Beispiel #1
0
 def test_double_qubit_gates(self):
     test_q0 = __rand__(0, 2048)
     test_q1 = __rand__(0, 2048)
     test_gate = 'cx'
     test_targets = f'q[{test_q0}], q[{test_q1}]'
     expected_value = f'{test_gate} {test_targets};'
     actual_value = __g__.gate(test_gate, # Gate Spec
                               test_q0, # TargetA Spec
                               test_q1) # TargetB Spec
     self.assertEqual(expected_value,
                      actual_value)
Beispiel #2
0
 def test_measurements(self):
     # Initialize variables
     test_q = __rand__(0, 1024)
     test_c = __rand__(0, 1024)
     # Set expected value
     expected_measurements = f"measure q[{test_q}] -> c[{test_c}];"
     # Get actual value
     actual_measurements = __g__.measurement(test_q,
                                             test_c)
     # Check if actual and expected values match as they should
     self.assertEqual(expected_measurements,
                      actual_measurements)
Beispiel #3
0
 def test_triple_qubit_gates(self):
     test_q0 = __rand__(0, 2048)
     test_q1 = __rand__(0, 2048)
     test_q2 = __rand__(0, 2048)
     test_gate = 'cx'
     test_targets = f'q[{test_q0}], q[{test_q1}], q[{test_q2}]'
     expected_value = f'{test_gate} {test_targets};'
     actual_value = __g__.gate(
         test_gate,  # Gate Spec
         test_q0,  # TargetA Spec
         test_q1,  # TargetB Spec
         test_q2)  # TargetC Spec
     expected_equals_actual = __tc__.compare(expected_value, actual_value)
     self.assertEqual(expected_equals_actual, True)
Beispiel #4
0
 def test_single_qubit_gates(self):
     test_q = __rand__(0,1024)
     expected_value = f"h q[{test_q}];"
     actual_value = __g__.gate('h',
                               targetA=test_q)
     self.assertEqual(expected_value,
                      actual_value)
Beispiel #5
0
 def test_ry(self):
     nrand = 256
     tgtA = __rand__(nrand)
     theta = float(__pi__ / 2)
     ry_gate = __g__.gate('ry', tgtA, theta=theta)
     expected_output = f'ry({theta}) q[{tgtA}];'
     self.assertEqual(expected_output, ry_gate)
Beispiel #6
0
 def test_single_qubit_gates(self):
     test_q = __rand__(0, 1024)
     expected_value = f"h q[{test_q}];"
     actual_value = __g__.gate('h', targetA=test_q)
     actual_equals_expected = __tc__.compare(expected_value, actual_value)
     self.assertEqual(actual_equals_expected, True)