MCPcopy Create free account
hub / github.com/numpy/numpy / _block_slicing

Function _block_slicing

numpy/core/shape_base.py:896–912  ·  view source on GitHub ↗
(arrays, list_ndim, result_ndim)

Source from the content-addressed store, hash-verified

894
895
896def _block_slicing(arrays, list_ndim, result_ndim):
897 shape, slices, arrays = _block_info_recursion(
898 arrays, list_ndim, result_ndim)
899 dtype = _nx.result_type(*[arr.dtype for arr in arrays])
900
901 # Test preferring F only in the case that all input arrays are F
902 F_order = all(arr.flags['F_CONTIGUOUS'] for arr in arrays)
903 C_order = all(arr.flags['C_CONTIGUOUS'] for arr in arrays)
904 order = 'F' if F_order and not C_order else 'C'
905 result = _nx.empty(shape=shape, dtype=dtype, order=order)
906 # Note: In a c implementation, the function
907 # PyArray_CreateMultiSortedStridePerm could be used for more advanced
908 # guessing of the desired order.
909
910 for the_slice, arr in zip(slices, arrays):
911 result[(Ellipsis,) + the_slice] = arr
912 return result
913
914
915def _block_concatenate(arrays, list_ndim, result_ndim):

Callers 2

_block_force_slicingMethod · 0.90
blockFunction · 0.85

Calls 2

_block_info_recursionFunction · 0.85
allFunction · 0.70

Tested by 1

_block_force_slicingMethod · 0.72