@@ -1967,42 +1967,59 @@ def test_polyval_compat(use_dask, use_datetime) -> None:
1967
1967
1968
1968
1969
1969
@pytest .mark .parametrize (
1970
- ["coeffs" , "expected" ],
1970
+ ["x" , " coeffs" , "expected" ],
1971
1971
[
1972
1972
pytest .param (
1973
- xr .DataArray ([0 , 1 ], dims = "degree" ),
1974
1973
xr .DataArray ([1 , 2 , 3 ], dims = "x" ),
1974
+ xr .DataArray ([2 , 3 , 4 ], dims = "degree" ),
1975
+ xr .DataArray ([9 , 2 + 6 + 16 , 2 + 9 + 36 ], dims = "x" ),
1975
1976
id = "simple" ,
1976
1977
),
1977
1978
pytest .param (
1979
+ xr .DataArray ([1 , 2 , 3 ], dims = "x" ),
1978
1980
xr .DataArray ([[0 , 1 ], [0 , 1 ]], dims = ("y" , "degree" )),
1979
1981
xr .DataArray ([[1 , 1 ], [2 , 2 ], [3 , 3 ]], dims = ("x" , "y" )),
1980
1982
id = "broadcast-x" ,
1981
1983
),
1982
1984
pytest .param (
1985
+ xr .DataArray ([1 , 2 , 3 ], dims = "x" ),
1983
1986
xr .DataArray ([[0 , 1 ], [1 , 0 ], [1 , 1 ]], dims = ("x" , "degree" )),
1984
1987
xr .DataArray ([1 , 1 , 1 + 3 ], dims = "x" ),
1985
1988
id = "shared-dim" ,
1986
1989
),
1987
1990
pytest .param (
1991
+ xr .DataArray ([1 , 2 , 3 ], dims = "x" ),
1988
1992
xr .DataArray ([1 , 0 , 0 ], dims = "degree" , coords = {"degree" : [2 , 1 , 0 ]}),
1989
- xr .DataArray ([1 , 2 ** 2 , 3 ** 2 ], dims = "x" ),
1993
+ xr .DataArray ([1 , 2 ** 2 , 3 ** 2 ], dims = "x" ),
1990
1994
id = "reordered-index" ,
1991
1995
),
1992
1996
pytest .param (
1997
+ xr .DataArray ([1 , 2 , 3 ], dims = "x" ),
1993
1998
xr .DataArray ([5 ], dims = "degree" , coords = {"degree" : [3 ]}),
1994
- xr .DataArray ([5 , 5 * 2 ** 3 , 5 * 3 ** 3 ], dims = "x" ),
1999
+ xr .DataArray ([5 , 5 * 2 ** 3 , 5 * 3 ** 3 ], dims = "x" ),
1995
2000
id = "sparse-index" ,
1996
2001
),
1997
2002
pytest .param (
2003
+ xr .DataArray ([1 , 2 , 3 ], dims = "x" ),
1998
2004
xr .Dataset ({"a" : ("degree" , [0 , 1 ]), "b" : ("degree" , [1 , 0 ])}),
1999
2005
xr .Dataset ({"a" : ("x" , [1 , 2 , 3 ]), "b" : ("x" , [1 , 1 , 1 ])}),
2000
- id = "dataset" ,
2006
+ id = "array-dataset" ,
2007
+ ),
2008
+ pytest .param (
2009
+ xr .Dataset ({"a" : ("x" , [1 , 2 , 3 ]), "b" : ("x" , [2 , 3 , 4 ])}),
2010
+ xr .DataArray ([1 , 1 ], dims = "degree" ),
2011
+ xr .Dataset ({"a" : ("x" , [2 , 3 , 4 ]), "b" : ("x" , [3 , 4 , 5 ])}),
2012
+ id = "dataset-array" ,
2013
+ ),
2014
+ pytest .param (
2015
+ xr .Dataset ({"a" : ("x" , [1 , 2 , 3 ]), "b" : ("x" , [2 , 3 , 4 ])}),
2016
+ xr .Dataset ({"a" : ("degree" , [0 , 1 ]), "b" : ("degree" , [1 , 1 ])}),
2017
+ xr .Dataset ({"a" : ("x" , [1 , 2 , 3 ]), "b" : ("x" , [3 , 4 , 5 ])}),
2018
+ id = "dataset-dataset" ,
2001
2019
),
2002
2020
],
2003
2021
)
2004
- def test_polyval (coeffs , expected ) -> None :
2005
- x = xr .DataArray ([1 , 2 , 3 ], dims = "x" )
2022
+ def test_polyval (x , coeffs , expected ) -> None :
2006
2023
actual = xr .polyval (x , coeffs )
2007
2024
xr .testing .assert_allclose (actual , expected )
2008
2025
0 commit comments