Skip to content

Commit 921490b

Browse files
authored
Fix SupportsArithmetic import (#563)
1 parent b11e491 commit 921490b

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

cf_xarray/accessor.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import xarray as xr
2626
from xarray import DataArray, Dataset
27-
from xarray.core.arithmetic import SupportsArithmetic
2827
from xarray.core.groupby import GroupBy
2928
from xarray.core.resample import Resample
3029
from xarray.core.rolling import Coarsen, Rolling
@@ -997,7 +996,7 @@ def _get_possible(accessor, criteria):
997996
return _get_possible(obj.cf, y_criteria)
998997

999998

1000-
class _CFWrappedClass(SupportsArithmetic):
999+
class _CFWrappedClass:
10011000
"""
10021001
This class is used to wrap any class in _WRAPPED_CLASSES.
10031002
"""

cf_xarray/tests/test_accessor.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1524,15 +1524,14 @@ def test_groupby_special_ops() -> None:
15241524
grouped = airds.groupby_bins("lat", np.arange(20, 50, 10))
15251525

15261526
# __iter__
1527-
for (label, group), (cflabel, cfgroup) in zip(grouped, cfgrouped, strict=False):
1527+
for (label, group), (cflabel, cfgroup) in zip(grouped, cfgrouped, strict=True):
15281528
assert label == cflabel
15291529
assert_identical(group, cfgroup)
15301530

15311531
# arithmetic
15321532
# TODO: Extremely buggy!
15331533
# 1. cfgrouped - cfgrouped.mean() raises RecursionError
1534-
# 2. use_flox=True doesn't preserve attributes for some reason
1535-
with xr.set_options(keep_attrs=True):
1534+
with xr.set_options(keep_attrs=True, use_flox=True):
15361535
expected = grouped - grouped.mean()
15371536
actual = grouped - cfgrouped.mean()
15381537
assert_identical(expected, actual)

0 commit comments

Comments
 (0)