10000 drop the length from `numpy`'s fixed-width string dtypes by keewis · Pull Request #9586 · pydata/xarray · GitHub
[go: up one dir, main page]

Skip to content

drop the length from numpy's fixed-width string dtypes #9586

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 8 commits into from
Oct 24, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
compatibility with numpy<2
  • Loading branch information
keewis committed Oct 10, 2024
commit 4d8dcb05ce8bd03de99f18b9108a1f8e906a9851
5 changes: 3 additions & 2 deletions xarray/core/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ def isdtype(dtype, kind: str | tuple[str, ...], xp=None) -> bool:
def preprocess_types(t):
if isinstance(t, str | bytes):
return type(t)
elif isinstance(
dtype := getattr(t, "dtype", t), np.dtypes.StrDType | np.dtypes.BytesDType
elif isinstance(dtype := getattr(t, "dtype", t), np.dtype) and dtype.type in (
np.str_,
np.bytes_,
):
# drop the length from numpy's fixed-width string dtypes, it is better to recalculate that
return dtype.type
Expand Down
Loading
0