Skip to content

dq.stack

stack(qarrays: Sequence[QArray], axis: int = 0) -> QArray

Join a sequence of qarrays along a new axis.

Warning

All elements of the sequence qarrays must have identical types, shapes and dims attributes. Additionally, when stacking qarrays of type SparseDIAQArray, all elements must have identical offsets attributes.

Parameters

  • qarrays –

    Qarrays to stack.

  • axis –

    Axis in the result along which the input qarrays are stacked.

Returns

Stacked qarray.

Examples

>>> dq.stack([dq.fock(3, 0), dq.fock(3, 1)])
QArray: shape=(2, 3, 1), dims=(3,), dtype=complex64, layout=dense
[[[1.+0.j]
  [0.+0.j]
  [0.+0.j]]

 [[0.+0.j]
  [1.+0.j]
  [0.+0.j]]]