| 
10 | 10 | 
 
  | 
11 | 11 | from zarr.abc.store import Store  | 
12 | 12 | from zarr.core.array import Array, AsyncArray, get_array_metadata  | 
 | 13 | +from zarr.core.buffer import NDArrayLike  | 
13 | 14 | from zarr.core.common import (  | 
14 | 15 |     JSON,  | 
15 | 16 |     AccessModeLiteral,  | 
 | 
31 | 32 |     from collections.abc import Iterable  | 
32 | 33 | 
 
  | 
33 | 34 |     from zarr.abc.codec import Codec  | 
34 |  | -    from zarr.core.buffer import NDArrayLike  | 
35 | 35 |     from zarr.core.chunk_key_encodings import ChunkKeyEncoding  | 
36 | 36 | 
 
  | 
37 | 37 |     # TODO: this type could use some more thought  | 
@@ -390,6 +390,8 @@ async def save_array(  | 
390 | 390 |         _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)  | 
391 | 391 |         or _default_zarr_version()  | 
392 | 392 |     )  | 
 | 393 | +    if not isinstance(arr, NDArrayLike):  | 
 | 394 | +        raise TypeError("arr argument must be numpy or other NDArrayLike array")  | 
393 | 395 | 
 
  | 
394 | 396 |     mode = kwargs.pop("mode", None)  | 
395 | 397 |     store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)  | 
@@ -444,16 +446,26 @@ async def save_group(  | 
444 | 446 |         or _default_zarr_version()  | 
445 | 447 |     )  | 
446 | 448 | 
 
  | 
 | 449 | +    for arg in args:  | 
 | 450 | +        if not isinstance(arg, NDArrayLike):  | 
 | 451 | +            raise TypeError(  | 
 | 452 | +                "All arguments must be numpy or other NDArrayLike arrays (except store, path, storage_options, and zarr_format)"  | 
 | 453 | +            )  | 
 | 454 | +    for k, v in kwargs.items():  | 
 | 455 | +        if not isinstance(v, NDArrayLike):  | 
 | 456 | +            raise TypeError(f"Keyword argument '{k}' must be a numpy or other NDArrayLike array")  | 
 | 457 | + | 
447 | 458 |     if len(args) == 0 and len(kwargs) == 0:  | 
448 | 459 |         raise ValueError("at least one array must be provided")  | 
449 | 460 |     aws = []  | 
450 | 461 |     for i, arr in enumerate(args):  | 
 | 462 | +        _path = f"{path}/arr_{i}" if path is not None else f"arr_{i}"  | 
451 | 463 |         aws.append(  | 
452 | 464 |             save_array(  | 
453 | 465 |                 store,  | 
454 | 466 |                 arr,  | 
455 | 467 |                 zarr_format=zarr_format,  | 
456 |  | -                path=f"{path}/arr_{i}",  | 
 | 468 | +                path=_path,  | 
457 | 469 |                 storage_options=storage_options,  | 
458 | 470 |             )  | 
459 | 471 |         )  | 
@@ -865,9 +877,8 @@ async def create(  | 
865 | 877 |         warnings.warn("meta_array is not yet implemented", RuntimeWarning, stacklevel=2)  | 
866 | 878 | 
 
  | 
867 | 879 |     mode = kwargs.pop("mode", None)  | 
868 |  | -    if mode is None:  | 
869 |  | -        if not isinstance(store, Store | StorePath):  | 
870 |  | -            mode = "a"  | 
 | 880 | +    if mode is None and not isinstance(store, Store | StorePath):  | 
 | 881 | +        mode = "a"  | 
871 | 882 | 
 
  | 
872 | 883 |     store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)  | 
873 | 884 | 
 
  | 
 | 
0 commit comments