qbraid.passes.qasm3.insert_gate_def

insert_gate_def(qasm3_str, gate_name, force_insert=False)[source]

Add gate definitions to an Open0QASM 3 string.

Parameters:
  • qasm3_str (str) – QASM 3.0 string.

  • gate_name (str) – Name of the gate to insert.

  • force_insert (bool) – If True, the gate definition will be added even if the gate is never referenced. Defaults to False.

Returns:

QASM 3.0 string with gate definition.

Return type:

str

Raises:

ValueError – If the gate definition is not found.