Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Illviljan committed Oct 14, 2023
1 parent aecdff4 commit 1f52099
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions xarray/namedarray/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
TypeVar,
Union,
runtime_checkable,
overload,
)

import numpy as np
Expand Down Expand Up @@ -92,10 +93,13 @@ def shape(self) -> _Shape:
def dtype(self) -> _DType_co:
...

# def __array__(
# self, *, dtype: _DTypeLike[_ScalarType_co]
# ) -> NDArray[_ScalarType_co]:
# ...
@overload
def __array__(self, dtype: None = ..., /) -> np.ndarray[Any, _DType_co]:
...

@overload
def __array__(self, dtype: _DType, /) -> np.ndarray[Any, _DType]:
...


# Corresponds to np.typing.NDArray:
Expand Down
2 changes: 1 addition & 1 deletion xarray/namedarray/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def _nonzero(self: T_NamedArrayInteger) -> tuple[T_NamedArrayInteger, ...]:
nonzeros = np.nonzero(cast(NDArray[np.integer[Any]], self.data))
_attrs = self.attrs
return tuple(
(T_NamedArrayInteger, _new(self, (dim,), nz, _attrs))
cast(T_NamedArrayInteger, _new(self, (dim,), nz, _attrs))
for nz, dim in zip(nonzeros, self.dims)
)

Expand Down

0 comments on commit 1f52099

Please sign in to comment.