issues: 1199122647
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1199122647 | I_kwDOAMm_X85HeSjX | 6466 | drop and other shouldn't be mutually exclusive in DataWithCoords.where | 3698640 | closed | 0 | 0 | 2022-04-10T17:42:07Z | 2022-04-12T15:33:05Z | 2022-04-12T15:33:05Z | CONTRIBUTOR | Is your feature request related to a problem?
```python In [2]: da = xr.DataArray(np.arange(16).reshape(4, 4), dims=['x', 'y']) In [3]: da
Out[3]:
<xarray.DataArray (x: 4, y: 4)>
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])
Dimensions without coordinates: x, y
ValueError Traceback (most recent call last) Input In [5], in <module> ----> 1 da.where(da > 6, -1, drop=True) File ~/miniconda3/envs/rhodium-env/lib/python3.10/site-packages/xarray/core/common.py:1268, in DataWithCoords.where(self, cond, other, drop)
1266 if drop:
1267 if other is not dtypes.NA:
-> 1268 raise ValueError("cannot set ValueError: cannot set Describe the solution you'd likeCurrent implementationThe current behavior is enforced within the block handling the
Proposed fixI just removed the above if statement on a fork, and the example now works! ```python
Describe alternatives you've consideredNo response Additional contextI haven't yet investigated what would happen with chunked, sparse, or other complex arrays, or if it's compatible with trees and other things on the roadmap. It's possible this breaks things I'm not imagining. Currently, I'm definitely open to creating a pull request (and have the simple implementation I've outlined here ready to go). |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/6466/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |