From c8444f6c87c3a7d7b239671cbb18c8267922b998 Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Tue, 17 Sep 2024 19:49:18 +0000 Subject: [PATCH] apply more comments --- pennylane_lightning/lightning_tensor/_tensornet.py | 6 +----- tests/lightning_tensor/test_tensornet_class.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) 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)