Skip to content

Commit

Permalink
BaseGrid __eq__ method no longer uses elementwise comparison (#82)
Browse files Browse the repository at this point in the history
If grids are not equal, numpy throws a Deprecation warning for elementwise comparison:
```
/home/charriso/micromamba/envs/ascat_env/lib/python3.8/site-packages/numpy/ma/core.py:4123: DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
  check = compare(sdata, odata)
```
Using np.array_equal(arr1, arr2) rather than np.all(arr1==arr2) should fix this
  • Loading branch information
claytharrison authored Nov 21, 2023
1 parent a241064 commit e5fcada
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pygeogrids/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ def __eq__(self, other):
# same
idx_gpi = np.argsort(self.gpis)
idx_gpi_other = np.argsort(other.gpis)
gpisame = np.all(self.gpis[idx_gpi] == other.gpis[idx_gpi_other])
gpisame = np.array_equal(self.gpis[idx_gpi], other.gpis[idx_gpi_other])
try:
nptest.assert_allclose(self.arrlon[idx_gpi], other.arrlon[idx_gpi_other])
lonsame = True
Expand Down

0 comments on commit e5fcada

Please sign in to comment.