Skip to content

Commit c13478b

Browse files
committed
Fix SupportsArithmetic import
1 parent ad28d6a commit c13478b

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

cf_xarray/accessor.py

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,15 +1514,14 @@ def test_groupby_special_ops() -> None:
15141514
grouped = airds.groupby_bins("lat", np.arange(20, 50, 10))
15151515

15161516
# __iter__
1517-
for (label, group), (cflabel, cfgroup) in zip(grouped, cfgrouped, strict=False):
1517+
for (label, group), (cflabel, cfgroup) in zip(grouped, cfgrouped, strict=True):
15181518
assert label == cflabel
15191519
assert_identical(group, cfgroup)
15201520

15211521
# arithmetic
15221522
# TODO: Extremely buggy!
15231523
# 1. cfgrouped - cfgrouped.mean() raises RecursionError
1524-
# 2. use_flox=True doesn't preserve attributes for some reason
1525-
with xr.set_options(keep_attrs=True):
1524+
with xr.set_options(keep_attrs=True, use_flox=True):
15261525
expected = grouped - grouped.mean()
15271526
actual = grouped - cfgrouped.mean()
15281527
assert_identical(expected, actual)

0 commit comments

Comments
 (0)