Skip to content

typing for numpy 1.21 #5522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion xarray/core/accessor_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ def _re_compile(

if getattr(pat, "dtype", None) != np.object_:
pat = self._stringify(pat)
func = lambda x: re.compile(x, flags=flags)

def func(x):
return re.compile(x, flags=flags)

if isinstance(pat, np.ndarray):
# apply_ufunc doesn't work for numpy arrays with output object dtypes
func = np.vectorize(func)
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def broadcast_compat_data(
data = duck_array_ops.transpose(data, order)

if new_dims != reordered_dims:
key_parts = []
key_parts: List[Optional[slice]] = []
for dim in new_dims:
if dim in set_old_dims:
key_parts.append(SLICE_NONE)
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def format_array_flat(array, max_width: int):
(max_possibly_relevant < array.size) or (cum_len > max_width).any()
):
padding = " ... "
max_len = max(np.argmax(cum_len + len(padding) - 1 > max_width), 2) # type: ignore[type-var]
max_len = max(int(np.argmax(cum_len + len(padding) - 1 > max_width)), 2) # type: ignore[type-var]
count = min(array.size, max_len)
else:
count = array.size
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def __init__(
else:
dtype_ = array.dtype
else:
dtype_ = np.dtype(dtype)
dtype_ = np.dtype(dtype) # type: ignore[assignment]
self._dtype = dtype_

def to_pandas_index(self) -> pd.Index:
Expand Down