-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
bool(Dataset(False)) is True #4290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If I remember correctly, In [2]: bool(xr.Dataset())
Out[2]: False
In [3]: bool(xr.Dataset({"x": False}))
Out[3]: True
In [4]: bool({})
Out[4]: False
In [5]: bool({"x": False})
Out[5]: True |
thanks for the explanation. but from a naive user perspective, bool(xr.DataArray(False).to_dataset(name='var')) # False
bool(xr.DataArray(True).to_dataset(name='var')) # True
bool(xr.DataArray(False)) # False
bool(xr.DataArray(True)) # True would be nice. |
I'm not sure if that's something we want to do: what happens if the dataset has more than one variable? I guess what we're talking about here is making Thoughts, @pydata/xarray? |
currently if (xrobject > 10).any():
raise ValueError('blabla') depends on whether xrobject is xr.DataArray or xr.Dataset. |
This question seems to me to be conceptually similar to the question I described in #3315: "Should we treat a named DataArray and a single-variable Dataset as if they are the same?" If the answer is yes, then we should definitely change the behaviour of Intuitively I personally think it should be the former, but I would first like to see how many tests break if we make that kind of change. |
We mirror numpy for For those who think IIUC, this is somewhat of an edge case — it's only possible to coerce
👍 |
👍 |
good point
I now understand the underlying problem better with your comments. My expectations were too naive about it. I cannot evaluate the consequences of changing this. I close this issue and hopefully users having this problem in the future will find this issue. |
Thanks for raising and engaging @aaronspring ! |
Uh oh!
There was an error while loading. Please reload this page.
What happened:
What you expected to happen:
Maybe this is intentional and I dont understand why.
xr.version = '0.16.0'
The text was updated successfully, but these errors were encountered: