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
xarray now tries to roll all the coordinates, rather than the variable DataArrays and only the specified coordinate. This fails as the other coordinates do not have the specified coordinate and there is no check so we just get a ValueError
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/dataset.py in roll(self, shifts, roll_coords, **shifts_kwargs)
3574 for k, v in iteritems(self.variables):
3575 if k not in unrolled_vars:
-> 3576 variables[k] = v.roll(**shifts)
3577 else:
3578 variables[k] = v
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/variable.py in roll(self, shifts, **shifts_kwargs)
1093 result = self
1094 for dim, count in shifts.items():
-> 1095 result = result._roll_one_dim(dim, count)
1096 return result
1097
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/common.py in get_axis_num(self, dim)
128 """
129 if isinstance(dim, basestring):
--> 130 return self._get_axis_num(dim)
131 else:
132 return tuple(self._get_axis_num(d) for d in dim)
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/common.py in _get_axis_num(self, dim)
137 except ValueError:
138 raise ValueError("%r not found in array dimensions %r" %
--> 139 (dim, self.dims))
140
141 @Property
ValueError: 'x' not found in array dimensions ('y',)
The text was updated successfully, but these errors were encountered:
xarray now tries to roll all the coordinates, rather than the variable DataArrays and only the specified coordinate. This fails as the other coordinates do not have the specified coordinate and there is no check so we just get a
ValueError
xarray/xarray/core/dataset.py
Line 3571 in ab96954
This seems like a significant regression from 0.10.8, making roll on an nd dataset/array currently not possible, unless I'm missing something.
Code Sample
If we try it on 0.10.9 -->
we get
Full traceback nested below,
0.10.9
ValueError Traceback (most recent call last)
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/common.py in _get_axis_num(self, dim)
135 try:
--> 136 return self.dims.index(dim)
137 except ValueError:
ValueError: tuple.index(x): x not in tuple
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
in ()
2 print(xr.version)
3 arr = xr.DataArray([[1, 2, 3],[4, 5, 6]], coords={'x': range(3), 'y': range(2)}, dims=('y','x'))
----> 4 actual = arr.roll(x=1)
5 expected = xr.DataArray([[3, 1, 2],[6, 4, 5]], coords=[('y', [0, 1]), ('x', [2, 0, 1])])
6 actual == expected
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/dataarray.py in roll(self, shifts, roll_coords, **shifts_kwargs)
2159 """
2160 ds = self._to_temp_dataset().roll(
-> 2161 shifts=shifts, roll_coords=roll_coords, **shifts_kwargs)
2162 return self._from_temp_dataset(ds)
2163
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/dataset.py in roll(self, shifts, roll_coords, **shifts_kwargs)
3574 for k, v in iteritems(self.variables):
3575 if k not in unrolled_vars:
-> 3576 variables[k] = v.roll(**shifts)
3577 else:
3578 variables[k] = v
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/variable.py in roll(self, shifts, **shifts_kwargs)
1093 result = self
1094 for dim, count in shifts.items():
-> 1095 result = result._roll_one_dim(dim, count)
1096 return result
1097
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/variable.py in _roll_one_dim(self, dim, count)
1049
1050 def _roll_one_dim(self, dim, count):
-> 1051 axis = self.get_axis_num(dim)
1052
1053 count %= self.shape[axis]
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/common.py in get_axis_num(self, dim)
128 """
129 if isinstance(dim, basestring):
--> 130 return self._get_axis_num(dim)
131 else:
132 return tuple(self._get_axis_num(d) for d in dim)
~/conda/envs/daily/lib/python3.6/site-packages/xarray/core/common.py in _get_axis_num(self, dim)
137 except ValueError:
138 raise ValueError("%r not found in array dimensions %r" %
--> 139 (dim, self.dims))
140
141 @Property
ValueError: 'x' not found in array dimensions ('y',)
The text was updated successfully, but these errors were encountered: