Skip to content

Commit

Permalink
Fix type annotations and ignore type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 committed Feb 7, 2024
1 parent 6b16862 commit a34d7a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion xarray/coding/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def lazy_elemwise_func(array, func: Callable, dtype: np.typing.DTypeLike):
if is_chunked_array(array):
chunkmanager = get_chunked_array_type(array)

return chunkmanager.map_blocks(func, array, dtype=dtype)
return chunkmanager.map_blocks(func, array, dtype=dtype) # type: ignore
else:
return _ElementwiseFunctionArray(array, func, dtype)

Expand Down
14 changes: 7 additions & 7 deletions xarray/namedarray/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Generic,
Literal,
TypeVar,
Union,
cast,
overload,
)
Expand Down Expand Up @@ -795,6 +796,8 @@ def chunk(
dask.array.from_array
"""

chunks = cast(Union[tuple[tuple[int, ...], ...], tuple[int, ...]], chunks)

if chunks is None:
warnings.warn(
"None value for 'chunks' is deprecated. "
Expand Down Expand Up @@ -828,7 +831,7 @@ def chunk(

data_old = self._data
if chunkmanager.is_chunked_array(data_old):
data_chunked = chunkmanager.rechunk(data_old, chunks)
data_chunked = chunkmanager.rechunk(data_old, chunks) # type: ignore
else:
if not isinstance(data_old, ExplicitlyIndexed):
ndata = data_old
Expand All @@ -846,11 +849,7 @@ def chunk(
if is_dict_like(chunks):
chunks = tuple(chunks.get(n, s) for n, s in enumerate(ndata.shape))

data_chunked = chunkmanager.from_array(
ndata,
chunks,
**_from_array_kwargs,
)
data_chunked = chunkmanager.from_array(ndata, chunks, **_from_array_kwargs) # type: ignore

return self._replace(data=data_chunked)

Expand All @@ -870,7 +869,8 @@ def to_numpy(self) -> np.ndarray[Any, Any]:
data = data.magnitude
if isinstance(data, array_type("sparse")):
data = data.todense()
data = np.asarray(data)
data = np.asarray(data) # type: ignore
data = cast(np.ndarray[Any, Any], data)

return data

Expand Down

0 comments on commit a34d7a7

Please sign in to comment.