home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 751732952

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
751732952 MDU6SXNzdWU3NTE3MzI5NTI= 4612 Assigning nan to int-dtype array converts nan to int 500246 open 0     1 2020-11-26T17:00:45Z 2021-01-02T03:55:30Z   CONTRIBUTOR      

(I am almost sure this already exists as an issue, but I can't find the original)

What happened:

When assigning nan to a integer-dtype array, the nan gets incorrectly inverted to int.

What you expected to happen:

I expect to get a ValueError, like I get for pure numpy arrays.

Minimal Complete Verifiable Example:

python import xarray import numpy da = xarray.DataArray(numpy.array([0,1], dtype="u8")) da[0] = numpy.nan print(da)

Gives:

<xarray.DataArray (dim_0: 2)> array([9223372036854775808, 1], dtype=uint64) Dimensions without coordinates: dim_0

Anything else we need to know?:

In numpy the equivalent code raises ValueError

This is related but different from #2945. In #2945, xarray behaves the same as numpy. In #4612, xarray behaves differently from numpy.

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 19:08:05) [GCC 7.5.0] python-bits: 64 OS: Linux OS-release: 4.12.14-lp150.12.82-default machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 libhdf5: 1.10.6 libnetcdf: 4.7.4 xarray: 0.16.1 pandas: 1.1.4 numpy: 1.19.4 scipy: 1.5.3 netCDF4: 1.5.4 pydap: None h5netcdf: 0.8.1 h5py: 3.1.0 Nio: None zarr: 2.5.0 cftime: 1.2.1 nc_time_axis: None PseudoNetCDF: None rasterio: 1.1.7 cfgrib: None iris: None bottleneck: None dask: 2.30.0 distributed: 2.30.1 matplotlib: 3.3.2 cartopy: 0.18.0 seaborn: None numbagg: None pint: None setuptools: 49.6.0.post20201009 pip: 20.2.4 conda: installed pytest: 6.1.2 IPython: 7.19.0 sphinx: 3.3.0
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4612/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

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