home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 441192361

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
441192361 MDU6SXNzdWU0NDExOTIzNjE= 2945 Implicit conversion from int to float tampers with values when int is not representable as float 14000880 closed 0     1 2019-05-07T11:57:20Z 2022-04-09T02:14:28Z 2022-04-09T02:14:28Z NONE      

```python ds = xr.Dataset() val = 95042027804193144 ds['var1'] = xr.DataArray(val) ds_1 = ds.where(ds.var1==val)

print(ds_1.var1.dtype) dtype('float64') print(int(ds_1.var1)) 95042027804193152 ```

Problem description

As described in #2183, int values are converted to float in where(), also when there are no NaNs in the data. This is a serious issue for the case when the int64 number is not representable as float64, as is the case in the example above. The resulting numbers are then actually different from the original numbers, without any warning.

Expected Output

I guess this is hard to fix. At a minimum, where() should probably not cast to float when there are no NaNs (which would already fix our use case). I would also rather expect an error instead of silently changing the values of a variable.

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] python-bits: 64 OS: Linux OS-release: 4.19.0-0.bpo.2-amd64 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.8.18 libnetcdf: 4.4.1.1 xarray: 0.12.1 pandas: 0.24.2 numpy: 1.15.4 scipy: 1.2.1 netCDF4: 1.2.8 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nc_time_axis: None PseudonetCDF: None rasterio: 0.36.0 cfgrib: 0.9.6.post1 iris: None bottleneck: 1.2.1 dask: 1.1.4 distributed: None matplotlib: 3.0.3 cartopy: 0.16.0 seaborn: 0.8.1 setuptools: 39.2.0 pip: 19.0.3 conda: None pytest: 4.4.1 IPython: 7.5.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2945/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

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