Skip to content

Commit 03384be

Browse files
Fix np scaler warning in _drop_missing_variables() (#291)
Co-authored-by: dcherian <[email protected]>
1 parent 942d735 commit 03384be

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cf_xarray/accessor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,12 @@ def isin(self, test_elements):
10301030
return self._obj.isin(mapped_test_elements)
10311031

10321032
def _drop_missing_variables(self, variables: list[str]) -> list[str]:
1033+
if isinstance(self._obj, Dataset):
1034+
good_names = set(self._obj.variables)
1035+
elif isinstance(self._obj, DataArray):
1036+
good_names = set(self._obj.coords)
10331037

1034-
return [var for var in variables if var in self._obj or var in self._obj.coords]
1038+
return [var for var in variables if var in good_names]
10351039

10361040
def _get_all_cell_measures(self):
10371041
"""

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ What's New
55
v0.6.4 (unreleased)
66
===================
77
- integrate ``xclim``'s CF-compliant unit formatter. :pr:`278`. By `Justus Magin`_.
8+
- Fix dropping of bad variable names. :pr:`291`. By `Tom Vo`_.
89

910
v0.6.3 (December 16, 2021)
1011
==========================
@@ -142,4 +143,5 @@ v0.1.3
142143
.. _`Kristen Thyng`: https://github.com/kthyng
143144
.. _`Julius Busecke`: https://github.com/jbusecke
144145
.. _`Filipe Fernandes`: https://github.com/ocefpaf
146+
.. _`Tom Vo`: https://github.com/tomvothecoder
145147
.. _`flag variables`: http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#flags

0 commit comments

Comments
 (0)