Skip to main content

Converts floats to SI units.

Project description

Pure Python 3 implementation to convert floats, lists of floats, NumPy arrays to International System of Units (SI) strings.

Some examples:

order_of_magnitude.oom(1.20679264e+19)
# returns '12.1 E'
order_of_magnitude.oom(1.20679264e+19, decimals=4)
# returns '12.0679 E'
order_of_magnitude.oom(np.logspace(5,12))
# returns ['10.0 M', '13.9 M', '19.3 M', '26.8 M', '37.3 M', '51.8 M', '72.0 M', '1.0 M', '1.4 M', '1.9 M', '2.7 M', '3.7 M', '5.2 M', '7.2 M', '10.0 M', '13.9 M', '19.3 M', '26.8 M', '37.3 M', '51.8 M', '72.0 M', '10.0 G', '13.9 G', '19.3 G', '26.8 G', '37.3 G', '51.8 G', '72.0 G', '1.0 G', '1.4 G', '1.9 G', '2.7 G', '3.7 G', '5.2 G', '7.2 G', '10.0 G', '13.9 G', '19.3 G', '26.8 G', '37.3 G', '51.8 G', '72.0 G', '10.0 T', '13.9 T', '19.3 T', '26.8 T', '37.3 T', '51.8 T', '72.0 T', '1.0 T']
order_of_magnitude.oom(np.logspace(5,12), prefix=True)
# returns ['10.0  mega', '13.9  mega', '19.3  mega', '26.8  mega', '37.3  mega', '51.8  mega', '72.0  mega', '1.0  mega', '1.4  mega', '1.9  mega', '2.7  mega', '3.7  mega', '5.2  mega', '7.2  mega', '10.0  mega', '13.9  mega', '19.3  mega', '26.8  mega', '37.3  mega', '51.8  mega', '72.0  mega', '10.0  giga', '13.9  giga', '19.3  giga', '26.8  giga', '37.3  giga', '51.8  giga', '72.0  giga', '1.0  giga', '1.4  giga', '1.9  giga', '2.7  giga', '3.7  giga', '5.2  giga', '7.2  giga', '10.0  giga', '13.9  giga', '19.3  giga', '26.8  giga', '37.3  giga', '51.8  giga', '72.0  giga', '10.0  tera', '13.9  tera', '19.3  tera', '26.8  tera', '37.3  tera', '51.8  tera', '72.0  tera', '1.0  tera']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

order_of_magnitude-1.0.tar.gz (2.4 kB view details)

Uploaded Source

File details

Details for the file order_of_magnitude-1.0.tar.gz.

File metadata

  • Download URL: order_of_magnitude-1.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8

File hashes

Hashes for order_of_magnitude-1.0.tar.gz
Algorithm Hash digest
SHA256 1796cca460ecca6c9dac52040ac429870287a1f9d790300e3834978d1c26a1e7
MD5 045c8151a600d356955d56b326e2bb36
BLAKE2b-256 ea7e89399c8e157014c92590afd553d615fa21b4d2dd0f1106e998821576ff8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page