Ejemplo n.º 1
0
def test_is_unitary_random():
    """Test that random unitary matrix returns True."""
    mat = random_unitary(2)
    np.testing.assert_equal(is_unitary(mat), True)
Ejemplo n.º 2
0
def test_is_not_unitary_matrix():
    """Test that non-unitary matrix returns False."""
    mat = np.array([[1, 0], [1, 1]])
    np.testing.assert_equal(is_unitary(mat), False)
Ejemplo n.º 3
0
def test_is_unitary_hardcoded():
    """Test that hardcoded unitary matrix returns True."""
    mat = np.array([[0, 1], [1, 0]])
    np.testing.assert_equal(is_unitary(mat), True)
Ejemplo n.º 4
0
def test_is_unitary_not_square():
    """Input must be a square matrix."""
    mat = np.array([[-1, 1, 1], [1, 2, 3]])
    np.testing.assert_equal(is_unitary(mat), False)
Ejemplo n.º 5
0
def test_random_unitary_not_real():
    """Generate random non-real unitary matrix."""
    mat = random_unitary(2)
    np.testing.assert_equal(is_unitary(mat), True)
Ejemplo n.º 6
0
def test_random_unitary_vec_dim():
    """Generate random non-real unitary matrix."""
    mat = random_unitary([4, 4], True)
    np.testing.assert_equal(is_unitary(mat), True)