juanre / magnitude

A Python library for computing with numbers with units.
http://juanreyero.com/magnitude/
21 stars 5 forks source link

Nearest SI prefix #1

Open trombonehero opened 12 years ago

trombonehero commented 12 years ago

Love this library, but I have a feature request:

I'd love for a magnitude to have something like .ounit() which means "use whatever SI prefix keeps the displayed magnitude between 0 and 1000". Currently, I have to munge ounit strings, replacing 'M' with 'k' or 'G' where appropriate.

Thanks!

hmeine commented 7 years ago

This is exactly what I was looking for. I wrote small python modules in the past for time and file size pretty-printing, and found magnitude when looking for something more general. I am not entirely sure yet whether .ounit() would be the right API; maybe some more explicit .pprint() function would be more appropriate, assuming that your use case also was pretty printing?