Skip to content

Commit

Permalink
remove normalize_chunks method from ChunkManagerEntrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNicholas committed Jul 31, 2024
1 parent def3131 commit 8db961e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 71 deletions.
19 changes: 0 additions & 19 deletions xarray/namedarray/daskmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,6 @@ def __init__(self) -> None:
def is_chunked_array(self, data: duckarray[Any, Any]) -> bool:
return is_duck_dask_array(data)

def normalize_chunks(
self,
chunks: T_Chunks | _NormalizedChunks,
shape: tuple[int, ...] | None = None,
limit: int | None = None,
dtype: _DType_co | None = None,
previous_chunks: _NormalizedChunks | None = None,
) -> Any:
"""Called by open_dataset"""
from dask.array.core import normalize_chunks

return normalize_chunks(
chunks,
shape=shape,
limit=limit,
dtype=dtype,
previous_chunks=previous_chunks,
) # type: ignore[no-untyped-call]

def from_array(
self, data: Any, chunks: T_Chunks | _NormalizedChunks, **kwargs: Any
) -> DaskArray | Any:
Expand Down
39 changes: 0 additions & 39 deletions xarray/namedarray/parallelcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
if TYPE_CHECKING:
from xarray.namedarray._typing import (
_Chunks,
_DType,
_DType_co,
_NormalizedChunks,
_ShapeType,
duckarray,
)

Expand Down Expand Up @@ -218,43 +216,6 @@ def is_chunked_array(self, data: duckarray[Any, Any]) -> bool:
"""
return isinstance(data, self.array_cls)

@abstractmethod
def normalize_chunks(
self,
chunks: _Chunks | _NormalizedChunks,
shape: _ShapeType | None = None,
limit: int | None = None,
dtype: _DType | None = None,
previous_chunks: _NormalizedChunks | None = None,
) -> _NormalizedChunks:
"""
Normalize given chunking pattern into an explicit tuple of tuples representation.
Exposed primarily because different chunking backends may want to make different decisions about how to
automatically chunk along dimensions not given explicitly in the input chunks.
Called internally by xarray.open_dataset.
Parameters
----------
chunks : tuple, int, dict, or string
The chunks to be normalized.
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 dimensions automatically.
See Also
--------
dask.array.core.normalize_chunks
"""
raise NotImplementedError()

@abstractmethod
def from_array(
self, data: duckarray[Any, Any], chunks: _Chunks, **kwargs: Any
Expand Down
14 changes: 1 addition & 13 deletions xarray/tests/test_parallelcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import pytest

from xarray.core.types import T_Chunks, T_DuckArray, T_NormalizedChunks
from xarray.core.types import T_DuckArray, T_NormalizedChunks
from xarray.namedarray._typing import _Chunks
from xarray.namedarray.core import NamedArray
from xarray.namedarray.daskmanager import DaskManager
Expand Down Expand Up @@ -79,18 +79,6 @@ def __init__(self):
def is_chunked_array(self, data: Any) -> bool:
return isinstance(data, DummyChunkedArray)

def normalize_chunks(
self,
chunks: T_Chunks | T_NormalizedChunks,
shape: tuple[int, ...] | None = None,
limit: int | None = None,
dtype: np.dtype | None = None,
previous_chunks: T_NormalizedChunks | None = None,
) -> T_NormalizedChunks:
from dask.array.core import normalize_chunks

return normalize_chunks(chunks, shape, limit, dtype, previous_chunks)

def from_array(
self, data: T_DuckArray | np.typing.ArrayLike, chunks: _Chunks, **kwargs
) -> DummyChunkedArray:
Expand Down

0 comments on commit 8db961e

Please sign in to comment.