pdft.manifolds.unstack_tensors#
- pdft.manifolds.unstack_tensors(batch, indices, *, into)[source]#
Unpack a
(*tensor_shape, n)batch back into a Python list, in place.Mirror of upstream src/manifolds.jl:146-154.
intois a mutable list long enough to be indexed by each entry ofindices.The slice is taken on the LAST axis (
batch[..., k]), matchingstack_tensors’axis=-1stacking, so this works for any tensor rank — 2×2 matrices stacked to(2, 2, n)AND 2-qubit gates(2, 2, 2, 2)stacked to(2, 2, 2, 2, n). A hardcoded[:, :, k]here would slice a qubit axis of the 2-qubit gates instead of the stack axis (and JAX silently clamps out-of-range k), corrupting them.