home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 1615599224

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
1615599224 I_kwDOAMm_X85gTBZ4 7597 Interpolate_na: max_map argument not working at array boundaries 42680748 closed 0     6 2023-03-08T16:56:36Z 2023-03-16T18:55:58Z 2023-03-16T18:55:58Z CONTRIBUTOR      

What happened?

In the case of multidimensional arrays, the max_gap argument of interpolate_na is currently not working correctly at the array boundaries. This is likely due to a missing "dim" argument in the max() aggregation in xarray.core.missing._get_nan_block_lengths, I think.

What did you expect to happen?

In the following code example, due to max_gap=2, no extrapolation should be performed for the second row. Currently, this is the case, the output created is:

<xarray.DataArray (x: 2, y: 5)> array([[1., 2., 3., 4., 5.], [1., 2., 3., 4., 5.]]) Coordinates: * x (x) int64 0 1 * y (y) int64 0 1 2 3 4

Minimal Complete Verifiable Example

Python import xarray as xr import numpy as np da=xr.DataArray([[1, 2,3,4, np.nan],[1,2, np.nan, np.nan, np.nan]], coords=[('x', [0,1]), ('y', [0,1,2,3,4])]) da_interp=da.interpolate_na(dim='y', max_gap=2, fill_value='extrapolate') print(da_interp)

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.
  • [ ] 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

No response

Anything else we need to know?

I added the missing dim argument and adapted the test cases (Currently, there was no test case for fully multidimensional arrays with a gap at the end).

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.10.5 | packaged by conda-forge | (main, Jun 14 2022, 07:04:59) [GCC 10.3.0] python-bits: 64 OS: Linux OS-release: 5.4.0-135-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.2 libnetcdf: 4.9.0 xarray: 2023.2.0 pandas: 1.5.3 numpy: 1.23.5 scipy: 1.8.1 netCDF4: 1.6.1 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.5 dask: 2022.10.2 distributed: None matplotlib: 3.6.3 cartopy: None seaborn: None numbagg: 0.2.1 fsspec: 2022.10.0 cupy: None pint: 0.20.1 sparse: None flox: 0.6.8 numpy_groupies: 0.9.20 setuptools: 58.1.0 pip: 23.0.1 conda: None pytest: None mypy: None IPython: 8.6.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7597/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

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