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

Function _block

numpy/core/shape_base.py:673–689  ·  view source on GitHub ↗

Internal implementation of block based on repeated concatenation. `arrays` is the argument passed to block. `max_depth` is the depth of nested lists within `arrays` and `result_ndim` is the greatest of the dimensions of the arrays in `arrays` and the depth of the lists in `array

(arrays, max_depth, result_ndim, depth=0)

Source from the content-addressed store, hash-verified

671
672
673def _block(arrays, max_depth, result_ndim, depth=0):
674 """
675 Internal implementation of block based on repeated concatenation.
676 `arrays` is the argument passed to
677 block. `max_depth` is the depth of nested lists within `arrays` and
678 `result_ndim` is the greatest of the dimensions of the arrays in
679 `arrays` and the depth of the lists in `arrays` (see block docstring
680 for details).
681 """
682 if depth < max_depth:
683 arrs = [_block(arr, max_depth, result_ndim, depth+1)
684 for arr in arrays]
685 return _concatenate(arrs, axis=-(max_depth-depth))
686 else:
687 # We've 'bottomed out' - arrays is either a scalar or an array
688 # type(arrays) is not list
689 return _atleast_nd(arrays, result_ndim)
690
691
692def _block_dispatcher(arrays):

Callers 1

_block_concatenateFunction · 0.85

Calls 1

_atleast_ndFunction · 0.85

Tested by

no test coverage detected