Skip to content

Commit 55f3324

Browse files
committed
replace dims with sizes in io too
1 parent 0d53be1 commit 55f3324

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

sarxarray/_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def from_dataset(ds: xr.Dataset) -> xr.Dataset:
4545
The input dataset should have the following variables: `('real', 'imag')`.
4646
"""
4747
# Check ds should have the following dimensions: (azimuth, range, time)
48-
if any(dim not in ds.dims for dim in ["azimuth", "range", "time"]):
48+
if any(dim not in list(ds.sizes) for dim in ["azimuth", "range", "time"]):
4949
raise ValueError(
5050
"The input dataset should have three dimensions: (azimuth, range, time)."
5151
)

tests/test_io.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_from_dataset_normal(self):
2626
f"{os.path.dirname(__file__)}/data/zarrs/slcs_example.zarr"
2727
)
2828
slcs = sarxarray.from_dataset(test_ds)
29-
assert all(dim in slcs.dims for dim in ["azimuth", "range", "time"])
29+
assert all(dim in list(slcs.sizes) for dim in ["azimuth", "range", "time"])
3030
assert all(var not in slcs.variables.keys() for var in ["real", "imag"])
3131
assert all(
3232
var in slcs.variables.keys() for var in ["complex", "amplitude", "phase"]
@@ -60,7 +60,7 @@ def test_loading_vars_and_coords(self, test_slcs):
6060
assert set(["azimuth", "range", "time"]).issubset(
6161
[k for k in stack.coords.keys()]
6262
)
63-
assert stack.dims == {"azimuth": 100, "range": 100, "time": 2}
63+
assert stack.sizes == {"azimuth": 100, "range": 100, "time": 2}
6464

6565
def test_loading_custom_var(self, test_slcs):
6666
"""When other var names specified, do not compute amplitude and range"""
@@ -75,7 +75,7 @@ def test_loading_custom_var(self, test_slcs):
7575
assert not (
7676
set(["amplitude", "phase"]).issubset([k for k in stack.coords.keys()])
7777
)
78-
assert stack.dims == {"azimuth": 100, "range": 100, "time": 2}
78+
assert stack.sizes == {"azimuth": 100, "range": 100, "time": 2}
7979

8080
def test_loading_chunksizes(self, test_slcs):
8181
stack = sarxarray.from_binary(
@@ -114,7 +114,7 @@ def test_loading_one_slc(self, test_slcs):
114114
assert set(["azimuth", "range", "time"]).issubset(
115115
[k for k in stack.coords.keys()]
116116
)
117-
assert stack.dims == {"azimuth": 100, "range": 100, "time": 1}
117+
assert stack.sizes == {"azimuth": 100, "range": 100, "time": 1}
118118

119119

120120
class TestUtils:

0 commit comments

Comments
 (0)