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.
Install by:
pip install order-of-magnitude
Some examples:
import numpy as np from order_of_magnitude import order_of_magnitude print(order_of_magnitude.oom(1.20679264e+19)) # returns '12.1 E' print(order_of_magnitude.oom(1.20679264e+19, decimals=4)) # returns '12.0679 E' print(order_of_magnitude.oom(np.logspace(3, 6, num=10))) # returns ['1.0 k', '2.2 k', '4.6 k', '10.0 k', '21.5 k', '46.4 k', '100.0 k', '215.4 k', '464.2 k', '1.0 M'] print(order_of_magnitude.oom(np.logspace(3, 6, num=10), prefix=True)) # returns ['1.0 kilo', '2.2 kilo', '4.6 kilo', '10.0 kilo', '21.5 kilo', '46.4 kilo', '100.0 kilo', '215.4 kilo', '464.2 kilo', '1.0 mega'] print(order_of_magnitude.oom(0e9)) # returns 0.0 print(order_of_magnitude.oom(np.logspace(3, 6, num=10), only_oom=True)) #returns ['k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'M'] print(order_of_magnitude.oom(np.logspace(3, 6, num=10), prefix=True, only_oom=True)) # returns [' kilo', ' kilo', ' kilo', ' kilo', ' kilo', ' kilo', ' kilo', ' kilo', ' kilo', ' mega']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file order_of_magnitude-1.5.tar.gz.
File metadata
- Download URL: order_of_magnitude-1.5.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67d05f4c9bd6935113608f48b4bd254c27c51e7aca79c594792fa03e6cf77430
|
|
| MD5 |
eec260676643a568f5a38348ff51c987
|
|
| BLAKE2b-256 |
46a56c2f5a0f8159896fa7831391cb09223dd14a4d6890ee67697fc76602b1de
|