qbraid_algorithms.qtran.GateBuilder
- class qbraid_algorithms.qtran.GateBuilder
Specialized builder for generating gate definition files.
This builder is designed to create standalone gate definition files that can be included in other OpenQASM programs. It focuses on generating reusable gate definitions without the overhead of complete circuit structure.
Use cases:
Creating custom gate libraries
Generating reusable quantum subroutines
Building modular quantum components
- __init__()
Initialize the base file builder with empty data structures.
Sets up the foundational components needed for code generation:
Empty import list for library dependencies
Empty gate definitions dictionary for custom gates
Empty gate references list for scope validation
Empty program string for accumulating generated code
Zero scope level for proper indentation tracking
Methods
__init__()Initialize the base file builder with empty data structures.
build()Generate the final gate definition output.
import_library(lib_class[, annotated])Import and initialize a quantum gate library.
program_append(line)Append a line of code to the program with proper indentation.