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

Function _get_axis

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

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

Callers 2

_vindex_arrayFunction · 0.85

Calls 2

emptyMethod · 0.45
indexMethod · 0.45

Tested by 1