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)
| 5806 | |
| 5807 | |
| 5808 | def _get_axis(indexes): |
| 5809 | """Get axis along which point-wise slicing results lie |
| 5810 | |
| 5811 | This is mostly a hack because I can't figure out NumPy's rule on this and |
| 5812 | can't be bothered to go reading. |
| 5813 | |
| 5814 | >>> _get_axis([[1, 2], None, [1, 2], None]) |
| 5815 | 0 |
| 5816 | >>> _get_axis([None, [1, 2], [1, 2], None]) |
| 5817 | 1 |
| 5818 | >>> _get_axis([None, None, [1, 2], [1, 2]]) |
| 5819 | 2 |
| 5820 | """ |
| 5821 | ndim = len(indexes) |
| 5822 | indexes = [slice(None, None) if i is None else [0] for i in indexes] |
| 5823 | x = np.empty((2,) * ndim) |
| 5824 | x2 = x[tuple(indexes)] |
| 5825 | return x2.shape.index(1) |
| 5826 | |
| 5827 | |
| 5828 | def _vindex_slice_and_transpose(block, points, axis): |