Skip to content

Commit

Permalink
Add kwargs to load_dataset to pass to xarray, matching `save_data…
Browse files Browse the repository at this point in the history
…set`
  • Loading branch information
tomwhite authored and mergify[bot] committed Feb 1, 2023
1 parent 2e047c0 commit 2baf610
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sgkit/io/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def save_dataset(
store: Union[PathType, MutableMapping[str, bytes]],
storage_options: Optional[Dict[str, str]] = None,
auto_rechunk: Optional[bool] = None,
**kwargs: Any
**kwargs: Any,
) -> None:
"""Save a dataset to Zarr storage.
Expand Down Expand Up @@ -87,6 +87,7 @@ def save_dataset(
def load_dataset(
store: Union[PathType, MutableMapping[str, bytes]],
storage_options: Optional[Dict[str, str]] = None,
**kwargs: Any,
) -> Dataset:
"""Load a dataset from Zarr storage.
Expand All @@ -99,6 +100,8 @@ def load_dataset(
Zarr store or path to directory in file system to load from.
storage_options:
Any additional parameters for the storage backend (see ``fsspec.open``).
kwargs
Additional arguments to pass to :func:`xarray.open_zarr`.
Returns
-------
Expand All @@ -110,7 +113,7 @@ def load_dataset(
store = fsspec.get_mapper(store, **storage_options)
elif isinstance(store, Path):
store = str(store)
ds: Dataset = xr.open_zarr(store, concat_characters=False) # type: ignore[no-untyped-call]
ds: Dataset = xr.open_zarr(store, concat_characters=False, **kwargs) # type: ignore[no-untyped-call]
for v in ds:
# Workaround for https://github.com/pydata/xarray/issues/4386
if v.endswith("_mask"): # type: ignore
Expand Down

0 comments on commit 2baf610

Please sign in to comment.