MCPcopy Create free account
hub / github.com/dask/dask / _get_axis

Function _get_axis

dask/array/core.py:6008–6025  ·  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

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

Callers 2

_vindex_arrayFunction · 0.85

Calls 2

emptyMethod · 0.45
indexMethod · 0.45

Tested by 1