MCPcopy Index your code
hub / github.com/pydata/xarray / _roll_one_dim

Method _roll_one_dim

xarray/core/variable.py:1346–1365  ·  view source on GitHub ↗
(self, dim, count)

Source from the content-addressed store, hash-verified

1344 return type(self)(self.dims, array, attrs=attrs)
1345
1346 def _roll_one_dim(self, dim, count):
1347 axis = self.get_axis_num(dim)
1348
1349 count %= self.shape[axis]
1350 if count != 0:
1351 indices = [slice(-count, None), slice(None, -count)]
1352 else:
1353 indices = [slice(None)]
1354
1355 arrays = [self[(slice(None),) * axis + (idx,)].data for idx in indices]
1356
1357 data = duck_array_ops.concatenate(arrays, axis)
1358
1359 if is_duck_dask_array(data):
1360 # chunked data should come out with the same chunks; this makes
1361 # it feasible to combine shifted and unshifted data
1362 # TODO: remove this once dask.array automatically aligns chunks
1363 data = data.rechunk(self.data.chunks)
1364
1365 return self._replace(data=data)
1366
1367 def roll(self, shifts=None, **shifts_kwargs):
1368 """

Callers 1

rollMethod · 0.80

Calls 4

_replaceMethod · 0.95
is_duck_dask_arrayFunction · 0.90
get_axis_numMethod · 0.45
rechunkMethod · 0.45

Tested by

no test coverage detected