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

Decide of the naming of strict or relaxed equality (__eq__ or raster_equal?) #316

Closed
rhugonnet opened this issue Sep 21, 2022 · 1 comment
Labels
enhancement Feature improvement or request

Comments

@rhugonnet
Copy link
Member

See #313 (comment)
Right now __eq__ checks that data.data and data.mask (and other attributes) are equal, and np.ma.allequal can be used to compare .data with masked values.
Several solutions we could implement:

  • We could add np.array_equal to __array_function__ to be castable on a Raster;
  • We could add a gu.raster_equal function that accounts potentially for nodata with an argument;
  • For equality with __eq__, what do we do? Should we mirror behaviour from NumPy or not for this? Actually NumPy broadcasts to element-wise equality with __eq__.

Example copied from @adehecq on Slack:

import numpy as np
data = np.ma.masked_array(np.arange(9).reshape((3,3)))
data[0, 0] = np.ma.masked
data2 = data.copy()
data2.data[0, 0] = 10
data == data2. # returns True for all unmasked values, masked otherwise
np.all(data == data2) # True
np.ma.allequal(data, data2) # True
@rhugonnet
Copy link
Member Author

Solved by #351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature improvement or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant