Skip to content

Commit edaf57b

Browse files
authored
Fix mapping for VAR_KEYWORD type kwargs. (#66)
* Fix mapping for VAR_KEYWORD type kwargs. This allows plotting with variable names, not jsut cf names * Pin pandas < 1.1.0
1 parent 329b0cb commit edaf57b

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

cf_xarray/accessor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,11 @@ def _rewrite_values(
742742
maybe_update = {
743743
# TODO: this is assuming key_mappers[k] is always
744744
# _get_axis_coord_single
745-
k: apply_mapper(mapper, self._obj, v)[0]
745+
k: apply_mapper(
746+
key_mappers[k], self._obj, v, error=False, default=[v]
747+
)[0]
746748
for k, v in kwargs[vkw].items()
747749
if k in key_mappers
748-
for mapper in key_mappers[k]
749750
}
750751
kwargs[vkw].update(maybe_update)
751752

cf_xarray/tests/test_accessor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ def test_dataarray_plot(obj):
283283
assert all([isinstance(line, mpl.lines.Line2D) for line in rv])
284284
plt.close()
285285

286+
obj = obj.copy(deep=True)
287+
obj.time.attrs.clear()
288+
rv = obj.cf.plot(x="X", y="Y", col="time")
289+
assert isinstance(rv, xr.plot.FacetGrid)
290+
plt.close()
291+
286292

287293
@pytest.mark.parametrize("obj", datasets)
288294
def test_dataset_plot(obj):

ci/doc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies:
1212
- numpydoc
1313
- ipython
1414
- ipykernel
15+
- pandas<1.1.0
1516
- pip:
1617
- git+https://github.com/xarray-contrib/cf-xarray
1718
- sphinx-book-theme

ci/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ dependencies:
77
- dask
88
- matplotlib
99
- netcdf4
10+
- pandas<1.1.0
1011
- xarray

0 commit comments

Comments
 (0)