magolib


Namemagolib JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryA library to format and convert numbers in the Mago unit of measure
upload_time2024-05-14 14:54:41
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseCopyright (c) 2024 Alessandro Sartori Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords mago unit of measure format convert
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

<p style="text-align:center">
    <img alt="Niccolò Marcon, the reference measure of a Mago" title="Niccolò Marcon, the reference measure of a Mago" src="mago.png" height="400px" />
</p>

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`:

```python
import magolib
```

Next, you can perform all these operations:

#### Convert meters to maghi

```python
>>> 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

```python
>>> 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

```python
>>> 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

```python
>>> 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

```python
>>> 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

```python
>>> 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 'â„ł'*

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "magolib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "mago, unit of measure, format, convert",
    "author": null,
    "author_email": "Alessandro Sartori <alex.sartori1997@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/84/54/496124609c2a124b78429cd2f9d1f98d7daef9056e52eb8db3efa37d637e/magolib-0.0.1.tar.gz",
    "platform": null,
    "description": "# MAGO-LIB\n\nA Python library to format, parse, and convert numbers from meters to maghi.\n\n## What's this, though?\n\n### Meters (= boring \ud83d\udc4e)\n\n> 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.\n>> 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.\n\nWhat 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.\n\n### Maghi (= helpful! \ud83d\udc4d)\n\nHow do you define a Mago? Simple enough! That's his height:\n\n<p style=\"text-align:center\">\n    <img alt=\"Niccol\u00f2 Marcon, the reference measure of a Mago\" title=\"Niccol\u00f2 Marcon, the reference measure of a Mago\" src=\"mago.png\" height=\"400px\" />\n</p>\n\nOf course, you'll have already figured the advantages of such unit of measurement:\n\n- Simple and immediate definition\n- The size of a Niccol\u00f2 is UNIVERSALLY known on Planet Earth\n- This Niccol\u00f2 has always existed and forever will\n- Its length is unchanged since the dawn of time and is extremely stable (contrary to a standard meter) to:\n  - Thermal variations\n  - Mechanical fatigue\n  - Aging and degradation\n  - Chemical stress\n  - Verbal abuse\n  - Intense math classes (up to 8 hours of continued exposure)\n  - Electromagnetic radiation\n  - Ionizing radiation (under testing)\n- If you dip a meter in Nutella it'll be ruined, a Mago will smile and thank you\n- Conversion between meters and maghi is very straightforward\n- A handy Python library is available to help migrate the world from metric to magic\n\n#### Conventions:\n\n- We denote a mago with the character: \u2133\n- One \u2133 equals approximately 1.93 meters\n- All the standard multiples and submultiples apply:\n  | Prefix | Name | Factor |\n  |---|---|---|\n  | p | pico | 1e-12 |\n  | n | nano | 1e-9 |\n  | \u00b5, u | micro | 1e-6 |\n  | m | milli | 1e-3 |\n  | c | centi | 1e-2 |\n  | d | deci | 1e-1 |\n  |  |  | 1e0 |\n  | da | deca | 1e1 |\n  | h | etto | 1e2 |\n  | k, K | kilo | 1e3 |\n  | M | mega | 1e6 |\n  | G | giga | 1e9 |\n  | T | tera | 1e12 |\n\n## Installation\n\nEnsure you have Python and Pip installed in your system and run:\n\n```\npip install magolib\n```\n\nAlternatively, you can clone this repository, `cd` into it, and run `pip install .`\n\n## Usage\n\nFirst off, import `magolib`:\n\n```python\nimport magolib\n```\n\nNext, you can perform all these operations:\n\n#### Convert meters to maghi\n\n```python\n>>> magolib.meters_to_maghi(1.0)\n0.5181347150259068\n>>> magolib.meters_to_maghi(-0.58)\n-0.3005181347150259\n>>> magolib.meters_to_maghi(2.3e4)\n11917.098445595855\n```\n\n#### Convert maghi to meters\n\n```python\n>>> magolib.maghi_to_meters(1.0)\n1.93\n>>> magolib.maghi_to_meters(-42.5)\n-82.02499999999999\n>>> magolib.maghi_to_meters(1.9e-2)\n0.03667\n```\n\n#### Format maghi as strings\n\n```python\n>>> magolib.format_maghi(1.0)\n'1.00 \u2133  (maghi)'\n>>> magolib.format_maghi(3.4e-10)\n'340.00 p\u2133  (picomaghi)'\n>>> magolib.format_maghi(23e6)\n'23.00 M\u2133  (megamaghi)'\n```\n\n#### Convert maghi subunits\n\n```python\n>>> magolib.convert_maghi(1.0, '', 'k')\n0.001\n>>> magolib.convert_maghi(5, 'h', '')\n500.0\n>>> magolib.convert_maghi(7.2, 'm', 'u')\n7200.000000000001\n```\n\n\n#### Parse meters from string\n\n```python\n>>> magolib.parse_meters('-2e3 km')\n-2000000.0\n>>> magolib.parse_meters('1 m')\n1.0\n>>> magolib.parse_meters('.3 dm')\n0.03\n>>> magolib.parse_meters('-2e3 km')\n-2000000.0\n```\n\n\n#### Parse maghi from string\n\n```python\n>>> magolib.parse_maghi('1\u2133')\n1.0\n>>> magolib.parse_maghi('1M')\n1.0\n>>> magolib.parse_maghi('3 mM')\n0.003\n```\n\n*Note: here for simplicity you can use an uppercase 'M' in place of the symbol '\u2133'*\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2024 Alessandro Sartori  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A library to format and convert numbers in the Mago unit of measure",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/AlexSartori/magolib",
        "Issues": "https://github.com/AlexSartori/magolib/issues",
        "Repository": "https://github.com/AlexSartori/magolib"
    },
    "split_keywords": [
        "mago",
        " unit of measure",
        " format",
        " convert"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "760962a9e7134555281ee0fccaecc7dffaae7923d8a8141b689bc5f680085b69",
                "md5": "14afbff96a8bd2a115afc6d6e855cf23",
                "sha256": "02ac40419ffe27ec40880f156b63c6404f333ff02c02bf21086b75bf6361f30b"
            },
            "downloads": -1,
            "filename": "magolib-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "14afbff96a8bd2a115afc6d6e855cf23",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6510,
            "upload_time": "2024-05-14T14:54:40",
            "upload_time_iso_8601": "2024-05-14T14:54:40.472468Z",
            "url": "https://files.pythonhosted.org/packages/76/09/62a9e7134555281ee0fccaecc7dffaae7923d8a8141b689bc5f680085b69/magolib-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8454496124609c2a124b78429cd2f9d1f98d7daef9056e52eb8db3efa37d637e",
                "md5": "21aea76a51b4eb054b25966168cc1479",
                "sha256": "ca08f5da7fd1e6376264585b147d837009e543f314b308be862623b397a10523"
            },
            "downloads": -1,
            "filename": "magolib-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "21aea76a51b4eb054b25966168cc1479",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7158,
            "upload_time": "2024-05-14T14:54:41",
            "upload_time_iso_8601": "2024-05-14T14:54:41.816201Z",
            "url": "https://files.pythonhosted.org/packages/84/54/496124609c2a124b78429cd2f9d1f98d7daef9056e52eb8db3efa37d637e/magolib-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-14 14:54:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AlexSartori",
    "github_project": "magolib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "magolib"
}
        
Elapsed time: 0.23385s