I have some code that reads numbers into a floating-point Numpy array (from a text format), multiplies the values by 1000.0, and later prints the array.
I format the array for printing like so, where k is a string identifying the array and v is the array itself:
out = f'{k.strip()} = ' + \
np.array2string(v,
prefix=f'{k} = ',
precision=5,
max_line_width=200,
floatmode='maxprec'
) + '\n'
I would like to see results that look like:
New.vals = -80. -75. -70. -65. -60. -55. -50.
But usually I get a result using scientific notation:
Typical.vals = -8.00E+01 -7.50E+01 -7.00E+01 -6.50E+01 -6.00E+01 -5.50E+01 -5.00E+01
How can I enforce formatting without scientific notation?
To the best of my knowledge there is no option available for setting a value that when exceeded triggers scientific notation. However you can define your own string-generating function:
prints: