OpenQASM AST holds Python values of various types. In particular, numeric types are annotated as int, float, bool etc, but many users work with numpy or other analogues of these. As a result, oqpy's to_ast can generate OpenQASM AST that does not satisfy the typing requirements.
For example, a BooleanLiteral should wrap a Python bool. oqpy is more permissive here, as it allows a np.bool_ (https://github.com/openqasm/oqpy/blob/main/oqpy/base.py#L513C1-L514C1). But then
>>> isinstance(np.bool_(True), bool)
False
Similarly we should convert numpy floating point or integer values to vanilla Python values.
OpenQASM AST holds Python values of various types. In particular, numeric types are annotated as
int,float,booletc, but many users work with numpy or other analogues of these. As a result, oqpy'sto_astcan generate OpenQASM AST that does not satisfy the typing requirements.For example, a
BooleanLiteralshould wrap a Pythonbool. oqpy is more permissive here, as it allows anp.bool_(https://github.com/openqasm/oqpy/blob/main/oqpy/base.py#L513C1-L514C1). But thenSimilarly we should convert numpy floating point or integer values to vanilla Python values.