MCPcopy
hub / github.com/dask/dask / _get_axis

Function _get_axis

dask/array/core.py:6011–6028  ·  view source on GitHub ↗

Get axis along which point-wise slicing results lie This is mostly a hack because I can't figure out NumPy's rule on this and can't be bothered to go reading. >>> _get_axis([[1, 2], None, [1, 2], None]) 0 >>> _get_axis([None, [1, 2], [1, 2], None]) 1 >>> _get_axis([None

(indexes)

Source from the content-addressed store, hash-verified

6009
6010
6011def _get_axis(indexes):
6012 """Get axis along which point-wise slicing results lie
6013
6014 This is mostly a hack because I can't figure out NumPy's rule on this and
6015 can't be bothered to go reading.
6016
6017 >>> _get_axis([[1, 2], None, [1, 2], None])
6018 0
6019 >>> _get_axis([None, [1, 2], [1, 2], None])
6020 1
6021 >>> _get_axis([None, None, [1, 2], [1, 2]])
6022 2
6023 """
6024 ndim = len(indexes)
6025 indexes = [slice(None, None) if i is None else [0] for i in indexes]
6026 x = np.empty((2,) * ndim)
6027 x2 = x[tuple(indexes)]
6028 return x2.shape.index(1)
6029
6030
6031def _vindex_slice_and_transpose(block, points, axis):

Callers 2

_vindex_arrayFunction · 0.85

Calls 2

emptyMethod · 0.45
indexMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…