Skip to content

DOC: Add "auto" to dataarray chunk method #6068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import datetime
import sys
import warnings
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -88,6 +89,12 @@

from .types import T_DataArray, T_Xarray

# TODO: Remove this check once python 3.7 is not supported:
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


def _infer_coords_and_dims(
shape, coords, dims
Expand Down Expand Up @@ -1094,6 +1101,7 @@ def chunk(
self,
chunks: Union[
int,
Literal["auto"],
Tuple[int, ...],
Tuple[Tuple[int, ...], ...],
Mapping[Any, Union[None, int, Tuple[int, ...]]],
Expand All @@ -1114,9 +1122,9 @@ def chunk(

Parameters
----------
chunks : int, tuple of int or mapping of hashable to int, optional
Chunk sizes along each dimension, e.g., ``5``, ``(5, 5)`` or
``{'x': 5, 'y': 5}``.
chunks : int, "auto", tuple of int or mapping of hashable to int, optional
Chunk sizes along each dimension, e.g., ``5``, ``"auto"``, ``(5, 5)`` or
``{"x": 5, "y": 5}``.
name_prefix : str, optional
Prefix for the name of the new dask array.
token : str, optional
Expand Down
12 changes: 9 additions & 3 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@
broadcast_variables,
)

# TODO: Remove this check once python 3.7 is not supported:
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

if TYPE_CHECKING:
from ..backends import AbstractDataStore, ZarrStore
from .dataarray import DataArray
Expand Down Expand Up @@ -2131,7 +2137,7 @@ def chunk(
self,
chunks: Union[
int,
str,
Literal["auto"],
Mapping[Any, Union[None, int, str, Tuple[int, ...]]],
] = {}, # {} even though it's technically unsafe, is being used intentionally here (#4667)
name_prefix: str = "xarray-",
Expand All @@ -2150,8 +2156,8 @@ def chunk(

Parameters
----------
chunks : int, 'auto' or mapping, optional
Chunk sizes along each dimension, e.g., ``5`` or
chunks : int, "auto" or mapping of hashable to int, optional
Chunk sizes along each dimension, e.g., ``5``, ``"auto"``, or
``{"x": 5, "y": 5}``.
name_prefix : str, optional
Prefix for the name of any new dask arrays.
Expand Down