home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 1199194614

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/6835#issuecomment-1199194614 https://api.github.com/repos/pydata/xarray/issues/6835 1199194614 IC_kwDOAMm_X85HekH2 4160723 2022-07-29T11:59:40Z 2022-07-29T11:59:40Z MEMBER

Thanks for the report @momchil-flex. That's definitely a regression.

However, I wonder what should we do: depreciate interpreting tuples as sequences and always consider them as "scalar" values or continue interpreting it differently depending on the cases?

For example, tuples indexer values were (and still are) assumed to be single element values when selecting on a dimension coordinate with a multi-index (although eventually the multi-index dimension coordinate might be depreciated in xarray):

```python da = xr.DataArray( data=range(3), dims="x", coords={"a": ("x", ["a", "a", "c"]), "b": ("x", [0, 1, 2])}, ).set_index(x=["a", "b"])

da

<xarray.DataArray (x: 3)>

array([0, 1, 2])

Coordinates:

* x (x) object MultiIndex

* a (x) <U1 'a' 'a' 'c'

* b (x) int64 0 1 2

da.sel(x=("a", 1))

<xarray.DataArray ()>

array(1)

Coordinates:

x object ('a', 1)

a <U1 'a'

b int64 1

```

Pros of always treating a tuple as 1-element indexer value:

  • Clearer
  • Less special cases to maintain internally in Xarray

Cons:

  • With flexible indexes, Xarray currently just passes the indexers to the corresponding (custom) indexes, leaving the responsibility to those indexes to process them as they want. Although we might have some control on the behavior of PandasIndex and PandasMultiIndex built-in Xarray, we have no control on 3rd party indexes. Unless we somehow formalize the semantics of the indexer values passed in .sel(), but this could be challenging as there could be many kinds of indexers (scalar types, tuples, lists, slices, numpy arrays, xarray Variable or DataArray objects, etc.).
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1318826485
Powered by Datasette · Queries took 0.704ms · About: xarray-datasette