Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename ds to dataset to avoid ambiguity with distributed scatterers #58

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading