Skip to content

Commit 4573aab

Browse files
committed
[bug] ds.variables and ds.data_vars are different things
1 parent 8deffef commit 4573aab

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/scores/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def make_dataarray_ref(self) -> xr.DataArray:
112112
if not self.is_dataarray():
113113
raise TypeError("Cannot revert name for xr.Dataset, only xr.DataArray")
114114

115-
var_names: list[Hashable] = list(self.ds.variables.keys())
115+
var_names: list[Hashable] = list(self.ds.data_vars.keys())
116116

117117
# safety: we should only have 1 variable if this is actually a data array
118118
assert len(var_names) == 1

tests/continuous/test_nse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def test_nse_with_datasets(self):
846846
assert set(res["temp"].dims) == set(["t", "h"])
847847
assert res["temp"].shape == (2, 4)
848848
# tapioca is ignored
849-
assert "tapioca" not in res.variables.keys()
849+
assert "tapioca" not in res.data_vars.keys()
850850

851851

852852
class TestNseDask(NseSetup):

tests/test_typing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_lift_dataarray_withname():
3232
da = xr.DataArray([1], dims="t", name=da_test_name)
3333
lds = scores.typing.LiftedDataset(da)
3434
# check lifted dataset only has one array
35-
keys = list(lds.ds.variables.keys())
35+
keys = list(lds.ds.data_vars.keys())
3636
assert len(keys) == 1
3737
# check that the name is preserved and isn't a dummy
3838
assert keys[0] == da_test_name
@@ -59,7 +59,7 @@ def test_lift_dataarray_withnameequalsdummy():
5959
da = xr.DataArray([1], dims="t", name=da_test_name)
6060
lds = scores.typing.LiftedDataset(da)
6161
# check lifted dataset only has one array
62-
keys = list(lds.ds.variables.keys())
62+
keys = list(lds.ds.data_vars.keys())
6363
assert len(keys) == 1
6464
# check that the name is the same as the dummy, BUT it isn't actually flagged as a dummy
6565
assert keys[0] == scores.typing.LiftedDataset._DUMMY_DATAARRAY_VARNAME # pylint: disable-msg=protected-access
@@ -82,7 +82,7 @@ def test_lift_dataarray_noname():
8282
da = xr.DataArray([1], dims="t")
8383
lds = scores.typing.LiftedDataset(da)
8484
# check lifted dataset only has one array
85-
keys = list(lds.ds.variables.keys())
85+
keys = list(lds.ds.data_vars.keys())
8686
assert len(keys) == 1
8787
# check that the name is the same as the dummy, AND is also flagged as dummy
8888
assert keys[0] == scores.typing.LiftedDataset._DUMMY_DATAARRAY_VARNAME # pylint: disable-msg=protected-access

0 commit comments

Comments
 (0)