diff --git a/pennylane_lightning/lightning_tensor/_tensornet.py b/pennylane_lightning/lightning_tensor/_tensornet.py index bf7f9c6b7..05849ad4b 100644 --- a/pennylane_lightning/lightning_tensor/_tensornet.py +++ b/pennylane_lightning/lightning_tensor/_tensornet.py @@ -80,11 +80,7 @@ def gate_matrix_decompose(gate_ops_matrix, wires, max_mpo_bond_dim, c_dtype): """Permute and decompose a gate matrix into MPO sites. This method return the MPO sites in the Fortran order of the ``cutensornet`` backend. Note that MSB in the Pennylane convention is the LSB in the ``cutensornet`` convention.""" sorted_indexed_wires = sorted(enumerate(wires), key=lambda x: x[1]) - sorted_wires = [] - original_axes = [] - for index, wire in sorted_indexed_wires: - sorted_wires.append(wire) - original_axes.append(index) + original_axes, sorted_wires = zip(*sorted_indexed_wires) tensor_shape = [2] * len(wires) * 2 diff --git a/tests/lightning_tensor/test_tensornet_class.py b/tests/lightning_tensor/test_tensornet_class.py index c8f24fb9c..638af52e2 100644 --- a/tests/lightning_tensor/test_tensornet_class.py +++ b/tests/lightning_tensor/test_tensornet_class.py @@ -101,7 +101,7 @@ def test_gate_matrix_decompose(): gate = scipy.linalg.expm(1j * hermitian) original_gate = gate.copy() # for later to double check - max_mpo_bond_dim = 2**len(wires) + max_mpo_bond_dim = 2 ** len(wires) mpos, sorted_wired = gate_matrix_decompose(gate, wires, max_mpo_bond_dim, np.complex128)