Skip to content
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

Change np.core.defchararray to np.char (#9165) #9166

Merged
merged 8 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Deprecations

Bug fixes
~~~~~~~~~
- Make `testing.assert_allclose` work with numpy 2.0 (:issue:`9165`, :pull:`9166`).
keewis marked this conversation as resolved.
Show resolved Hide resolved
By `Pontus Lurcock <https://github.com/pont-us>`_
keewis marked this conversation as resolved.
Show resolved Hide resolved


Documentation
Expand Down
2 changes: 1 addition & 1 deletion xarray/testing/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def wrapper(*args, **kwargs):

def _decode_string_data(data):
if data.dtype.kind == "S":
return np.core.defchararray.decode(data, "utf-8", "replace")
return np.char.decode(data, "utf-8", "replace")
return data


Expand Down
5 changes: 5 additions & 0 deletions xarray/tests/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def test_allclose_regression() -> None:
xr.Dataset({"a": ("x", [0, 2]), "b": ("y", [0, 1])}),
id="Dataset",
),
pytest.param(
xr.DataArray(np.array("a", dtype="|S1")),
xr.DataArray(np.array("b", dtype="|S1")),
id="DataArray_dtypeS",
pont-us marked this conversation as resolved.
Show resolved Hide resolved
),
),
)
def test_assert_allclose(obj1, obj2) -> None:
Expand Down
Loading