You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The test used for __contains__(self, key) on the Type dimension is whether the key is in the _coords of Type.
This is probably the right thing to do when the DataArray is used for storing data, but probably not what we want if the DataArray is being used as a dimension - it should instead check if 'Type 1' is in the values of Type?
The text was updated successfully, but these errors were encountered:
I agree, this is strange. my_dataarray['Type'] is really just a convenient shortcut for my_dataarray.coords['Type'], but DataArray is meant to be primarily array-like so in should look at the values (we have Dataset for the dict-like container).
I would be in favor of changing this to look at values like in on NumPy arrays in the next major release (0.10.0). That's probably a little ways off though, so let's hold off on the pull request for now :).
As an example I have a DataArray called "my_dataarray" that looks something like this:
'Type' is a dimension on my DataArray. Note that 'Type' is also a DataArray that looks like this:
Let's say I run:
The result is False, even though 'Type 1' is in the "Type" dimension.
To get the result I was expecting I need to run:
Stepping through the code, the problematic line is here:
xarray/xarray/core/dataarray.py
Line 487 in 20ec324
The test used for
__contains__(self, key)
on the Type dimension is whether the key is in the_coords
of Type.This is probably the right thing to do when the DataArray is used for storing data, but probably not what we want if the DataArray is being used as a dimension - it should instead check if 'Type 1' is in the values of Type?
The text was updated successfully, but these errors were encountered: