WIP: New binary operations for cubes#881
Closed
shoyer wants to merge 3 commits intoSciTools:masterfrom
Closed
Conversation
To begin, I refactored iris.analysis.maths to reduce redundant code. It should be much more straightforward to write a new operation now. I believe all related tests are still passing. `iris.analysis.maths.exponentiate` can now take cubes or coordinates as arguments for the exponent, as long as the units still make sense. I also added comparison operations `>=`, `<=`, `>` and `<` to iris.analysis.maths and to cubes. These operators do the cube equivalent of the standard numpy operations, except with "cube aware" broadcasting. I would like to change the cube operators `==` and `!=` to match my new comparison operators but this would change the current API so it definitely needs to be discussed. I haven't added much in the way of new tests because the current tests for numerical operations look very awkward to write, relying on separate test data. I imagine new tests should go in tests/unit/analysis but I would appreciate some guidance here.
I think this covers (nearly) all the magic methods used by numpy: http://www.rafekettler.com/magicmethods.html
Contributor
Author
|
Guided by the example of the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To begin, I refactored iris.analysis.maths to reduce redundant code. It should
be much more straightforward to write a new operation now. I believe all
related tests are still passing.
iris.analysis.maths.exponentiatecan now take cubes or coordinates asarguments for the exponent, as long as the units still make sense.
I also added comparison operations
>=,<=,>and<toiris.analysis.maths and to cubes. These operators do the cube equivalent of
the standard numpy operations, except with "cube aware" broadcasting.
I would like to change the cube operators
==and!=to match my newcomparison operators but this would change the current API so it definitely
needs to be discussed.
I haven't added much in the way of new tests because the current tests for
numerical operations look very awkward to write, relying on separate test
data. I imagine new tests should go in tests/unit/analysis but I would
appreciate some guidance here.