1234567891011121314151617181920212223242526272829303132333435 |
- import pytest
- from qcgpu.gate import Gate, h, x, y, z, s, t, sqrt_x
- import numpy as np
- def test_gate_creation():
- Gate(np.array([[0, 1], [1, 0]]))
- h()
- x()
- y()
- z()
- s()
- t()
- sqrt_x()
- def test_using_list():
- return Gate([[1, 0], [0, 1]])
- def test_non_unitary_gate_creation_fails():
-
- with pytest.raises(Exception):
- return Gate(np.array([[12, 33], [-7j, 1]]))
- def test_large_gate_creation_fails():
-
- with pytest.raises(Exception):
- return Gate(np.ones(4))
- def test_using_scalar_fails():
- with pytest.raises(Exception):
- return Gate(2)
- def test_using_string_fails():
- with pytest.raises(Exception):
- return Gate("this should fail")
|