Skip to content

Commit 0d60420

Browse files
authored
Fix .isel and .sel with dictionaries (#54)
1 parent e685d58 commit 0d60420

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

cf_xarray/accessor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def _get_measure(da: Union[xr.DataArray, xr.Dataset], key: str) -> List[Optional
276276
# We need this for groupby("T.month") and groupby("latitude") for example.
277277
_DEFAULT_KEY_MAPPERS: Mapping[str, Mapper] = {
278278
"dim": _get_axis_coord,
279+
"indexers": _get_axis_coord, # sel, isel
279280
"dims_or_levels": _get_axis_coord, # reset_index
280281
"coord": _get_axis_coord_single,
281282
"group": _get_axis_coord_single,

cf_xarray/tests/test_accessor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ def test_kwargs_methods(obj):
154154
actual = obj.cf.isel(T=slice(2))
155155
assert_identical(expected, actual)
156156

157+
with raise_if_dask_computes():
158+
expected = obj.isel({"time": slice(2)})
159+
actual = obj.cf.isel({"T": slice(2)})
160+
assert_identical(expected, actual)
161+
157162

158163
def test_kwargs_expand_key_to_multiple_keys():
159164

0 commit comments

Comments
 (0)