Skip to content

Commit

Permalink
fix codecov complains
Browse files Browse the repository at this point in the history
  • Loading branch information
multiphaseCFD committed Sep 11, 2024
1 parent c8e2323 commit 4c7d2bd
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions pennylane_lightning/lightning_tensor/_tensornet.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def svd_split(M, bond_dim):


def split(M, max_mpo_bond_dim):
"""SVD split a matrix into a matrix product operator via numpy linalg. Note that this function is to be moved to the C++ layer."""
U, S, Vd = np.linalg.svd(M, full_matrices=False)
bonds = len(S)
Vd = (
Expand All @@ -65,6 +66,7 @@ def split(M, max_mpo_bond_dim):


def dense_to_mpo(psi, n_wires, max_mpo_bond_dim):
"""Convert a dense gate matrix to a matrix product operator."""
Ms = [[] for _ in range(n_wires)]

psi = np.reshape(psi, (4, -1))
Expand Down Expand Up @@ -344,22 +346,14 @@ def _apply_lightning_controlled(self, operation):
control_wires = list(operation.control_wires)
control_values = operation.control_values
target_wires = list(operation.target_wires)
if method is not None and basename not in (
"GlobalPhase",
"MultiRZ",
): # apply n-controlled specialized gate

if method is not None and basename not in ("GlobalPhase", "MultiRZ"):
inv = False

Check notice on line 351 in pennylane_lightning/lightning_tensor/_tensornet.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane_lightning/lightning_tensor/_tensornet.py#L351

Too many branches (13/12) (too-many-branches)
param = operation.parameters
method(control_wires, control_values, target_wires, inv, param)
else: # apply gate as an n-controlled matrix
method = getattr(tensornet, "applyControlledMatrix")
method(
qml.matrix(operation.base),
control_wires,
control_values,
target_wires,
False,
)
method(qml.matrix(operation.base), control_wires, control_values, target_wires, False)

def _apply_lightning(self, operations):
"""Apply a list of operations to the quantum state.
Expand Down

0 comments on commit 4c7d2bd

Please sign in to comment.