@@ -386,16 +386,19 @@ def _write_array_direct(
386386 ** kwargs ,
387387 }
388388
389- if zarr_fmt == 3 and region is None and zarr_array is None :
390- # Zarr v3, no region/zarr_array: use zarr.create_array and assign
389+ if zarr_fmt == 3 and zarr_array is None :
390+ # Zarr v3, use zarr.create_array and assign (whole array or region)
391391 array = zarr .create_array (
392392 store = store ,
393393 name = path ,
394394 shape = arr .shape ,
395395 dtype = arr .dtype ,
396396 ** to_zarr_kwargs ,
397397 )
398- array [:] = arr .compute ()
398+ if region is not None :
399+ array [region ] = arr .compute ()
400+ else :
401+ array [:] = arr .compute ()
399402 else :
400403 # All other cases: use dask.array.to_zarr
401404 target = zarr_array if (region is not None and zarr_array is not None ) else store
@@ -759,7 +762,7 @@ def to_ngff_zarr(
759762 :param chunks_per_shard: Number of chunks along each axis in a shard. If None, no sharding. Requires OME-Zarr version >= 0.5.
760763 :type chunks_per_shard: int, tuple, or dict, optional
761764
762- :param **kwargs: Passed to the zarr.creation.create() function, e.g., compression options.
765+ :param **kwargs: Passed to the zarr.create_array() or zarr. creation.create() function, e.g., compression options.
763766 """
764767 # Setup and validation
765768 store_path = str (store ) if isinstance (store , (str , Path )) else None
@@ -782,6 +785,11 @@ def to_ngff_zarr(
782785 format_kwargs = {"zarr_format" : zarr_format } if zarr_version_major >= 3 else {}
783786 _zarr_kwargs = zarr_kwargs .copy ()
784787
788+ if version == "0.4" and kwargs .get ("compressors" ) is not None :
789+ raise ValueError (
790+ "The argument `compressors` are not supported for OME-Zarr version 0.4. (Zarr v3). Use `compression` instead."
791+ )
792+
785793 if zarr_format == 2 and zarr_version_major >= 3 :
786794 _zarr_kwargs ["dimension_separator" ] = "/"
787795
0 commit comments