Obviously, it's very practical what you mentioned. For now, it's the simplest solution.
Thanks Yoriz
Yes, I am getting an extremely long float at 0.47
I am formatting all this as follows ...
Thanks Yoriz
(Apr-27-2019, 08:47 PM)Gribouillis Wrote: Notice this in the documentation ofnumpy.arange()
[quote=numpy documentation] When using a non-integer step, such as 0.1, the results will often not
be consistent. It is better to uselinspace
for these cases.
Yes, I am getting an extremely long float at 0.47
I am formatting all this as follows ...
import numpy as np from numpy import linspace myRange = list(np.linspace(0.45, 0.6, 16)) myFormattedRange = ['%.2f'% elem for elem in myRange]
Output:print(myRange)
[0.45, 0.46, 0.47000000000000003, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6]
print(myFormattedRange)
['0.45', '0.46', '0.47', '0.48', '0.49', '0.50', '0.51', '0.52', '0.53', '0.54', '0.55', '0.56', '0.57', '0.58', '0.59', '0.60']