@@ -28,7 +28,7 @@ def _check_and_update_path(store: BaseStore, path):
28
28
29
29
30
30
# noinspection PyShadowingBuiltins
31
- def open (store : StoreLike = None , mode : str = "a" , * , zarr_version = 2 , path = None , ** kwargs ):
31
+ def open (store : StoreLike = None , mode : str = "a" , * , zarr_version = None , path = None , ** kwargs ):
32
32
"""Convenience function to open a group or array using file-mode-like semantics.
33
33
34
34
Parameters
@@ -40,9 +40,11 @@ def open(store: StoreLike = None, mode: str = "a", *, zarr_version=2, path=None,
40
40
read/write (must exist); 'a' means read/write (create if doesn't
41
41
exist); 'w' means create (overwrite if exists); 'w-' means create
42
42
(fail if exists).
43
- zarr_version : {2, 3}
44
- The zarr protocol version to use.
45
- path : str
43
+ zarr_version : {2, 3, None}, optional
44
+ The zarr protocol version to use. The default value of None will attempt
45
+ to infer the version from `store` if possible, otherwise it will fall
46
+ back to 2.
47
+ path : str or None, optional
46
48
The path within the store to open.
47
49
**kwargs
48
50
Additional parameters are passed through to :func:`zarr.creation.open_array` or
@@ -93,7 +95,8 @@ def open(store: StoreLike = None, mode: str = "a", *, zarr_version=2, path=None,
93
95
store , clobber = clobber , storage_options = kwargs .pop ("storage_options" , {}),
94
96
zarr_version = zarr_version ,
95
97
)
96
- path = _check_and_update_path (_store , path )
98
+ # path = _check_and_update_path(_store, path)
99
+ path = normalize_storage_path (path )
97
100
kwargs ['path' ] = path
98
101
99
102
if mode in {'w' , 'w-' , 'x' }:
@@ -121,7 +124,7 @@ def _might_close(path):
121
124
return isinstance (path , (str , os .PathLike ))
122
125
123
126
124
- def save_array (store : StoreLike , arr , * , zarr_version = 2 , path = None , ** kwargs ):
127
+ def save_array (store : StoreLike , arr , * , zarr_version = None , path = None , ** kwargs ):
125
128
"""Convenience function to save a NumPy array to the local file system, following a
126
129
similar API to the NumPy save() function.
127
130
@@ -131,9 +134,11 @@ def save_array(store: StoreLike, arr, *, zarr_version=2, path=None, **kwargs):
131
134
Store or path to directory in file system or name of zip file.
132
135
arr : ndarray
133
136
NumPy array with data to save.
134
- zarr_version : {2, 3}
135
- The zarr protocol version to use when saving.
136
- path : str
137
+ zarr_version : {2, 3, None}, optional
138
+ The zarr protocol version to use when saving. The default value of None
139
+ will attempt to infer the version from `store` if possible, otherwise
140
+ it will fall back to 2.
141
+ path : str or None, optional
137
142
The path within the store where the array will be saved.
138
143
kwargs
139
144
Passed through to :func:`create`, e.g., compressor.
@@ -168,7 +173,7 @@ def save_array(store: StoreLike, arr, *, zarr_version=2, path=None, **kwargs):
168
173
_store .close ()
169
174
170
175
171
- def save_group (store : StoreLike , * args , zarr_version = 2 , path = None , ** kwargs ):
176
+ def save_group (store : StoreLike , * args , zarr_version = None , path = None , ** kwargs ):
172
177
"""Convenience function to save several NumPy arrays to the local file system, following a
173
178
similar API to the NumPy savez()/savez_compressed() functions.
174
179
@@ -178,9 +183,11 @@ def save_group(store: StoreLike, *args, zarr_version=2, path=None, **kwargs):
178
183
Store or path to directory in file system or name of zip file.
179
184
args : ndarray
180
185
NumPy arrays with data to save.
181
- zarr_version : {2, 3}
182
- The zarr protocol version to use when saving.
183
- path : str
186
+ zarr_version : {2, 3, None}, optional
187
+ The zarr protocol version to use when saving. The default value of None
188
+ will attempt to infer the version from `store` if possible, otherwise
189
+ it will fall back to 2.
190
+ path : str or None, optional
184
191
Path within the store where the group will be saved.
185
192
kwargs
186
193
NumPy arrays with data to save.
@@ -249,7 +256,7 @@ def save_group(store: StoreLike, *args, zarr_version=2, path=None, **kwargs):
249
256
_store .close ()
250
257
251
258
252
- def save (store : StoreLike , * args , zarr_version = 2 , path = None , ** kwargs ):
259
+ def save (store : StoreLike , * args , zarr_version = None , path = None , ** kwargs ):
253
260
"""Convenience function to save an array or group of arrays to the local file system.
254
261
255
262
Parameters
@@ -258,9 +265,11 @@ def save(store: StoreLike, *args, zarr_version=2, path=None, **kwargs):
258
265
Store or path to directory in file system or name of zip file.
259
266
args : ndarray
260
267
NumPy arrays with data to save.
261
- zarr_version : {2, 3}
262
- The zarr protocol version to use when saving.
263
- path : str
268
+ zarr_version : {2, 3, None}, optional
269
+ The zarr protocol version to use when saving. The default value of None
270
+ will attempt to infer the version from `store` if possible, otherwise
271
+ it will fall back to 2.
272
+ path : str or None, optional
264
273
The path within the group where the arrays will be saved.
265
274
kwargs
266
275
NumPy arrays with data to save.
@@ -364,13 +373,19 @@ def __repr__(self):
364
373
return r
365
374
366
375
367
- def load (store : StoreLike , zarr_version = 2 , path = None ):
376
+ def load (store : StoreLike , zarr_version = None , path = None ):
368
377
"""Load data from an array or group into memory.
369
378
370
379
Parameters
371
380
----------
372
381
store : MutableMapping or string
373
382
Store or path to directory in file system or name of zip file.
383
+ zarr_version : {2, 3, None}, optional
384
+ The zarr protocol version to use when loading. The default value of
385
+ None will attempt to infer the version from `store` if possible,
386
+ otherwise it will fall back to 2.
387
+ path : str or None, optional
388
+ The path within the store from which to load.
374
389
375
390
Returns
376
391
-------
0 commit comments