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 basic arithmetic methods #541
Conversation
Hello @wtbarnes! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
@wtbarnes: Summarising our discussion on the sunpy call:
Feel free to push back if you feel this doesn't represent what we agreed. |
Any movement or planned movement on this @wtbarnes? |
Sorry I have not had any time to revisit this since the discussion you summarized above. I should have some time this week or next to make the refactor suggested in the above comment. |
f71d5b9
to
b5c014d
Compare
The logic here is not very clean and could probably be refactored a bit to avoid some repetition, but I believe this accomplishes what is laid out above. Currently, I'm not explicitly excluding NDCube or NDData instances, but they're implicitly caught by the "has-unit-but-is-not-a-quantity" case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great @wtbarnes. I haven't reviewed the tests but have left a few comments and one discussion point (about NDCube
vs NDCubeBase
). This PR isn't the end of the story but is a big leap forward and I believe isn't far off now.
The way you've filtered out the NDCube and NDData instances is a good way to go.
961b591
to
8152804
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still need to review this properly, but I want to keep the behaviour of NDCube and Map the same (in all things) at the moment, so if we are going to deviate from map for NotImplemeted
vs NotImplementedError
then I would want a PR open to sunpy core with the same change before we merge this one.
To be clear, the deviation from |
After discussion with @ayshih we identified the following remaining issues.
I will leave a few code suggestions in inline comments that should address the above issues. |
Just one minor correction in a comment, but otherwise I think this is ready to go |
Co-authored-by: Will Barnes <will.t.barnes@gmail.com>
Issues raised in review have been resolved
Thanks so much @wtbarnes for this!!!! |
This PR adds basic support for arithmetic methods on NDCube: add, subtract, multiply, divide. It explicitly does not support operations between NDCube objects (or more precisely anything that is an NDData instance).
There was also some discussion about to what extent we can support operations with Dask arrays. There is no issue if our NDCube is already backed by a Dask array. However, if the other object that we are performing the operation with is a Dask array, it will be eagerly evaluated because of the use of
Quantity
. This is probably not necessary and we should be checking possible other operands in a slightly different way.TODOs
Gallery exampleNotImplementedError