home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 207477701

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
207477701 MDU6SXNzdWUyMDc0Nzc3MDE= 1267 "in" operator does not work as expected on DataArray dimensions 5629061 closed 0   2856429 2 2017-02-14T10:35:41Z 2018-10-28T17:56:17Z 2018-10-28T17:56:17Z NONE      

As an example I have a DataArray called "my_dataarray" that looks something like this:

<xarray.DataArray 'values' (Type: 3)> array([1, 2, 3]) Coordinates: * Type (Type) object 'Type 1' 'Type 2' 'Type 3'

'Type' is a dimension on my DataArray. Note that 'Type' is also a DataArray that looks like this:

OrderedDict([('Type', <xarray.IndexVariable 'Type' (Type: 3)> array(['Type 1', 'Type 2', 'Type 3'], dtype='object'))])

Let's say I run:

'Type 1' in my_dataarray.Type

The result is False, even though 'Type 1' is in the "Type" dimension.

To get the result I was expecting I need to run:

'Type 1' in my_dataarray.Type.values

Stepping through the code, the problematic line is here: https://github.com/pydata/xarray/blob/20ec32430fac63a8976699d9528b5fdc1cd4125d/xarray/core/dataarray.py#L487

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?

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1267/reactions",
    "total_count": 1,
    "+1": 1,
    "-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
  • 2 rows from issue in issue_comments
Powered by Datasette · Queries took 0.674ms · About: xarray-datasette