Skip to content

Commit 57e61cc

Browse files
committed
Small improvements.
1 parent 6d81630 commit 57e61cc

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

cf_xarray/accessor.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,6 @@ def _get_measure(da: Union[DataArray, Dataset], key: str) -> List[str]:
262262

263263

264264
#: Default mappers for common keys.
265-
# TODO: Make the values of this a tuple,
266-
# so that multiple mappers can be used for a single key
267-
# We need this for groupby("T.month") and groupby("latitude") for example.
268265
_DEFAULT_KEY_MAPPERS: Mapping[str, Tuple[Mapper, ...]] = {
269266
"dim": (_get_axis_coord,),
270267
"dims": (_get_axis_coord,), # is this necessary?
@@ -301,7 +298,7 @@ def _get_list_standard_names(obj: Dataset) -> List[str]:
301298
----------
302299
303300
obj: DataArray, Dataset
304-
Xarray objec to process
301+
Xarray object to process
305302
306303
Returns
307304
-------
@@ -568,7 +565,7 @@ def _process_signature(
568565
def _rewrite_values(
569566
self,
570567
kwargs,
571-
key_mappers: MutableMapping[str, Tuple[Mapper, ...]],
568+
key_mappers: Mapping[str, Tuple[Mapper, ...]],
572569
var_kws: Tuple[str, ...],
573570
):
574571
"""
@@ -593,11 +590,11 @@ def _rewrite_values(
593590

594591
# allow multiple return values here.
595592
# these are valid for .sel, .isel, .coarsen
596-
key_mappers.update(dict.fromkeys(var_kws, (_get_axis_coord,)))
593+
all_mappers = ChainMap(key_mappers, dict.fromkeys(var_kws, (_get_axis_coord,)))
597594

598-
for key in set(key_mappers) & set(kwargs):
595+
for key in set(all_mappers) & set(kwargs):
599596
value = kwargs[key]
600-
mappers = key_mappers[key]
597+
mappers = all_mappers[key]
601598

602599
if isinstance(value, str):
603600
value = [value]

0 commit comments

Comments
 (0)