inaos / iron-array

2 stars 0 forks source link

Raise an error when constants types are larger than array operands types #473

Closed FrancescAlted closed 2 years ago

FrancescAlted commented 3 years ago

This shows the issue:


In [28]: a = ia.arange((10,), dtype=np.float32)

In [29]: e = ia.expr_from_string("a * 2e36", {"a": a})
In [30]: e.eval().data
Out[30]:
array([0.0000000e+00, 1.9999999e+36, 3.9999998e+36, 5.9999995e+36,
       7.9999997e+36, 9.9999999e+36, 1.1999999e+37, 1.3999999e+37,
       1.5999999e+37, 1.8000000e+37], dtype=float32)

In [31]: e = ia.expr_from_string("a * 2e40", {"a": a})

In [32]: e.eval().data
Out[32]: array([nan, inf, inf, inf, inf, inf, inf, inf, inf, inf], dtype=float32)
FrancescAlted commented 2 years ago

After thinking more about this, I am not sure this is an error anymore because array types should always have precedence. Closing.