oqpy icon indicating copy to clipboard operation
oqpy copied to clipboard

NaN support

Open ajberdy opened this issue 3 months ago • 1 comments

The openqasm spec references NaN values for floats, but oqpy does not support them.

To reproduce:

import math

import oqpy
from oqpy.base import to_ast


program = oqpy.Program()
float_var = to_ast(program, 1.0)
print(float_var)
float_var_nan = to_ast(program, math.nan)
print(float_var_nan)

outputs

FloatLiteral(span=None, value=1.0)
ValueError: cannot convert float NaN to integer

This should be handled, perhaps yielding FloatLiteral(span=None, value=math.nan)

ajberdy avatar Sep 19 '25 01:09 ajberdy

I don't think I have the necessary repo permissions to assign this issue, but I'm happy to take it

ajberdy avatar Sep 19 '25 01:09 ajberdy