Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map numpy values to vanilla Python values in to_ast #94

Open
braised-babbage opened this issue Sep 9, 2024 · 0 comments
Open

Map numpy values to vanilla Python values in to_ast #94

braised-babbage opened this issue Sep 9, 2024 · 0 comments

Comments

@braised-babbage
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant