Skip to content

ENH: Possible improvements to np.block #8899

@eric-wieser

Description

@eric-wieser

Pulled out from discussions in #8886:

  • Preallocate the result array (MAINT: Block algorithm with a single copy per call to block #11971)
  • Alias np.b_[...] to np.block([...])- shorthands are useful for nesting calls
  • Implement block destructuring, np.b_[...] = somearr (comes cheap after preallocation)
  • Add a np.block(arr : ndarray[object]) overload, that takes an ndarray of blocks that align in all axes (ie, such that the concatenation order does not matter)
  • Allow broadcasting
    • Extra leading dimensions: With two stacks of arrays, A.shape == (3, 1, 2, 2), B.shape = (1, 4, 2, 2), should np.block([A, B]).shape == (3,4,2,4)? (currently: ValueError)
    • All dimensions
  • Deprecate bmat in favor of np.block(...).view(np.matrix)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions