autoqasm.types.conversions module

Type conversions between Python and the autoqasm representation for types.

autoqasm.types.conversions.map_parameter_type(python_type: type) type[source]

Maps a given Python function parameter type to the corresponding oqpy subroutine parameter type.

Parameters:

python_type (type) – The Python type to be mapped.

Returns:

type – The corresponding oqpy type.

autoqasm.types.conversions.var_type_from_ast_type(ast_type: ClassicalType) type[source]

Converts an OpenQASM AST type to the corresponding AutoQASM variable type.

Parameters:

ast_type (ast.ClassicalType) – The OpenQASM AST type to be converted.

Returns:

type – The corresponding AutoQASM variable type.

autoqasm.types.conversions.var_type_from_oqpy(expr_or_var: OQPyExpression | Var) type[source]

Returns the AutoQASM variable type corresponding to the provided OQPy object.

Parameters:

expr_or_var (OQPyExpression | Var) – An OQPy expression or variable.

Returns:

type – The corresponding AutoQASM variable type.

autoqasm.types.conversions.wrap_value(node: Any) Any[source]
autoqasm.types.conversions.wrap_value(node: tuple)
autoqasm.types.conversions.wrap_value(node: bool)
autoqasm.types.conversions.wrap_value(node: int | integer)
autoqasm.types.conversions.wrap_value(node: int | integer)
autoqasm.types.conversions.wrap_value(node: float | floating)
autoqasm.types.conversions.wrap_value(node: float | floating)
autoqasm.types.conversions.wrap_value(node: Var)
autoqasm.types.conversions.wrap_value(node: OQPyExpression)

Wraps an object in an autoqasm variable.

Parameters:

node (Any) – The object to be wrapped.

Raises:
  • NotImplementedError – If logic for wrapping the given object

  • type does not exist.

Returns:

Any – The autoqasm variable wrapping the given object.