Skip to content

Commit

Permalink
Do not return <this-array> instances (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
aulemahal authored Feb 24, 2021
1 parent af85a2a commit 54b897a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cf_xarray/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def _get_with_standard_name(

varnames = []
if isinstance(obj, DataArray):
obj = obj._to_temp_dataset()
obj = obj.coords.to_dataset()
for vname, var in obj.variables.items():
stdname = var.attrs.get("standard_name", None)
if stdname == name:
Expand Down
4 changes: 4 additions & 0 deletions cf_xarray/tests/test_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ def test_getitem_standard_name():
expected = airds["air"]
assert_identical(actual, expected)

actual = airds.lat.cf["latitude"]
expected = airds["lat"]
assert_identical(actual, expected)

ds = airds.copy(deep=True)
ds["air2"] = ds.air
with pytest.raises(KeyError):
Expand Down

0 comments on commit 54b897a

Please sign in to comment.