magorder
This library streamlines the conversion between different orders of magnitude, like transforming nm (nanometers) to meters, or kilobytes to gigabytes.
It is meant to provide a drop-in mechanism that is simple and consistent to manipulate such conversions.
Installation
Install it as usual:
pip install magorder
Dependencies
This library has no runtime dependencies.
Usage
To use the library:
# import the MagnitudeUnit class that meets your requirements
from magorder.stdsi import StdSIMagnitudeUnit
# create a magorder object, associated with an unit
mag = StdSIMagnitudeUnit("m")
# transform can convert from a different order of magnitude to the base unit
assert mag.transform(0.1, "km") == 100
assert mag.transform(100_000_000, "µm") == 100
assert mag.transform(100_000_000_000_000_000_000_000_000.0, "ym") == 100
assert mag.transform(0.0000000000000000000001, "Ym", decimals=3) == 100
Or to transform data units:
from magorder.data import SIDataMagnitudeUnit, IECDataMagnitudeUnit
mags = SIDataMagnitudeUnit("b")
assert mags.transform(1, "kb") == 1000
assert mags.transform(1, from_unit="Gb", to_unit="kb") == 1_000_000
mags = IECDataMagnitudeUnit("b")
assert mags.transform(1, "Kib") == 1024
assert mags.transform(4096, from_unit="Mib", to_unit="Gib") == 4
See the module tests for more examples.
License
Check the file LICENSE.
Contributions
Feel free to contribute to this code at:
Metadata
Release files for magorder 0.20
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| magorder-0.20.tar.gz | 15.7 kB | Without provenance | Details for magorder-0.20.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| magorder-0.20-py3-none-any.whl | Python 3 | none | any | Details for magorder-0.20-py3-none-any.whl |
Total release size: 32.8 kB
Release files / magorder-0.20.tar.gz
| Download URL | magorder-0.20.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c70a499258c32da0eac23344fe2dcf17809c49412c627431a67877506439b8af
|
|
BLAKE2b-256 checksum How to use checksums |
abbb285ca4bf1a5e85fd605d7519a3c29fe97656a30bc8626c018a0821213b42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Release files / magorder-0.20-py3-none-any.whl
| Download URL | magorder-0.20-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cad03caf8baa9f2c7214272fb4726152c9bbb14962f7e192a45ae772fdadf0a1
|
|
BLAKE2b-256 checksum How to use checksums |
d24385640c648151597c994ac665c9486bd2bf9a698301e74d013e3dd334d6cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Security for magorder 0.20
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.