qbraid.passes.qasm.replace_gate_name

replace_gate_name(qasm, old_gate_name, new_gate_name, force_replace=False)[source]

Replace occurrences of a specified gate name in a QASM program string with a new gate name, while optionally enforcing the replacement even if the new gate name isn’t in the predefined gate map.

Parameters:
  • qasm (str) – The QASM program as a string.

  • old_gate_name (str) – The original gate name to replace.

  • new_gate_name (str) – The new gate name to use in replacement.

  • force_replace (bool) – If True, force the replacement even if the new gate name isn’t in the gate map.

Returns:

The modified QASM program with the gate names replaced.

Return type:

str