Skip to content

Add easy way to iterate through every chunk of an array #2454

Open
@dstansby

Description

@dstansby

I am finding myself wanting to apply an operation (e.g., thresholding) on every chunk in an array. It would therefore be nice if there was an easy way to iterate through each chunk of the array.

Something like:

for i, chunk in enumerate(zarr_arr.all_chunks):
    zarr.all_chunks[i] = np.clip(chunk, min, max)

This is sort of similar to block indexing, but iterating over Array.blocks only iterates over the first axis of blocks, and gives you back all the chunks along the other axes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features or improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions