Documentation suggestion: Float64 Converters #90
Unanswered
WilliamParsonsV
asked this question in
Q&A
Replies: 1 comment
-
I'm not sure I understand. When I multiple a numpy array of uint8's by a python float it promotes the data type to float64. Are you saying you were using a poly converter with float literals, and it wasn't promoting the data type to float64? In [14]: x = 10.0
In [15]: type(x)
Out[15]: float
In [16]: x * np.arange(10, dtype=np.uint8)
Out[16]: array([ 0., 10., 20., 30., 40., 50., 60., 70., 80., 90.])
In [17]: (x * np.arange(10, dtype=np.uint8)).dtype
Out[17]: dtype('float64') Or maybe the coefficients were loaded from a file, and the values passed you passed were accidentally np.float16 or np.float32? If this is the case, it might make sense to automatically upcast the coefficients to float64 just to be safe. It can be easy to confuse a numpy float16 or float32 with a python float because they appear similar when you print them. In [18]: np.float16(0)
Out[18]: 0.0 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Just wanted to make a suggestion for adding that you need to use numpy's np.float64(x) instead of just python's float(x) when using PolyConverters with very volatile coefficients (high exponents like e-28 and many decimal places)
It's possible this is required elsewhere but I'm only using PolyConverters right now.
I might have missed it in the documentation somewhere but I fixed my issue after debugging my code heavily and noticing float64 typing in your test_converters script
I'm surprised it made such a difference but it was the difference between 35.4 (the correct answer) and garbage values like 634241.113
Beta Was this translation helpful? Give feedback.
All reactions