home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 1861738444

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1861738444 I_kwDOAMm_X85u99_M 8099 inconsistent dimension propagation in `.interp()` with non-numeric types 28786187 open 0     0 2023-08-22T15:46:13Z 2023-08-22T15:55:44Z   CONTRIBUTOR      

What happened?

Hi, tried to find a similar issue, but haven't seen it. When interpolating a dataset containing non-numeric types using a DataArray for the new coordinates, then the dimensions of the interpolated data set differ from the case with only numeric types. Not sure this is clear enough, see the example.

Edit: looks like nothing is interpolated at all in the non-numeric case.

What did you expect to happen?

The output dimensions should be the same in both cases and match the ones of the numeric-only case.

Minimal Complete Verifiable Example

```Python import xarray as xr import numpy as np

ds = xr.Dataset( {"x": ("a", np.arange(4))}, coords={"a": (np.arange(4) - 1.5)}, )

t = xr.DataArray( np.random.randn(6).reshape((2, 3)) * 0.5, dims=["r", "s"], coords={"r": np.arange(2) - 0.5, "s": np.arange(3) - 1}, )

ds["m"] = ds.x > 1

different dimensions for x, compare

ds.interp(a=t, method="linear")

to numeric only

ds[["x"]].interp(a=t, method="linear") ```

MVCE confirmation

  • [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [X] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [X] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [X] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

```Python

Output in the numeric-only case:

<xarray.Dataset> Dimensions: (r: 2, s: 3) Coordinates: a (r, s) float64 -0.177 -0.2806 -0.1925 -0.1464 0.3165 0.6232 * r (r) float64 -0.5 0.5 * s (s) int64 -1 0 1 Data variables: x (r, s) float64 1.323 1.219 1.308 1.354 1.816 2.123

output including non-numeric variables:

<xarray.Dataset> Dimensions: (a: 4, r: 2, s: 3) Coordinates: * a (r, s) float64 -0.177 -0.2806 -0.1925 -0.1464 0.3165 0.6232 * r (r) float64 -0.5 0.5 * s (s) int64 -1 0 1 Data variables: x (a) int64 0 1 2 3 m (a) bool False False True True ```

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:17) [GCC 12.2.0] python-bits: 64 OS: Linux machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: C.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.2 libnetcdf: 4.9.1 xarray: 2023.7.0 pandas: 2.0.3 numpy: 1.25.2 scipy: 1.11.1 netCDF4: 1.6.3 pydap: installed h5netcdf: 1.2.0 h5py: 3.8.0 Nio: None zarr: 2.16.0 cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None iris: None bottleneck: None dask: 2023.8.0 distributed: 2023.8.0 matplotlib: 3.7.2 cartopy: 0.22.0 seaborn: None numbagg: None fsspec: 2023.6.0 cupy: None pint: None sparse: None flox: 0.7.2 numpy_groupies: 0.9.22 setuptools: 68.0.0 pip: 23.2.1 conda: 23.7.2 pytest: 7.4.0 mypy: None IPython: 8.7.0 sphinx: 5.3.0
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/8099/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 6.553ms · About: xarray-datasette