Skip to content

Commit 99fa8be

Browse files
authored
Merge pull request #3 from TomNicholas/remove_indexing_adapter
Update some typing
2 parents f194cdf + 004dda9 commit 99fa8be

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

cubed_xarray/cubedmanager.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010
from xarray.core import utils
1111
from xarray.core.parallelcompat import ChunkManagerEntrypoint
1212
from xarray.core.pycompat import is_chunked_array, is_duck_dask_array
13+
from xarray.core.types import T_Chunks, T_NormalizedChunks
1314

1415
T_ChunkedArray = TypeVar("T_ChunkedArray")
1516

16-
# TODO importing TypeAlias is a pain on python 3.9 without typing_extensions in the CI
17-
# T_Chunks: TypeAlias = tuple[tuple[int, ...], ...]
18-
T_Chunks = Any
19-
2017
CHUNK_MANAGERS: dict[str, type["ChunkManagerEntrypoint"]] = {}
2118

2219
if TYPE_CHECKING:
@@ -31,9 +28,21 @@ def __init__(self):
3128

3229
self.array_cls = Array
3330

34-
def chunks(self, data: "CubedArray") -> T_Chunks:
31+
def chunks(self, data: "CubedArray") -> T_NormalizedChunks:
3532
return data.chunks
3633

34+
def normalize_chunks(
35+
self,
36+
chunks: T_Chunks,
37+
shape: Union[tuple[int], None] = None,
38+
limit: Union[int, None] = None,
39+
dtype: Union[np.dtype, None] = None,
40+
previous_chunks: T_NormalizedChunks = None,
41+
) -> tuple[tuple[int, ...], ...]:
42+
from cubed.vendor.dask.array.core import normalize_chunks
43+
44+
return normalize_chunks(chunks, shape=shape, limit=limit, dtype=dtype, previous_chunks=previous_chunks)
45+
3746
def from_array(self, data: np.ndarray, chunks, **kwargs) -> "CubedArray":
3847
from cubed import from_array
3948

@@ -148,7 +157,6 @@ def apply_gufunc(
148157
output_sizes=None,
149158
vectorize=None,
150159
allow_rechunk=False,
151-
meta=None,
152160
**kwargs,
153161
):
154162
if allow_rechunk:

0 commit comments

Comments
 (0)