Skip to content

Commit

Permalink
correct API changes in v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tjstavenger-pnnl committed Feb 19, 2024
1 parent 50cf52e commit 1f3c806
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion c2qa/discretize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test_animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions tests/test_parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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)


Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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)"
Expand Down

0 comments on commit 1f3c806

Please sign in to comment.