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
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:
arr=xr.DataArray(range(2), name='arrname')
ds=arr.to_dataset()
ds.rename({'dim_0':'dim_0'})
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
<ipython-input-15-a5b851f9fb10>in<module>()
---->1ds.rename({'dim_0':'dim_0'})
/Users/spencerahill/anaconda/lib/python2.7/site-packages/xarray/core/dataset.pycinrename(self, name_dict, inplace)
1245"variable in this dataset"%k)
1246ifvinself:
->1247raiseValueError('the new name %r already exists'%v)
12481249variables=OrderedDict()
ValueError: thenewname'dim_0'alreadyexists
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!
The text was updated successfully, but these errors were encountered:
Before #648, passing
Dataset.rename
aname_dict
whose keys and values were identical did not raise an exception. Now, however, it raises a ValueError: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 withif 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-renamerename
. Thanks!The text was updated successfully, but these errors were encountered: