| 
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  | 
@@ -393,6 +393,8 @@ async def save_array(  | 
393 | 393 |         _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)  | 
394 | 394 |         or _default_zarr_version()  | 
395 | 395 |     )  | 
 | 396 | +    if not isinstance(arr, NDArrayLike):  | 
 | 397 | +        raise TypeError("arr argument must be numpy or other NDArrayLike array")  | 
396 | 398 | 
 
  | 
397 | 399 |     mode = kwargs.pop("mode", None)  | 
398 | 400 |     store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)  | 
@@ -447,16 +449,26 @@ async def save_group(  | 
447 | 449 |         or _default_zarr_version()  | 
448 | 450 |     )  | 
449 | 451 | 
 
  | 
 | 452 | +    for arg in args:  | 
 | 453 | +        if not isinstance(arg, NDArrayLike):  | 
 | 454 | +            raise TypeError(  | 
 | 455 | +                "All arguments must be numpy or other NDArrayLike arrays (except store, path, storage_options, and zarr_format)"  | 
 | 456 | +            )  | 
 | 457 | +    for k, v in kwargs.items():  | 
 | 458 | +        if not isinstance(v, NDArrayLike):  | 
 | 459 | +            raise TypeError(f"Keyword argument '{k}' must be a numpy or other NDArrayLike array")  | 
 | 460 | + | 
450 | 461 |     if len(args) == 0 and len(kwargs) == 0:  | 
451 | 462 |         raise ValueError("at least one array must be provided")  | 
452 | 463 |     aws = []  | 
453 | 464 |     for i, arr in enumerate(args):  | 
 | 465 | +        _path = f"{path}/arr_{i}" if path is not None else f"arr_{i}"  | 
454 | 466 |         aws.append(  | 
455 | 467 |             save_array(  | 
456 | 468 |                 store,  | 
457 | 469 |                 arr,  | 
458 | 470 |                 zarr_format=zarr_format,  | 
459 |  | -                path=f"{path}/arr_{i}",  | 
 | 471 | +                path=_path,  | 
460 | 472 |                 storage_options=storage_options,  | 
461 | 473 |             )  | 
462 | 474 |         )  | 
 | 
0 commit comments