Trait
Module for parsing and displaying quantum computing program components using the bloqade library.
Parse ¶
Bases: ParseRegister
, ParseSequence
, ParseCircuit
, ParseRoutine
A composite class inheriting from ParseRegister, ParseSequence, ParseCircuit, and ParseRoutine. Provides a unified interface for parsing different components of the program.
n_atoms property
¶
Return the number of atoms in the program.
Returns:
Name | Type | Description |
---|---|---|
int | int | The number of atoms in the parsed register. |
Raises:
Type | Description |
---|---|
ValueError | If the register type is unsupported. |
Note
If the register is of type ParallelRegister, the number of atoms is extracted from its internal register.
Example:
ParseCircuit ¶
A class providing functionality to parse the analog circuit from the program.
Example:
>>> class MyBuilder(ParseCircuit):
... pass
>>> builder = MyBuilder()
>>> analog_circuit = builder.parse_circuit()
parse_circuit ¶
Parse the analog circuit from the program.
Returns:
Name | Type | Description |
---|---|---|
AnalogCircuit | AnalogCircuit | The parsed analog circuit. |
Raises:
Type | Description |
---|---|
ValueError | If the circuit cannot be parsed. |
Source code in src/bloqade/builder/parse/trait.py
ParseRegister ¶
A class providing functionality to parse the arrangement of atoms in the program.
Example:
>>> class MyBuilder(ParseRegister):
... pass
>>> builder = MyBuilder()
>>> atom_arrangement = builder.parse_register()
parse_register ¶
Parse the arrangement of atoms in the program.
Returns:
Type | Description |
---|---|
Union[AtomArrangement, ParallelRegister] | Union[AtomArrangement, ParallelRegister]: The parsed atom arrangement or parallel register. |
Raises:
Type | Description |
---|---|
ValueError | If the register cannot be parsed. |
Source code in src/bloqade/builder/parse/trait.py
ParseRoutine ¶
A class providing functionality to parse the program and return a Routine object.
Example:
ParseSequence ¶
A class providing functionality to parse the pulse sequence part of the program.
Example:
>>> class MyBuilder(ParseSequence):
... pass
>>> builder = MyBuilder()
>>> sequence = builder.parse_sequence()
Show ¶
A mixin class providing functionality to display the builder with given arguments and batch ID.
show ¶
Display the current program being defined with the given arguments and batch ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args | Additional arguments for display. | () | |
batch_id | int | The batch ID to be displayed. Defaults to 0. | 0 |
Note
This method uses the display_builder
function to render the builder's state.
Example:
>>> class MyBuilder(Show):
... pass
>>> builder = MyBuilder()
>>> builder.show()
>>> builder.show(batch_id=1)
>>> builder.show('arg1', 'arg2', batch_id=2)