Skip to content

Commit

Permalink
rename ds to dataset to avoid ambiguity with distributed scatterers
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerkuou committed Oct 21, 2024
1 parent 6bfd60a commit 66a663f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions sarxarray/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from sarxarray import stack
from sarxarray._io import from_binary, from_ds
from sarxarray._io import from_binary, from_dataset
from sarxarray.utils import complex_coherence, multi_look

__all__ = ("stack", "from_binary", "from_ds", "multi_look", "complex_coherence")
__all__ = ("stack", "from_binary", "from_dataset", "multi_look", "complex_coherence")
2 changes: 1 addition & 1 deletion sarxarray/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Example: https://docs.dask.org/en/stable/array-creation.html#memory-mapping


def from_ds(ds: xr.Dataset) -> xr.Dataset:
def from_dataset(ds: xr.Dataset) -> xr.Dataset:
"""Create a SLC stack or from an Xarray Dataset.
This function create tasks graph converting the two data variables of complex data:
Expand Down
14 changes: 7 additions & 7 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@ def test_slcs():


class TestFromDS:
"""from_ds in _io.py"""
"""from_dataset in _io.py"""

def test_from_ds_normal(self):
def test_from_dataset_normal(self):
test_ds = xr.open_zarr(
f"{os.path.dirname(__file__)}/data/zarrs/slcs_example.zarr"
)
slcs = sarxarray.from_ds(test_ds)
slcs = sarxarray.from_dataset(test_ds)
assert all(dim in slcs.dims for dim in ["azimuth", "range", "time"])
assert all(var not in slcs.variables.keys() for var in ["real", "imag"])
assert all(
var in slcs.variables.keys() for var in ["complex", "amplitude", "phase"]
)

def test_from_ds_broken_dim(self):
def test_from_dataset_broken_dim(self):
test_ds_broken_dim = xr.open_zarr(
f"{os.path.dirname(__file__)}/data/zarrs/slcs_example_broken_dim.zarr"
)
with pytest.raises(ValueError):
sarxarray.from_ds(test_ds_broken_dim)
sarxarray.from_dataset(test_ds_broken_dim)

def test_from_ds_broken_vars(self):
def test_from_dataset_broken_vars(self):
test_ds_broken_vars = xr.open_zarr(
f"{os.path.dirname(__file__)}/data/zarrs/slcs_example_broken_vars.zarr"
)
with pytest.raises(ValueError):
sarxarray.from_ds(test_ds_broken_vars)
sarxarray.from_dataset(test_ds_broken_vars)


class TestFromBinary:
Expand Down

0 comments on commit 66a663f

Please sign in to comment.