Skip to content

WIP: New binary operations for cubes#881

Closed
shoyer wants to merge 3 commits intoSciTools:masterfrom
TheClimateCorporation:fix-binary-ops
Closed

WIP: New binary operations for cubes#881
shoyer wants to merge 3 commits intoSciTools:masterfrom
TheClimateCorporation:fix-binary-ops

Conversation

@shoyer
Copy link
Contributor

@shoyer shoyer commented Dec 11, 2013

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.

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
@shoyer
Copy link
Contributor Author

shoyer commented Dec 14, 2013

Guided by the example of the PartialDateTime PR, I decided to break this up into a series of smaller PRs, starting with #888.

@shoyer shoyer closed this Dec 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant