MCPcopy
hub / github.com/pydata/xarray / chunk

Method chunk

xarray/core/datatree.py:2591–2685  ·  view source on GitHub ↗

Coerce all arrays in all groups in this tree into dask arrays with the given chunks. Non-dask arrays in this tree will be converted to dask arrays. Dask arrays will be rechunked to the given chunk sizes. If neither chunks is not provided for one or more dimensions,

(
        self,
        chunks: T_ChunksFreq = {},  # noqa: B006  # {} even though it's technically unsafe, is being used intentionally here (#4667)
        name_prefix: str = "xarray-",
        token: str | None = None,
        lock: bool = False,
        inline_array: bool = False,
        chunked_array_type: str | ChunkManagerEntrypoint | None = None,
        from_array_kwargs=None,
        **chunks_kwargs: T_ChunkDimFreq,
    )

Source from the content-addressed store, hash-verified

2589 )
2590
2591 def chunk(
2592 self,
2593 chunks: T_ChunksFreq = {}, # noqa: B006 # {} even though it's technically unsafe, is being used intentionally here (#4667)
2594 name_prefix: str = "xarray-",
2595 token: str | None = None,
2596 lock: bool = False,
2597 inline_array: bool = False,
2598 chunked_array_type: str | ChunkManagerEntrypoint | None = None,
2599 from_array_kwargs=None,
2600 **chunks_kwargs: T_ChunkDimFreq,
2601 ) -> Self:
2602 """Coerce all arrays in all groups in this tree into dask arrays with the given
2603 chunks.
2604
2605 Non-dask arrays in this tree will be converted to dask arrays. Dask
2606 arrays will be rechunked to the given chunk sizes.
2607
2608 If neither chunks is not provided for one or more dimensions, chunk
2609 sizes along that dimension will not be updated; non-dask arrays will be
2610 converted into dask arrays with a single block.
2611
2612 Along datetime-like dimensions, a :py:class:`groupers.TimeResampler` object is also accepted.
2613
2614 Parameters
2615 ----------
2616 chunks : int, tuple of int, "auto" or mapping of hashable to int or a TimeResampler, optional
2617 Chunk sizes along each dimension, e.g., ``5``, ``"auto"``, or
2618 ``{"x": 5, "y": 5}`` or ``{"x": 5, "time": TimeResampler(freq="YE")}``.
2619 name_prefix : str, default: "xarray-"
2620 Prefix for the name of any new dask arrays.
2621 token : str, optional
2622 Token uniquely identifying this datatree.
2623 lock : bool, default: False
2624 Passed on to :py:func:`dask.array.from_array`, if the array is not
2625 already as dask array.
2626 inline_array: bool, default: False
2627 Passed on to :py:func:`dask.array.from_array`, if the array is not
2628 already as dask array.
2629 chunked_array_type: str, optional
2630 Which chunked array type to coerce this datatree's arrays to.
2631 Defaults to 'dask' if installed, else whatever is registered via the `ChunkManagerEntryPoint` system.
2632 Experimental API that should not be relied upon.
2633 from_array_kwargs: dict, optional
2634 Additional keyword arguments passed on to the `ChunkManagerEntrypoint.from_array` method used to create
2635 chunked arrays, via whichever chunk manager is specified through the `chunked_array_type` kwarg.
2636 For example, with dask as the default chunked array type, this method would pass additional kwargs
2637 to :py:func:`dask.array.from_array`. Experimental API that should not be relied upon.
2638 **chunks_kwargs : {dim: chunks, ...}, optional
2639 The keyword arguments form of ``chunks``.
2640 One of chunks or chunks_kwargs must be provided
2641
2642 Returns
2643 -------
2644 chunked : xarray.DataTree
2645
2646 See Also
2647 --------
2648 Dataset.chunk

Callers

nothing calls this directly

Calls 6

_get_all_dimsMethod · 0.95
from_dictMethod · 0.95
either_dict_or_kwargsFunction · 0.90
typeFunction · 0.85
keysMethod · 0.80
itemsMethod · 0.80

Tested by

no test coverage detected