Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add matrix attributes zero and one #16898

Merged
merged 1 commit into from
May 28, 2019
Merged

Conversation

jksuom
Copy link
Member

@jksuom jksuom commented May 26, 2019

References to other Issues or PRs

#16883 and others

Brief description of what is fixed or changed

Matrix codebase currently makes use of the hardcoded constants
S.Zero and S.One. That is inconvenient when a non-Basic data
type is used to speed up computation (cf. #16883). This PR
replaces these constants with class attributes zero and one that
can be modified by subclassing.

Other comments

This is a step of work in progress.

Release Notes

  • matrices
    • Mutable attributes zero and one added to replace hardcoded S.Zero and S.One

Matrix codebase currently makes use of the hardcoded constants
S.Zero and S.One. That is inconvenient when a non-Basic data
type is used to speed up computation (cf. sympy#16883). This PR
replaces these constants with class attributes zero and one that
can be modified by subclassing.
@sympy-bot
Copy link

sympy-bot commented May 26, 2019

Hi, I am the SymPy bot (v147). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • matrices
    • Mutable attributes zero and one added to replace hardcoded S.Zero and S.One (#16898 by @jksuom)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.5.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234". See
https://github.com/blog/1506-closing-issues-via-pull-requests . Please also
write a comment on that issue linking back to this pull request once it is
open. -->
#16883 and others

#### Brief description of what is fixed or changed
Matrix codebase currently makes use of the hardcoded constants
S.Zero and S.One. That is inconvenient when a non-Basic data
type is used to speed up computation (cf. #16883). This PR
replaces these constants with class attributes zero and one that
can be modified by subclassing.


#### Other comments
This is a step of work in progress.

#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
- matrices
  - Mutable attributes zero and one added to replace hardcoded S.Zero and S.One
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@codecov
Copy link

codecov bot commented May 26, 2019

Codecov Report

Merging #16898 into master will increase coverage by 0.013%.
The diff coverage is 82.5%.

@@              Coverage Diff              @@
##            master    #16898       +/-   ##
=============================================
+ Coverage   73.891%   73.904%   +0.013%     
=============================================
  Files          619       619               
  Lines       160001    160005        +4     
  Branches     37554     37554               
=============================================
+ Hits        118227    118251       +24     
+ Misses       36300     36270       -30     
- Partials      5474      5484       +10

@oscarbenjamin
Copy link
Collaborator

This change seems reasonable.

If the zero/one types are tied determined by the Python class of the Matrix does that mean that a new class is needed for each type of matrix entry? Is the plan to create such classes?

@jksuom
Copy link
Member Author

jksuom commented May 27, 2019

does that mean that a new class is needed for each type of matrix entry?

I think that is what is needed. I would expect that only one class will have to be created in most cases.

Is the plan to create such classes?

Yes, I have planned to extend the polymatrix module to create new classes on demand. Those classes also have a ring attribute to allow inspection of the properties of matrix items. That is already done here:

if not (hasattr(m, "ring") and m.ring.is_PID):
raise ValueError(
"The matrix entries must be over a principal ideal domain")
but currently the ring attribute has to be monkey-patched (unless provided as keyword attribute domain). In the future, a special class should be created.

@jksuom
Copy link
Member Author

jksuom commented May 28, 2019

I'll merge in 24 h if there are no objections.

@oscarbenjamin
Copy link
Collaborator

+1 to merge

I don't see why the change here would be controversial.

@oscarbenjamin oscarbenjamin merged commit fc66c08 into sympy:master May 28, 2019
@jksuom
Copy link
Member Author

jksuom commented May 29, 2019

Thanks for taking a look.

@jksuom jksuom deleted the matrix-zero-one branch May 29, 2019 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants