Skip to main content

MAGO-LIB

A Python library to format, parse, and convert numbers from meters to maghi.

What's this, though?

Meters (= boring 👎)

Since 2019, the metre has been defined as the length of the path travelled by light in vacuum during a time interval of 1/299792458 of a second, where the second is defined by a hyperfine transition frequency of caesium.

One second is the time that elapses during 9.192631770 x 10E9 cycles of the radiation produced by the transition between two levels of the cesium-133 atom.

What the hell is even that? How could you ever recreate a precise meter if you found yourself in a forest alone or shipwrecked on a desert island? Important questions. But the International System of Units doesn't care about you.

Maghi (= helpful! 👍)

How do you define a Mago? Simple enough! That's his height:

Niccolò Marcon, the reference measure of a Mago

Of course, you'll have already figured the advantages of such unit of measurement:

  • Simple and immediate definition
  • The size of a Niccolò is UNIVERSALLY known on Planet Earth
  • This Niccolò has always existed and forever will
  • Its length is unchanged since the dawn of time and is extremely stable (contrary to a standard meter) to:
    • Thermal variations
    • Mechanical fatigue
    • Aging and degradation
    • Chemical stress
    • Verbal abuse
    • Intense math classes (up to 8 hours of continued exposure)
    • Electromagnetic radiation
    • Ionizing radiation (under testing)
  • If you dip a meter in Nutella it'll be ruined, a Mago will smile and thank you
  • Conversion between meters and maghi is very straightforward
  • A handy Python library is available to help migrate the world from metric to magic

Conventions:

  • We denote a mago with the character: ℳ
  • One ℳ equals approximately 1.93 meters
  • All the standard multiples and submultiples apply:
    Prefix Name Factor
    p pico 1e-12
    n nano 1e-9
    µ, u micro 1e-6
    m milli 1e-3
    c centi 1e-2
    d deci 1e-1
    1e0
    da deca 1e1
    h etto 1e2
    k, K kilo 1e3
    M mega 1e6
    G giga 1e9
    T tera 1e12

Installation

Ensure you have Python and Pip installed in your system and run:

pip install magolib

Alternatively, you can clone this repository, cd into it, and run pip install .

Usage

First off, import magolib:

import magolib

Next, you can perform all these operations:

Convert meters to maghi

>>> magolib.meters_to_maghi(1.0)
0.5181347150259068
>>> magolib.meters_to_maghi(-0.58)
-0.3005181347150259
>>> magolib.meters_to_maghi(2.3e4)
11917.098445595855

Convert maghi to meters

>>> magolib.maghi_to_meters(1.0)
1.93
>>> magolib.maghi_to_meters(-42.5)
-82.02499999999999
>>> magolib.maghi_to_meters(1.9e-2)
0.03667

Format maghi as strings

>>> magolib.format_maghi(1.0)
'1.00 ℳ  (maghi)'
>>> magolib.format_maghi(3.4e-10)
'340.00 pℳ  (picomaghi)'
>>> magolib.format_maghi(23e6)
'23.00 Mℳ  (megamaghi)'

Convert maghi subunits

>>> magolib.convert_maghi(1.0, '', 'k')
0.001
>>> magolib.convert_maghi(5, 'h', '')
500.0
>>> magolib.convert_maghi(7.2, 'm', 'u')
7200.000000000001

Parse meters from string

>>> magolib.parse_meters('-2e3 km')
-2000000.0
>>> magolib.parse_meters('1 m')
1.0
>>> magolib.parse_meters('.3 dm')
0.03
>>> magolib.parse_meters('-2e3 km')
-2000000.0

Parse maghi from string

>>> magolib.parse_maghi('1ℳ')
1.0
>>> magolib.parse_maghi('1M')
1.0
>>> magolib.parse_maghi('3 mM')
0.003

Note: here for simplicity you can use an uppercase 'M' in place of the symbol 'ℳ'

Metadata

Release files for magolib 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for magolib 0.0.1
File Size Uploaded Provenance
magolib-0.0.1.tar.gz 7.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for magolib 0.0.1
File Interpreter ABI Platform
magolib-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.7 kB

Release files / magolib-0.0.1.tar.gz

Download URL magolib-0.0.1.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ca08f5da7fd1e6376264585b147d837009e543f314b308be862623b397a10523
BLAKE2b-256 checksum
How to use checksums
8454496124609c2a124b78429cd2f9d1f98d7daef9056e52eb8db3efa37d637e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.12

Release files / magolib-0.0.1-py3-none-any.whl

Download URL magolib-0.0.1-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
02ac40419ffe27ec40880f156b63c6404f333ff02c02bf21086b75bf6361f30b
BLAKE2b-256 checksum
How to use checksums
760962a9e7134555281ee0fccaecc7dffaae7923d8a8141b689bc5f680085b69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.12

Security for magolib 0.0.1

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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page