Skip to content

Commit df4d94a

Browse files
authored
Merge pull request #21 from kthyng/main
small but important fix
2 parents e2606d5 + 297621b commit df4d94a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cf_pandas/accessor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ def keys(self) -> Set[str]:
161161

162162
varnames = list(self.axes) + list(self.coordinates)
163163
try:
164-
varnames.extend(list(self.custom_keys))
164+
# see which custom keys have matched values in object
165+
matched_keys = [
166+
key for key, val in self.custom_keys.items() if len(val) > 0
167+
]
168+
varnames.extend(matched_keys)
165169
except ValueError:
166170
# don't have criteria defined, then no custom keys to report
167171
pass

tests/test_accessor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"temp2": {
1717
"standard_name": "temp$",
1818
},
19+
"salt2": {"standard_name": "sal$"},
1920
}
2021

2122

@@ -73,6 +74,7 @@ def test_match_criteria_key_accessor():
7374
]
7475
assert "X" in df.cf
7576
assert "Y" not in df.cf
77+
assert "salt2" not in df.cf
7678

7779

7880
@mock.patch("requests.get")

0 commit comments

Comments
 (0)