pyqasm.loads
- loads(program, **kwargs)[source]
Loads an OpenQASM program into a QasmModule object.
- Parameters:
program (openqasm3.ast.Program or str) – The OpenQASM program to validate.
**kwargs –
Additional arguments to pass to the loads function.
device_qubits (int): Number of physical qubits available on the target device.
device_cycle_time (float): The duration of a hardware device cycle, in seconds.
compiler_angle_type_size (int): The width of the angle type in the compiler.
extern_functions (dict): Dictionary of extern functions to be added to the module.
frame_in_def_cal (bool): Whether to allow frames in defcal.
frame_limit_per_port (int): The maximum number of frames per port.
play_in_cal_block (bool): Whether to allow play in defcal.
compact_gate_arguments (bool): Print gate arguments without spaces around ‘*’, ‘/’ and ‘**’:
rx(pi/2)instead ofrx(pi / 2). Defaults to False. Also settable later throughmodule.compact_gate_arguments.include_dir (str): Directory holding the program’s custom include files. A program given as a string has no filesystem location of its own, so this is the only way to resolve its includes. Omit it and custom includes are left unresolved and passed through, as before; pass it and an include the directory does not hold raises a
ValidationErrornaming it.
Passing an explicit
Nonefor any of these means “not passed”: the module default is kept. PassFalseto turn off a boolean kwarg.
- Raises:
TypeError – If the input is not a string or an openqasm3.ast.Program instance, if an unrecognized keyword argument is passed, or if a numeric keyword argument is not a real number.
ValueError – If a numeric keyword argument is zero or negative, or if
include_diris passed with an already-parsed openqasm3.ast.Program.ValidationError – If the program fails parsing or semantic validation, or if a custom include is not found in
include_dir.
- Returns:
- An object containing the parsed qasm representation along with
some useful metadata and methods
- Return type: