Skip to content

polyval returns objects with different dimension order #6600

Closed
@malmans2

Description

@malmans2

What is your issue?

I noticed that the dimension order of the object returned by the latest polyval (main, unreleased) is different compared to xarray<=2022.3.0.
For example, the following code returns different results.

import xarray as xr
import numpy as np

values = np.array(
    [
        "2021-04-01T05:25:19.000000000",
        "2021-04-01T05:25:29.000000000",
        "2021-04-01T05:25:39.000000000",
        "2021-04-01T05:25:49.000000000",
        "2021-04-01T05:25:59.000000000",
        "2021-04-01T05:26:09.000000000",
    ],
    dtype="datetime64[ns]",
)
azimuth_time = xr.DataArray(
    values, name="azimuth_time", coords={"azimuth_time": values - values[0]}
)

polyfit_coefficients = xr.DataArray(
    [
        [2.33333335e-43, 1.62499999e-43, 2.79166678e-43],
        [-1.15316667e-30, 1.49518518e-31, 9.08833333e-31],
        [-2.50272583e-18, -1.23851062e-18, -2.99098229e-18],
        [5.83965193e-06, -1.53321770e-07, -4.84640242e-06],
        [4.44739216e06, 1.45053974e06, 5.29960857e06],
    ],
    dims=("degree", "axis"),
    coords={"axis": [0, 1, 2], "degree": [4, 3, 2, 1, 0]},
)

ds_out = xr.polyval(azimuth_time.coords["azimuth_time"], polyfit_coefficients)
print(ds_out.dims)
xarray v2022.3.0
('azimuth_time', 'axis')

xarray v2022.3.1.dev103+gfc282d59
('axis', 'azimuth_time')

Is this the expected behaviour? If yes, is it worth mentioning this change in what's new/breaking changes?

cc: @headtr1ck

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue that has not been reviewed by xarray team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions