Skip to content

Commit

Permalink
Remove intermediate variable introduced with this 10399
Browse files Browse the repository at this point in the history
PR 10399 (not merged) changed a method call inside a Python f-string statement
into a call outside, introducing a variable, and use of that variable inside the
f-string. This commit makes a more minimal change.

Now we only replace the method call with an ordinary function call.
  • Loading branch information
jlapeyre committed Jul 14, 2023
1 parent 5f2d5f2 commit e4ab6a2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,11 +1745,10 @@ def qasm(
operation, existing_gate_names, gates_to_define
)
# Insert qasm representation of the original instruction
name_param = _instruction_qasm2(operation)
bits_qasm = ",".join(
bit_labels[j] for j in itertools.chain(instruction.qubits, instruction.clbits)
)
instruction_qasm = f"{name_param} {bits_qasm};"
instruction_qasm = f"{_instruction_qasm2(operation)} {bits_qasm};"
instruction_calls.append(instruction_qasm)
instructions_qasm = "".join(f"{call}\n" for call in instruction_calls)
gate_definitions_qasm = "".join(f"{qasm}\n" for _, qasm in gates_to_define.values())
Expand Down Expand Up @@ -5088,8 +5087,7 @@ def _qasm2_define_custom_operation(operation, existing_gate_names, gates_to_defi
instruction.operation, existing_gate_names, gates_to_define
)
bits_qasm = ",".join(qubit_labels[q] for q in instruction.qubits)
name_param = _instruction_qasm2(new_operation)
statements.append(f"{name_param} {bits_qasm};")
statements.append(f"{_instruction_qasm2(new_operation)} {bits_qasm};")
body_qasm = " ".join(statements)

# if an inner operation has the same name as the actual operation, it needs to be renamed
Expand Down

0 comments on commit e4ab6a2

Please sign in to comment.