pydata / pydata/xarray

converting int vars to floats when I where the enclosing ds?

Open
#2,183 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-documentation
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

Code Sample
test_ds = xr.Dataset()

test_ds['var1'] = xr.DataArray(np.arange(5))
test_ds['var2'] = xr.DataArray(np.ones(5))

assert(test_ds['var1'].dtype == np.int64)

assert(test_ds.where(test_ds['var2'] == 1)['var1'].dtype == np.int64)
Problem description

Second assert fails, which is a bit strange I think. Is that intended? If so, whats the reasoning?

Output of xr.show_versions()
commit: None python: 2.7.14.final.0 python-bits: 64 OS: Linux OS-release: 4.9.87-linuxkit-aufs machine: x86_64 processor: x86_64 byteorder: little LC_ALL: en_US.UTF-8 LANG: None LOCALE: None.None

xarray: 0.10.3
pandas: 0.22.0
numpy: 1.14.3
scipy: 1.1.0
netCDF4: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
bottleneck: 1.2.1
cyordereddict: None
dask: None
distributed: None
matplotlib: 2.2.2
cartopy: None
seaborn: 0.8.1
setuptools: 39.1.0
pip: 10.0.1
conda: None
pytest: 3.5.1
IPython: 5.6.0
sphinx: None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Dataset.where reproducer against the current test suite and trace the Dataset.where implementation. Determine whether the dtype change is expected, then add a regression test documenting the intended dtype behavior and update the implementation or documentation accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.