MCPcopy Create free account
hub / github.com/dask/dask / _get_zarr_write_chunks

Function _get_zarr_write_chunks

dask/array/core.py:4122–4143  ·  view source on GitHub ↗

Get the appropriate chunk shape for writing to a Zarr array. For Zarr v3 arrays with sharding, returns the shard shape. For arrays without sharding, returns the chunk shape. For Zarr v2 arrays, returns the chunk shape. Parameters ---------- zarr_array : zarr.Array T

(zarr_array)

Source from the content-addressed store, hash-verified

4120
4121
4122def _get_zarr_write_chunks(zarr_array) -> tuple[int, ...]:
4123 """Get the appropriate chunk shape for writing to a Zarr array.
4124
4125 For Zarr v3 arrays with sharding, returns the shard shape.
4126 For arrays without sharding, returns the chunk shape.
4127 For Zarr v2 arrays, returns the chunk shape.
4128
4129 Parameters
4130 ----------
4131 zarr_array : zarr.Array
4132 The target zarr array
4133
4134 Returns
4135 -------
4136 tuple
4137 The chunk shape to use for rechunking the dask array
4138 """
4139 # Zarr V3 array with shards
4140 if hasattr(zarr_array, "shards") and zarr_array.shards is not None:
4141 return zarr_array.shards
4142 # Zarr V3 array without shards, or Zarr V2 array
4143 return zarr_array.chunks
4144
4145
4146def _check_regular_chunks(chunkset):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected