Exemple #1
0
def test_is_valid_cov_thermal(nbar):
    """ Test if is_valid_cov for a mixed state"""
    hbar = 2
    dim = 10
    cov = (2 * nbar + 1) * np.identity(dim)
    val = is_valid_cov(cov, hbar=hbar)
    assert val
Exemple #2
0
def test_is_valid_cov_non_symmetric():
    """ Test False if matrix is not symmetric"""
    hbar = 2
    V = np.zeros([4, 4])
    V[0, 1] = 1
    val = is_valid_cov(V, hbar=hbar)
    assert not val
Exemple #3
0
def test_is_valid_cov_too_certain():
    """ Test False if matrix does not satisfy the Heisenberg
    uncertainty relation"""
    hbar = 2
    V = np.random.random([4, 4])
    V += V.T
    val = is_valid_cov(V, hbar=hbar)
    assert not val
Exemple #4
0
    def test_hbar(self, hbar, tol):
        """test that the output is a valid covariance matrix, even when not square"""

        M = 4
        a = np.arange(4 * M**2, dtype=np.float64).reshape((2 * M, 2 * M))
        cov = a @ a.T + np.eye(2 * M)
        mu = np.arange(2 * M, dtype=np.float64)

        T = np.sqrt(0.9) * M**(-0.5) * np.ones((6, M), dtype=np.float64)

        _, cov_out = symplectic.passive_transformation(mu, cov, T, hbar=hbar)

        assert is_valid_cov(cov_out, hbar=hbar, atol=tol, rtol=0)
Exemple #5
0
    def test_valid_cov(self, M, tol):
        """test that the output is a valid covariance matrix, even when not square"""
        a = np.arange(4 * M**2, dtype=np.float64).reshape((2 * M, 2 * M))
        cov = a @ a.T + np.eye(2 * M)
        mu = np.arange(2 * M, dtype=np.float64)

        T = np.sqrt(0.9) * M**(-0.5) * np.ones((6, M), dtype=np.float64)

        mu_out, cov_out = symplectic.passive_transformation(mu, cov, T)

        assert cov_out.shape == (12, 12)
        assert len(mu_out) == 12
        assert is_valid_cov(cov_out, atol=tol, rtol=0)
Exemple #6
0
def test_is_valid_cov_not_even_dimension():
    """ Test False if matrix does not have even dimensions"""
    hbar = 2
    V = np.zeros([5, 5])
    val = is_valid_cov(V, hbar=hbar)
    assert not val
Exemple #7
0
def test_is_valid_cov_non_square():
    """ Test False if matrix is not square"""
    hbar = 2
    V = np.ones([3, 4])
    val = is_valid_cov(V, hbar=hbar)
    assert not val
Exemple #8
0
def test_is_valid_cov():
    """ Test if is_valid_cov for a valid covariance matrix """
    hbar = 2
    val = is_valid_cov(V, hbar=hbar)
    assert val