dask 2021.10.0

ParametersBackRef
normalize_chunks(chunks, shape=None, limit=None, dtype=None, previous_chunks=None)

This takes in a variety of input types and information and produces a full tuple-of-tuples result for chunks, suitable to be passed to Array or rechunk or any other operation that creates a Dask array.

Parameters

chunks: tuple, int, dict, or string :

The chunks to be normalized. See examples below for more details

shape: Tuple[int] :

The shape of the array

limit: int (optional) :

The maximum block size to target in bytes, if freedom is given to choose

dtype: np.dtype :
previous_chunks: Tuple[Tuple[int]] optional :

Chunks from a previous array that we should use for inspiration when rechunking auto dimensions. If not provided but auto-chunking exists then auto-dimensions will prefer square-like chunk shapes.

Normalize chunks to tuple of tuples

Examples

Specify uniform chunk sizes

This example is valid syntax, but we were not able to check execution
>>> from dask.array.core import normalize_chunks
... normalize_chunks((2, 2), shape=(5, 6)) ((2, 2, 1), (2, 2, 2))

Also passes through fully explicit tuple-of-tuples

This example is valid syntax, but we were not able to check execution
>>> normalize_chunks(((2, 2, 1), (2, 2, 2)), shape=(5, 6))
((2, 2, 1), (2, 2, 2))

Cleans up lists to tuples

This example is valid syntax, but we were not able to check execution
>>> normalize_chunks([[2, 2], [3, 3]])
((2, 2), (3, 3))

Expands integer inputs 10 -> (10, 10)

This example is valid syntax, but we were not able to check execution
>>> normalize_chunks(10, shape=(30, 5))
((10, 10, 10), (5,))

Expands dict inputs

This example is valid syntax, but we were not able to check execution
>>> normalize_chunks({0: 2, 1: 3}, shape=(6, 6))
((2, 2, 2), (3, 3))

The values -1 and None get mapped to full size

This example is valid syntax, but we were not able to check execution
>>> normalize_chunks((5, -1), shape=(10, 10))
((5, 5), (10,))

Use the value "auto" to automatically determine chunk sizes along certain dimensions. This uses the limit= and dtype= keywords to determine how large to make the chunks. The term "auto" can be used anywhere an integer can be used. See array chunking documentation for more information.

This example is valid syntax, but we were not able to check execution
>>> normalize_chunks(("auto",), shape=(20,), limit=5, dtype='uint8')
((5, 5, 5, 5),)

You can also use byte sizes (see dask.utils.parse_bytes ) in place of "auto" to ask for a particular size

This example is valid syntax, but we were not able to check execution
>>> normalize_chunks("1kiB", shape=(2000,), dtype='float32')
((250, 250, 250, 250, 250, 250, 250, 250),)

Respects null dimensions

This example is valid syntax, but we were not able to check execution
>>> normalize_chunks((), shape=(0, 0))
((0,), (0,))
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.array.core.auto_chunks dask.array.core.normalize_chunks

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/core.py#2698
type: <class 'function'>
Commit: