qbraid.passes.qasm.replace_gate_names

replace_gate_names(qasm, gate_mappings, case_sensitive=False)[source]

Replace occurrences of specified gate names in a QASM program string.

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

  • gate_mappings (dict[str, str]) – A dictionary mapping old gate names (keys) to new gate names (values).

  • case_sensitive (bool) – Whether the gate name replacement should be case-sensitive. Defaults to False.

Returns:

The modified QASM program with the gate names replaced.

Return type:

str

Raises:

ValueError – If duplicate keys are found in the gate_mappings after lowercasing.