Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Oct 16, 2024
1 parent 7b88e64 commit 30c2f7b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_quantum_info_superoperator_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from qibo import matrices
from qibo.config import PRECISION_TOL
from qibo.quantum_info.linalg_operations import partial_trace
from qibo.quantum_info.random_ensembles import random_density_matrix, random_statevector
from qibo.quantum_info.superoperator_transformations import (
chi_to_choi,
Expand Down Expand Up @@ -40,6 +41,7 @@
to_choi,
to_liouville,
to_pauli_liouville,
to_stinespring,
unvectorization,
vectorization,
)
Expand Down Expand Up @@ -363,6 +365,25 @@ def test_to_chi(backend, normalize, order, pauli_order):
backend.assert_allclose(chi, test_chi, atol=PRECISION_TOL)


@pytest.mark.parametrize("test_a0", [test_a0])
def test_to_stinespring(backend, test_a0):
test_a0_ = backend.cast(test_a0)
state = random_density_matrix(2**1, seed=8, backend=backend)

target = test_a0_ @ state @ backend.np.conj(test_a0_.T)

environment = (1, 2)

global_state = backend.identity_density_matrix(len(environment), normalize=True)
global_state = backend.np.kron(state, global_state)

stinespring = to_stinespring(test_a0_, (0,), len(environment) + 1, backend=backend)
stinespring = stinespring @ global_state @ backend.np.conj(stinespring.T)
stinespring = partial_trace(stinespring, traced_qubits=environment, backend=backend)

backend.assert_allclose(stinespring, target, atol=PRECISION_TOL)


@pytest.mark.parametrize("test_superop", [test_superop])
@pytest.mark.parametrize("order", ["row", "column"])
def test_choi_to_liouville(backend, order, test_superop):
Expand Down

0 comments on commit 30c2f7b

Please sign in to comment.