From a24b59ab513ea1e75bc4dbd8b0ad169ce87a6694 Mon Sep 17 00:00:00 2001 From: Astral Cai Date: Wed, 10 Apr 2024 17:05:03 -0400 Subject: [PATCH] Fixes bug with dimensions, hopefully doesn't break anything else --- pennylane/transforms/hamiltonian_expand.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pennylane/transforms/hamiltonian_expand.py b/pennylane/transforms/hamiltonian_expand.py index 730532650e7..090b8f411de 100644 --- a/pennylane/transforms/hamiltonian_expand.py +++ b/pennylane/transforms/hamiltonian_expand.py @@ -42,10 +42,9 @@ def grouping_processing_fn(res_groupings, coeff_groupings, batch_size, offset): # pylint: disable=no-member if isinstance(r_group, (tuple, list, qml.numpy.builtins.SequenceBox)): r_group = qml.math.stack(r_group, axis=-1) + r_group = qml.math.transpose(r_group) if qml.math.shape(r_group) == (): r_group = qml.math.reshape(r_group, (1,)) - if batch_size: - r_group = r_group.T if len(c_group) == 1 and len(r_group) != 1: dot_products.append(r_group * c_group)