From c34ef8a60227720724e90aa11a6266c0026a812a Mon Sep 17 00:00:00 2001 From: Mick <43316012+headtr1ck@users.noreply.github.com> Date: Thu, 12 May 2022 21:01:58 +0200 Subject: [PATCH] change polyval dim ordering (#6601) --- xarray/core/computation.py | 2 +- xarray/tests/test_computation.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/core/computation.py b/xarray/core/computation.py index 8d450cceef9..81b5e3fd915 100644 --- a/xarray/core/computation.py +++ b/xarray/core/computation.py @@ -1909,7 +1909,7 @@ def polyval( # using Horner's method # https://en.wikipedia.org/wiki/Horner%27s_method - res = coeffs.isel({degree_dim: max_deg}, drop=True) + zeros_like(coord) + res = zeros_like(coord) + coeffs.isel({degree_dim: max_deg}, drop=True) for deg in range(max_deg - 1, -1, -1): res *= coord res += coeffs.isel({degree_dim: deg}, drop=True) diff --git a/xarray/tests/test_computation.py b/xarray/tests/test_computation.py index b8aa05c75e7..ec8b5a5bc7c 100644 --- a/xarray/tests/test_computation.py +++ b/xarray/tests/test_computation.py @@ -1951,7 +1951,7 @@ def test_where_attrs() -> None: xr.DataArray( [[0, 1], [0, 1]], dims=("y", "degree"), coords={"degree": [0, 1]} ), - xr.DataArray([[1, 2, 3], [1, 2, 3]], dims=("y", "x")), + xr.DataArray([[1, 1], [2, 2], [3, 3]], dims=("x", "y")), id="broadcast-x", ), pytest.param(