Limit the number of decimal places when displaying floats with NumPy
Currently, NumPy displays too many decimal places for floating point numbers by default.
Exemple :
Propositions :
- Use printoptions as a context manager to set the values temporarily.
- Work directly for the iterations prints
- Other proposition ?
I think we should use a consistent number of significant figures (3?) to ensure the number of various magnitude that we have always display correctly.
Apparently there's two ways of doing this, either Python f"{mynum:.3g}" or NumPy with np.printoptions(precision=3) you mention. However both of those will trigger scientific notation for small/large numbers (e.g. 1.234e+05).
If we want to avoid scientific notation and still have right number of significant digits, apparently there aren't many options, it's only np.format_float_positional that is made just for this!
I can deal with this in #759
Great ! Thanks :)
I think we should use a consistent number of significant figures (3?) to ensure the number of various magnitude that we have always display correctly.
Apparently there's two ways of doing this, either Python
f"{mynum:.3g}"or NumPy withnp.printoptions(precision=3)you mention. However both of those will trigger scientific notation for small/large numbers (e.g.1.234e+05).If we want to avoid scientific notation and still have right number of significant digits, apparently there aren't many options, it's only
np.format_float_positionalthat is made just for this!I can deal with this in #759
Of course, scientific notation is the only way if you want to always display 3 non 0 numbers. But if we know we wants only 3 digits, it is possible to use the format ".3f" instead of ".3g". For example, if the shift is 0.0001 pixels, it makes sense that the print is "0.000" (with .3f) instead of "1e-4" (with .3g).