Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Aug 22, 2024
1 parent 9f32502 commit 9bb78f9
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/terra/backends/test_runtime_parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,44 @@ def test_kraus_noise_with_shot_branching(self, method, device):

self.assertEqual(counts, counts_pre_bind)

@supported_methods(SUPPORTED_METHODS)
def test_bind_some_param(self, method, device):
"""Test parameterized circuit with gate with defaul values"""
shots = 1000
backend = self.backend(method=method, device=device)
circuit = QuantumCircuit(2)
theta = Parameter("theta")
theta_squared = theta * theta
circuit.h(0)
circuit.rx(theta, 0)
circuit.cx(0, 1)
circuit.rz(theta_squared, 1)
circuit.u(theta, theta_squared, 1.5708, 1)
circuit.measure_all()
parameter_binds = [{theta: [0, pi, 2 * pi]}]

result = backend.run(
circuit,
shots=shots,
parameter_binds=parameter_binds,
shot_branching_enable=False,
runtime_parameter_bind_enable=True,
).result()
self.assertSuccess(result)
counts = result.get_counts()

result_pre_bind = backend.run(
circuit,
shots=shots,
parameter_binds=parameter_binds,
shot_branching_enable=False,
runtime_parameter_bind_enable=False,
).result()
self.assertSuccess(result_pre_bind)
counts_pre_bind = result_pre_bind.get_counts()

self.assertEqual(counts, counts_pre_bind)


if __name__ == "__main__":
unittest.main()

0 comments on commit 9bb78f9

Please sign in to comment.