home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 949618104

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/5647#issuecomment-949618104 https://api.github.com/repos/pydata/xarray/issues/5647 949618104 IC_kwDOAMm_X844mgW4 4160723 2021-10-22T13:11:01Z 2021-10-22T13:11:01Z MEMBER

@shoyer I'm now reviewing the merging logic. I works mostly fine, with some minor concerns:

  • MergeElement (variable, index) tuples are not grouped per matching (unique) index, so index equality will be checked more than once for multi-coordinate indexes. Not a big deal I think, unless for large multi-indexes with many levels. A proper fix for this would probably require some heavier refactoring, though. Is it ok to leave this as is for now?

  • I'm not sure how we should handle the case where foo is the name of both an un-indexed dimension and a coordinate with other dimension(s).

Let's take this example:

```python

from xarray.tests.test_dataset import create_test_multiindex data = create_test_multiindex() data <xarray.Dataset> Dimensions: (x: 4) Coordinates: * x (x) MultiIndex - level_1 (x) object 'a' 'a' 'b' 'b' - level_2 (x) int64 1 2 1 2 Data variables: empty python other = xr.Dataset({"z": ("level_1", [0, 1])}) merged = data.merge(other) ValueError: conflicting level / dimension names. level_1 already exists as a level name. ```

Do we raise a ValueError here because otherwise we don't know what to return from merged["level_1"] (i.e., the multi-index virtual coordinate or a default dimension coordinate)? Can we allow this case now that multi-index level coordinates are not virtual anymore?

Note: the following example does not raise any error in xarray:

```python

data = xr.Dataset(coords={"x": [0, 1, 2, 3], "level_1": ("x", ["a", "a", "b", "b"])}) other = xr.Dataset({"z": ("level_1", [0, 1])}) merged = data.merge(other) merged <xarray.Dataset> Dimensions: (x: 4, level_1: 2) Coordinates: * x (x) int64 0 1 2 3 level_1 (x) <U1 'a' 'a' 'b' 'b' Data variables: z (level_1) int64 0 1 ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  955936490
Powered by Datasette · Queries took 83.862ms · About: xarray-datasette