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)
| 6009 | |
| 6010 | |
| 6011 | def _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 | |
| 6031 | def _vindex_slice_and_transpose(block, points, axis): |
searching dependent graphs…