Note notation

Is there a way to limit the representation of floating point numbers so that they match only the prefixes used in physical units.

An example will simplify:

0.01 -> currently 1e-02 -> what I'd like 10e-03 0.0001 -> currently 1e-04 -> what I'd like 100e-06 

The motivation is that I take some time measurements and have views, since 1000 views are much more user friendly. I know that 10e-03 -> 10mili or 100e-06 -> 100u

Update

For numpy 1.7 <there is a set_printoptions() attribute in set_printoptions() . The solution I'm heading for is to write a built-in function that will perform formatting. After installing it, formatting should be available worldwide.

Formatter Link

+4
source share
1 answer

I think this section may be useful to you. On the other hand, I would try to create several β€œbuckets” for values ​​in certain ranges and check the simple condition> (the lowest value in the range), and then multiply this value by the range, for example. 2e-5 on 1e6 to get 20u. Not very effective, but easy.

+1
source

Source: https://habr.com/ru/post/1494100/


All Articles