ExZarr.ChunkGrid.Regular (ExZarr v1.1.0)

View Source

Regular chunk grid implementation for Zarr v3.

In a regular chunk grid, all chunks have the same shape, except for edge chunks which may be smaller if the array dimensions are not evenly divisible by the chunk dimensions.

Configuration

The configuration map must contain:

  • "chunk_shape" - List of integers defining chunk dimensions

Example

config = %{
  "chunk_shape" => [100, 100, 100]
}

{:ok, grid} = ExZarr.ChunkGrid.Regular.init(config)

Specification

Zarr v3 Regular Chunk Grid: https://zarr-specs.readthedocs.io/en/latest/v3/core/index.html#regular-chunk-grid

Summary

Functions

Get all chunk indices for an array with the given shape.

Set the array shape for this chunk grid.

Types

t()

@type t() :: %ExZarr.ChunkGrid.Regular{
  array_shape: tuple() | nil,
  chunk_shape: tuple()
}

Functions

all_chunk_indices(regular)

@spec all_chunk_indices(t()) :: [tuple()]

Get all chunk indices for an array with the given shape.

Parameters

  • grid - Regular chunk grid state
  • array_shape - Shape of the array

Returns

  • List of chunk index tuples

Examples

iex> grid = %ExZarr.ChunkGrid.Regular{chunk_shape: {10, 10}, array_shape: {25, 15}}
iex> ExZarr.ChunkGrid.Regular.all_chunk_indices(grid)
[{0, 0}, {0, 1}, {1, 0}, {1, 1}, {2, 0}, {2, 1}]

set_array_shape(grid, array_shape)

@spec set_array_shape(t(), tuple()) :: t()

Set the array shape for this chunk grid.

Required for calculating edge chunk shapes and total chunk count.