Ejemplo n.º 1
0
def test_fidelity_bounded_purepure(tol=1e-7):
    """
    Metrics: Fidelity of pure states within [0, 1].
    """
    for _ in range(10):
        psi = rand_ket_haar(17)
        phi = rand_ket_haar(17)
        F = fidelity(psi, phi)
        assert_(-tol <= F <= 1 + tol)
Ejemplo n.º 2
0
def test_fidelity_bounded_purepure(tol=1e-7):
    """
    Metrics: Fidelity of pure states within [0, 1].
    """
    for _ in range(10):
        psi = rand_ket_haar(17)
        phi = rand_ket_haar(17)
        F = fidelity(psi, phi)
        assert_(-tol <= F <= 1 + tol)
Ejemplo n.º 3
0
def test_fidelity_overlap():
    """
    Metrics: Checks fidelity against pure-state overlap. (#631)
    """
    for _ in range(10):
        psi = rand_ket_haar(7)
        phi = rand_ket_haar(7)

        assert_almost_equal(fidelity(psi, phi), np.abs((psi.dag() * phi)[0,
                                                                         0]))
Ejemplo n.º 4
0
def test_fidelity_overlap():
    """
    Metrics: Checks fidelity against pure-state overlap. (#631)
    """
    for _ in range(10):
        psi = rand_ket_haar(7)
        phi = rand_ket_haar(7)

        assert_almost_equal(
            fidelity(psi, phi),
            np.abs((psi.dag() * phi)[0, 0])
        )
Ejemplo n.º 5
0
def test_fidelity_max():
    """
    Metrics: Fidelity of a pure state w/ itself should be 1.
    """
    for _ in range(10):
        psi = rand_ket_haar(13)
        assert_almost_equal(fidelity(psi, psi), 1)
Ejemplo n.º 6
0
def test_fidelity_max():
    """
    Metrics: Fidelity of a pure state w/ itself should be 1.
    """
    for _ in range(10):
        psi = rand_ket_haar(13)
        assert_almost_equal(fidelity(psi, psi), 1)
Ejemplo n.º 7
0
def test_fidelity_bounded_puremixed(tol=1e-7):
    """
    Metrics: Fidelity of pure states against mixed states within [0, 1].
    """
    for _ in range(10):
        psi = rand_ket_haar(11)
        sigma = rand_dm_ginibre(11)
        F = fidelity(psi, sigma)
        assert_(-tol <= F <= 1 + tol)
Ejemplo n.º 8
0
def test_fidelity_bounded_puremixed(tol=1e-7):
    """
    Metrics: Fidelity of pure states against mixed states within [0, 1].
    """
    for _ in range(10):
        psi = rand_ket_haar(11)
        sigma = rand_dm_ginibre(11)
        F = fidelity(psi, sigma)
        assert_(-tol <= F <= 1 + tol)