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

- Fix :py:meth:`xr.polyval` with non-system standard integer coeffs (:pull:`7619`).
By `Shreyal Gupta <https://github.com/Ravenin7>`_ and `Michael Niklas <https://github.com/headtr1ck>`_.

Documentation
~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ def polyval(
raise ValueError(
f"Dimension `{degree_dim}` should be a coordinate variable with labels."
)
if not np.issubdtype(coeffs[degree_dim].dtype, int):
if not np.issubdtype(coeffs[degree_dim].dtype, np.integer):
raise ValueError(
f"Dimension `{degree_dim}` should be of integer dtype. Received {coeffs[degree_dim].dtype} instead."
)
Expand Down
30 changes: 30 additions & 0 deletions xarray/tests/test_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,36 @@ def test_where_attrs() -> None:
xr.DataArray([1000.0, 2000.0, 3000.0], dims="x"),
id="timedelta",
),
pytest.param(
xr.DataArray([1, 2, 3], dims="x"),
xr.DataArray(
[2, 3, 4],
dims="degree",
coords={"degree": np.array([0, 1, 2], dtype=np.int64)},
),
xr.DataArray([9, 2 + 6 + 16, 2 + 9 + 36], dims="x"),
id="int64-degree",
),
pytest.param(
xr.DataArray([1, 2, 3], dims="x"),
xr.DataArray(
[2, 3, 4],
dims="degree",
coords={"degree": np.array([0, 1, 2], dtype=np.int32)},
),
xr.DataArray([9, 2 + 6 + 16, 2 + 9 + 36], dims="x"),
id="int32-degree",
),
pytest.param(
xr.DataArray([1, 2, 3], dims="x"),
xr.DataArray(
[2, 3, 4],
dims="degree",
coords={"degree": np.array([0, 1, 2], dtype=np.uint8)},
),
xr.DataArray([9, 2 + 6 + 16, 2 + 9 + 36], dims="x"),
id="uint8-degree",
),
],
)
def test_polyval(
Expand Down