home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 128718628

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
128718628 MDU6SXNzdWUxMjg3MTg2Mjg= 724 Behavior of ds.rename when old and new name are the same 6200806 closed 0     2 2016-01-26T04:12:24Z 2016-02-02T01:33:03Z 2016-02-02T01:33:03Z CONTRIBUTOR      

Before #648, passing Dataset.rename a name_dict whose keys and values were identical did not raise an exception. Now, however, it raises a ValueError:

``` python arr = xr.DataArray(range(2), name='arrname') ds = arr.to_dataset() ds.rename({'dim_0':'dim_0'})


ValueError Traceback (most recent call last) <ipython-input-15-a5b851f9fb10> in <module>() ----> 1 ds.rename({'dim_0':'dim_0'})

/Users/spencerahill/anaconda/lib/python2.7/site-packages/xarray/core/dataset.pyc in rename(self, name_dict, inplace) 1245 "variable in this dataset" % k) 1246 if v in self: -> 1247 raise ValueError('the new name %r already exists' % v) 1248 1249 variables = OrderedDict()

ValueError: the new name 'dim_0' already exists ```

This is easy enough to handle with a try/except clause in my own code, but it would be nice (for me at least) for rename to not raise anything for these cases. Since the result is simply the original Dataset unchanged, this could be implemented by replacing line 1246 with if v in self and k != v:

The use case is that we have data coming from multiple sources, often with differing internal names for coordinates and variables, and we're programmatically forcing them to have consistent names via rename. Sometimes, a piece of data already has the name that we are after, hence the non-rename rename. Thanks!

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/724/reactions",
    "total_count": 0,
    "+1": 0,
    "-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.578ms · About: xarray-datasette