Ejemplo n.º 1
0
def test_random_density_matrix(dim):
    state = random_density_matrix(dim)

    assert state.shape == (dim, dim)
    np.testing.assert_allclose(np.trace(state), 1)
    np.testing.assert_allclose(state, state.T.conj())
    eigs, _ = np.linalg.eigh(state)
    assert np.all(eigs >= 0)
Ejemplo n.º 2
0
def test_random_density_matrix_deterministic_given_seed():
    state1 = random_density_matrix(10, random_state=1234)
    state2 = random_density_matrix(10, random_state=1234)

    np.testing.assert_equal(state1, state2)