Repository: QuantestPy/quantestpy (language: python)

Issue:
Modify failed tests; test_test_circuit_ch_gate.py and test_test_circuit_cz_gate.py



Discussion / hints:
@mitz1012 
The two test files that you added in the PR https://github.com/QuantestPy/quantestpy/pull/68 fail👉 https://github.com/QuantestPy/quantestpy/runs/8049576710?check_suite_focus=true

These tests were not running on github actions in the PR https://github.com/QuantestPy/quantestpy/pull/68, therefore we missed it; see https://github.com/QuantestPy/quantestpy/pull/68/checks

The problems seem to be related to significant digits.
Could you please fix it and make a new PR?

Fix patch:
diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml
index 7ab4221..e0737f5 100644
--- a/.github/workflows/github-actions.yml
+++ b/.github/workflows/github-actions.yml
@@ -39,3 +39,6 @@ jobs:
           python3 -m unittest test.test_test_circuit_create_all_qubit_gate_from_single_qubit_gate
           python3 -m unittest test.test_state_vector_assert_equal
           python3 -m unittest test.test_circuit_assert_equal
+          python3 -m unittest test.test_test_circuit_ch_gate
+          python3 -m unittest test.test_test_circuit_cz_gate
+          python3 -m unittest test.test_test_circuit_cy_gate


Test patch:
diff --git a/test/test_test_circuit_ch_gate.py b/test/test_test_circuit_ch_gate.py
index e3b3b08..d6f6d90 100644
--- a/test/test_test_circuit_ch_gate.py
+++ b/test/test_test_circuit_ch_gate.py
@@ -12,7 +12,7 @@ class TestTestCircuitCHGate(unittest.TestCase):
     $ python -m unittest test.test_test_circuit_ch_gate
     ........
     ----------------------------------------------------------------------
-    Ran 7 tests in 0.050s
+    Ran 7 tests in 0.009s
 
     OK
     $
@@ -30,7 +30,7 @@ def test_ch_regular_qubit_order(self,):
                                   [0, 0, 1/np.sqrt(2), -1/np.sqrt(2)]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_ch_qiskit_qubit_order(self,):
         circ = TestCircuit(2)
@@ -46,7 +46,7 @@ def test_ch_qiskit_qubit_order(self,):
             [0. + 0.j, 0.70710678+0.j, 0. + 0.j, -0.70710678+0.j]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_ch_flip_control_target(self,):
         circ = TestCircuit(2)
@@ -62,7 +62,7 @@ def test_ch_flip_control_target(self,):
             [0. + 0.j, 0.70710678+0.j, 0. + 0.j, -0.70710678+0.j]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_ch_three_qubits_qiskit_qubit_order(self,):
         circ = TestCircuit(3)
@@ -98,7 +98,7 @@ def test_ch_three_qubits_qiskit_qubit_order(self,):
                                    0. + 0.j, -0.70710678+0.j]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_ch_control_value_is_zero(self,):
         circ = TestCircuit(2)
@@ -112,7 +112,7 @@ def test_ch_control_value_is_zero(self,):
                                   [0, 0, 0, 1]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_ch_multiple_controls(self,):
         circ = TestCircuit(3)
@@ -132,7 +132,7 @@ def test_ch_multiple_controls(self,):
                                    1/np.sqrt(2), -1/np.sqrt(2)]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_ch_multiple_targets(self,):
 
@@ -150,4 +150,5 @@ def test_ch_multiple_targets(self,):
         )
 
         self.assertIsNone(
-            np.testing.assert_allclose(gate_0, np.matmul(gate_1_0, gate_1_1)))
+            np.testing.assert_allclose(gate_0, np.matmul(gate_1_0, gate_1_1),
+                                       atol=1e-07))
diff --git a/test/test_test_circuit_cz_gate.py b/test/test_test_circuit_cz_gate.py
index 9d38f4c..8ae303b 100644
--- a/test/test_test_circuit_cz_gate.py
+++ b/test/test_test_circuit_cz_gate.py
@@ -30,7 +30,7 @@ def test_cz_regular_qubit_order(self,):
                                   [0, 0, 0, -1]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_cz_qiskit_qubit_order(self,):
         circ = TestCircuit(2)
@@ -45,7 +45,7 @@ def test_cz_qiskit_qubit_order(self,):
                                   [0, 0, 0, -1]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_cz_flip_control_target(self,):
         circ = TestCircuit(2)
@@ -59,7 +59,7 @@ def test_cz_flip_control_target(self,):
                                   [0, 0, 0, -1]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_cz_three_qubits_qiskit_qubit_order(self,):
         circ = TestCircuit(3)
@@ -80,7 +80,7 @@ def test_cz_three_qubits_qiskit_qubit_order(self,):
             [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, -1.+0.j]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_cz_control_value_is_zero(self,):
         circ = TestCircuit(2)
@@ -94,7 +94,7 @@ def test_cz_control_value_is_zero(self,):
                                   [0, 0, 0, 1]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_cz_multiple_controls(self,):
         circ = TestCircuit(3)
@@ -112,7 +112,7 @@ def test_cz_multiple_controls(self,):
                                   [0, 0, 0, 0, 0, 0, 0, -1]])
 
         self.assertIsNone(
-            np.testing.assert_allclose(actual_gate, expected_gate))
+            np.testing.assert_allclose(actual_gate, expected_gate, atol=1e-07))
 
     def test_cz_multiple_targets(self,):
 
@@ -130,4 +130,5 @@ def test_cz_multiple_targets(self,):
         )
 
         self.assertIsNone(
-            np.testing.assert_allclose(gate_0, np.matmul(gate_1_0, gate_1_1)))
+            np.testing.assert_allclose(gate_0, np.matmul(gate_1_0, gate_1_1),
+                                       atol=1e-07))