From 1f3c8069caf9ef2c3e6561b19c90854fb7b73f18 Mon Sep 17 00:00:00 2001 From: Tim Stavenger Date: Mon, 19 Feb 2024 14:51:11 -0800 Subject: [PATCH] correct API changes in v1.0 --- c2qa/discretize.py | 2 +- tests/test_animate.py | 6 +++--- tests/test_parameterized.py | 8 ++++---- .../jaynes-cummings-dispersive.ipynb | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/c2qa/discretize.py b/c2qa/discretize.py index fc468c0..bb253a8 100644 --- a/c2qa/discretize.py +++ b/c2qa/discretize.py @@ -102,7 +102,7 @@ def discretize_single_circuit( segment_count = 0 for inst, qargs, cargs in circuit.data: num_segments = segments_per_gate - qargs_indices = [qubit.index for qubit in qargs] + qargs_indices = [qubit._index for qubit in qargs] # FIXME -- is there a public API to get the qubit's index in Qiskit v1.0+? if noise_passes and not (isinstance(inst, qiskit.circuit.instruction.Instruction) and inst.name == "initialize"): # Don't discretize instructions initializing system state: noise_pass = None diff --git a/tests/test_animate.py b/tests/test_animate.py index 31611ec..5ae325a 100644 --- a/tests/test_animate.py +++ b/tests/test_animate.py @@ -53,7 +53,7 @@ def __build_subcircuit(): # Append time evolution unitary circuit_0.append(U_JC,qmr[0] + [qbr[0]]) - # circuit_0.bind_parameters({dt : total_time}) + # circuit_0.assign_parameters({dt : total_time}) # dt = total_time @@ -74,7 +74,7 @@ def __build_subcircuit(): # circuit_1.initialize([0,1], qbr) # circuit_1.cv_d(alpha,qmr[0]) # circuit_1.append(U_JC,qmr[0] + [qbr[0]]) - # circuit_1 = circuit_1.bind_parameters({dt : total_time}) + # circuit_1 = circuit_1.assign_parameters({dt : total_time}) return circuit_0 @@ -115,7 +115,7 @@ def test_animate_parameterized(capsys): minimal_circuit.cv_c_d(1j * a, qmr[0], qbr[0]) - bound_circuit = minimal_circuit.bind_parameters({a: 2}) + bound_circuit = minimal_circuit.assign_parameters({a: 2}) wigner_filename = "tests/animate_parameterized.apng" c2qa.animate.animate_wigner( diff --git a/tests/test_parameterized.py b/tests/test_parameterized.py index 96a9ed3..2cc2a47 100644 --- a/tests/test_parameterized.py +++ b/tests/test_parameterized.py @@ -46,7 +46,7 @@ def test_parameterized_displacement(capsys): alpha = qiskit.circuit.Parameter("alpha") circuit.cv_d(alpha, qmr[0]) - bound_circuit = circuit.bind_parameters({alpha: 3.14}) + bound_circuit = circuit.assign_parameters({alpha: 3.14}) state, result, fock_counts = c2qa.util.simulate(bound_circuit) assert_changed(state, result) @@ -65,7 +65,7 @@ def test_complex_literals(capsys): minimal_circuit.cv_c_d(1j * 1, qmr[0], qbr[0]) - # bound_circuit = minimal_circuit.bind_parameters({a: 1}) + # bound_circuit = minimal_circuit.assign_parameters({a: 1}) c2qa.util.simulate(minimal_circuit) @@ -83,7 +83,7 @@ def test_complex_parameters(capsys): minimal_circuit.cv_c_d(1j * a, qmr[0], qbr[0]) - bound_circuit = minimal_circuit.bind_parameters({a: 1}) + bound_circuit = minimal_circuit.assign_parameters({a: 1}) c2qa.util.simulate(bound_circuit) @@ -100,5 +100,5 @@ def test_complex_parameters_float(capsys): minimal_circuit.cv_c_d(1j * a, qmr[0], qbr[0]) - bound_circuit = minimal_circuit.bind_parameters({a: 2}) + bound_circuit = minimal_circuit.assign_parameters({a: 2}) c2qa.util.simulate(bound_circuit) diff --git a/tutorials/jaynes-cummings-model/jaynes-cummings-dispersive.ipynb b/tutorials/jaynes-cummings-model/jaynes-cummings-dispersive.ipynb index f882077..3697a07 100644 --- a/tutorials/jaynes-cummings-model/jaynes-cummings-dispersive.ipynb +++ b/tutorials/jaynes-cummings-model/jaynes-cummings-dispersive.ipynb @@ -215,7 +215,7 @@ "sigma_x_expectation = []\n", "sigma_z_expectation = []\n", "for tau in tarray:\n", - " state, result, _ = c2qa.util.simulate(circuit.bind_parameters({dt : tau}))\n", + " state, result, _ = c2qa.util.simulate(circuit.assign_parameters({dt : tau}))\n", " sigma_x_expectation.append(state.expectation_value(sigmax).real)\n", " sigma_z_expectation.append(state.expectation_value(sigmaz).real)" ] @@ -409,7 +409,7 @@ " \n", " sigma_x_expectation = []\n", " for tau in tarray:\n", - " state, result, _ = c2qa.util.simulate(circuit.bind_parameters({dt : tau}))\n", + " state, result, _ = c2qa.util.simulate(circuit.assign_parameters({dt : tau}))\n", " sigma_x_expectation.append(state.expectation_value(sigmax).real)\n", "\n", "\n", @@ -504,7 +504,7 @@ "\n", "# Append time evolution unitary\n", "circuit_0.append(U_JC,qmr[0] + [qbr[0]]);\n", - "# circuit_0.bind_parameters({dt : total_time})\n", + "# circuit_0.assign_parameters({dt : total_time})\n", "\n", "\n", "# dt = total_time\n", @@ -525,7 +525,7 @@ "# circuit_1.initialize([0,1], qbr)\n", "# circuit_1.cv_d(alpha,qmr[0])\n", "# circuit_1.append(U_JC,qmr[0] + [qbr[0]]);\n", - "# circuit_1 = circuit_1.bind_parameters({dt : total_time})\n", + "# circuit_1 = circuit_1.assign_parameters({dt : total_time})\n", "\n", "# Animate wigner function of each circuit\n", "c2qa.animate.animate_wigner(circuit_0, animation_segments = 1000)"