MCPcopy
hub / github.com/numpy/numpy / _block_slicing

Function _block_slicing

numpy/_core/shape_base.py:969–985  ·  view source on GitHub ↗
(arrays, list_ndim, result_ndim)

Source from the content-addressed store, hash-verified

967
968
969def _block_slicing(arrays, list_ndim, result_ndim):
970 shape, slices, arrays = _block_info_recursion(
971 arrays, list_ndim, result_ndim)
972 dtype = _nx.result_type(*[arr.dtype for arr in arrays])
973
974 # Test preferring F only in the case that all input arrays are F
975 F_order = all(arr.flags['F_CONTIGUOUS'] for arr in arrays)
976 C_order = all(arr.flags['C_CONTIGUOUS'] for arr in arrays)
977 order = 'F' if F_order and not C_order else 'C'
978 result = _nx.empty(shape=shape, dtype=dtype, order=order)
979 # Note: In a c implementation, the function
980 # PyArray_CreateMultiSortedStridePerm could be used for more advanced
981 # guessing of the desired order.
982
983 for the_slice, arr in zip(slices, arrays):
984 result[(Ellipsis,) + the_slice] = arr
985 return result
986
987
988def _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.85

Tested by 1

_block_force_slicingMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…