home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1521368478

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
1521368478 I_kwDOAMm_X85arj2e 7423 unstacking an integer array yields a RuntimeWarning after upgrade to numpy 1.24.1 3383837 closed 0     9 2023-01-05T20:29:45Z 2023-12-11T14:27:09Z 2023-11-06T06:05:16Z CONTRIBUTOR      

What happened?

After upgrading numpy from 1.23.5 to 1.24.1, calling the unstack method on an xarray.DataArray with integer data produces the warning <__array_function__ internals>:200: RuntimeWarning: invalid value encountered in cast. I think this relates to "ongoing work to improve the handling and promotion of dtypes" (Numpy 1.24.0 Release Notes), and is catching the fact that the method attempts to provide nan as a fill value on an integer array.

What did you expect to happen?

In the case below, where there is no need for a fill value, I do not expect to get a warning.

Minimal Complete Verifiable Example

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

np.seterr(all='raise') # uncomment to convert warning to error

da = xr.DataArray( data=np.array([[0]], dtype=int), coords={'x': [0], 'y': [1]}, ) da = da.stack({'z': ['x', 'y']}) da.unstack() ```

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 <__array_function__ internals>:200: RuntimeWarning: invalid value encountered in cast <xarray.DataArray (x: 1, y: 1)> array([[0]]) Coordinates: * x (x) int64 0 * y (y) int64 1

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.10.9 (main, Dec 15 2022, 18:18:30) [Clang 14.0.0 (clang-1400.0.29.202)] python-bits: 64 OS: Darwin OS-release: 21.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: None LOCALE: (None, 'UTF-8') libhdf5: 1.12.2 libnetcdf: 4.9.0 xarray: 2022.12.0 pandas: 1.5.2 numpy: 1.24.1 scipy: 1.10.0 netCDF4: 1.6.2 pydap: None h5netcdf: 1.1.0 h5py: 3.7.0 Nio: None zarr: None cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2022.12.1 distributed: None matplotlib: 3.6.2 cartopy: 0.21.1 seaborn: None numbagg: None fsspec: 2022.11.0 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 65.6.3 pip: 22.1.2 conda: None pytest: None mypy: None IPython: 8.8.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7423/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
  • 2 rows from issue in issue_comments
Powered by Datasette · Queries took 0.994ms · About: xarray-datasette