1010from xarray .core import utils
1111from xarray .core .parallelcompat import ChunkManagerEntrypoint
1212from xarray .core .pycompat import is_chunked_array , is_duck_dask_array
13+ from xarray .core .types import T_Chunks , T_NormalizedChunks
1314
1415T_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-
2017CHUNK_MANAGERS : dict [str , type ["ChunkManagerEntrypoint" ]] = {}
2118
2219if 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