Skip to content

to_zarr() produces error when trying to use keyword 'region' #4636

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

Closed
mloeffelbein opened this issue Dec 1, 2020 · 2 comments
Closed

to_zarr() produces error when trying to use keyword 'region' #4636

mloeffelbein opened this issue Dec 1, 2020 · 2 comments

Comments

@mloeffelbein
Copy link

When executing the code from the v0.16.1 documentation ds.isel(x=slice(0, 10)).to_zarr(path, region={"x": slice(0, 10)}) an error was produced:

Traceback (most recent call last):
File "", line 1, in
TypeError: to_zarr() got an unexpected keyword argument 'region'

Code copied from v0.16.1 documentation.

 
import numpy as np
import xarray as xr
import dask.array

dummies = dask.array.zeros(30, chunks=10)
ds = xr.Dataset({"foo": ("x", dummies)})
path = "path/to/directory.zarr"
ds.to_zarr(path, compute=False, consolidated=True)

ds = xr.Dataset({"foo": ("x", np.arange(30))})
ds.isel(x=slice(0, 10)).to_zarr(path, region={"x": slice(0, 10)})
Output of xr.show_versions()

xr.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.7.7 (default, Mar 26 2020, 15:48:22)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-53-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.4

xarray: 0.16.1
pandas: 1.1.3
numpy: 1.19.2
scipy: 1.5.2
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: None
Nio: 1.5.5
zarr: 2.5.0
cftime: 1.3.0
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.1.0
cfgrib: 0.9.8.4
iris: None
bottleneck: 1.3.2
dask: 2.30.0
distributed: 2.30.1
matplotlib: 3.3.2
cartopy: None
seaborn: None
numbagg: None
pint: None
setuptools: 50.3.1.post20201107
pip: 20.2.4
conda: None
pytest: None
IPython: 5.8.0
sphinx: None

@keewis
Copy link
Collaborator

keewis commented Dec 1, 2020

that's not actually the documentation of v0.16.1 but a PR documentation preview (which should have been removed once #4035 was merged). The region keyword argument is new in v0.16.2, so you need to upgrade xarray to be able to use it.

@mloeffelbein
Copy link
Author

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants