Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphix/flow/_find_gpflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def to_correction_function(self) -> dict[int, frozenset[int]]:
correction_function: dict[int, frozenset[int]] = {}
for node in col_tags:
i = col_tags.index(node)
correction_set = {row_tags[j] for j in np.flatnonzero(self.c_matrix[:, i])}
correction_set = {row_tags[int(j)] for j in np.flatnonzero(self.c_matrix[:, i])}
correction_function[node] = frozenset(correction_set)
return correction_function

Expand Down
12 changes: 6 additions & 6 deletions tests/test_density_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def test_cnot_success(self, fx_rng: Generator) -> None:
edge = (0, 1)
dm.cnot(edge)
psi = psi.reshape((2, 2))
psi = np.tensordot(CNOT_TENSOR, psi, ((2, 3), edge)) # type: ignore[assignment]
psi = np.tensordot(CNOT_TENSOR, psi, ((2, 3), edge))
psi = np.moveaxis(psi, (0, 1), edge)
expected_matrix2 = np.outer(psi, psi.conj())
assert np.allclose(dm.rho, expected_matrix2)
Expand All @@ -320,7 +320,7 @@ def test_cnot_success(self, fx_rng: Generator) -> None:
edge = (u, v)
dm.cnot(edge)
psi = psi.reshape((2,) * n)
psi = np.tensordot(CNOT_TENSOR, psi, ((2, 3), edge)) # type: ignore[assignment]
psi = np.tensordot(CNOT_TENSOR, psi, ((2, 3), edge))
psi = np.moveaxis(psi, (0, 1), edge)
expected_matrix3 = np.outer(psi, psi.conj())
assert np.allclose(dm.rho, expected_matrix3)
Expand Down Expand Up @@ -354,7 +354,7 @@ def test_swap_success(self, fx_rng: Generator) -> None:
dm.swap(edge)
rho = dm.rho
psi = psi.reshape((2, 2))
psi = np.tensordot(SWAP_TENSOR, psi, ((2, 3), edge)) # type: ignore[assignment]
psi = np.tensordot(SWAP_TENSOR, psi, ((2, 3), edge))
psi = np.moveaxis(psi, (0, 1), edge)
expected_matrix2 = np.outer(psi, psi.conj())
assert np.allclose(rho, expected_matrix2)
Expand Down Expand Up @@ -392,7 +392,7 @@ def test_entangle_success(self, fx_rng: Generator) -> None:
dm.entangle(edge)
rho = dm.rho
psi = psi.reshape((2, 2))
psi = np.tensordot(CZ_TENSOR, psi, ((2, 3), edge)) # type: ignore[assignment]
psi = np.tensordot(CZ_TENSOR, psi, ((2, 3), edge))
psi = np.moveaxis(psi, (0, 1), edge)
expected_matrix2 = np.outer(psi, psi.conj())
assert np.allclose(rho, expected_matrix2)
Expand Down Expand Up @@ -443,7 +443,7 @@ def test_evolve_success(self, fx_rng: Generator) -> None:
rho = dm.rho

psi = psi.reshape((2,) * nqubits)
psi = np.tensordot(op.reshape((2,) * 2 * nqubits_op), psi, ((2, 3), edge)) # type: ignore[assignment]
psi = np.tensordot(op.reshape((2,) * 2 * nqubits_op), psi, ((2, 3), edge))
psi = np.moveaxis(psi, (0, 1), edge)
expected_matrix = np.outer(psi, psi.conj())
assert np.allclose(rho, expected_matrix)
Expand All @@ -468,7 +468,7 @@ def test_evolve_success(self, fx_rng: Generator) -> None:
rho = dm.rho

psi = psi.reshape((2,) * nqubits)
psi = np.tensordot(op.reshape((2,) * 2 * nqubits_op), psi, ((3, 4, 5), targets)) # type: ignore[assignment]
psi = np.tensordot(op.reshape((2,) * 2 * nqubits_op), psi, ((3, 4, 5), targets))
psi = np.moveaxis(psi, (0, 1, 2), targets)
expected_matrix = np.outer(psi, psi.conj())
assert np.allclose(rho, expected_matrix)
Expand Down
Loading