A package for units.
Project description
AllYourUnitAreBelongToUs
Installation
pip install ayuabtu
Usage
Creating quantities
Create quantities with a given unit:
>>> from ayuabtu.quantities import Length
>>> from ayuabtu.units import LengthUnit
>>> Length(2, LengthUnit.METER)
2 m
Or you can use the unit specific factory methods:
>>> from ayuabtu.quantities import Length
>>> Length.from_meters(2)
2 m
You can also access only the value with
>>> from ayuabtu.quantities import Length
>>> Length.from_meters(2).value
2
Converting units
You can convert a quantity to a quantity with another unit
>>> from ayuabtu.quantities import Length
>>> from ayuabtu.units import LengthUnit
>>> distance_metric = Length.from_meters(2)
>>> distance_metric.to_unit(LengthUnit.FOOT)
6.561679790026246 ft
If you just need the numeric value of the quantity, but expressed in another unit, use
>>> from ayuabtu.quantities import Length
>>> from ayuabtu.units import LengthUnit
>>> distance_metric = Length.from_meters(2)
>>> distance_metric.as_unit(LengthUnit.FOOT)
6.561679790026246
For this common usecase, there are also shorthand methods:
>>> from ayuabtu.quantities import Length
>>> distance_metric = Length.from_meters(2)
>>> distance_metric.feet()
6.561679790026246
Quantity arithmetics
Coming soon ...
Custom units
Coming soon ...
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
ayuabtu-0.0.3.tar.gz
(7.4 kB
view details)
Built Distribution
ayuabtu-0.0.3-py3-none-any.whl
(23.5 kB
view details)
File details
Details for the file ayuabtu-0.0.3.tar.gz
.
File metadata
- Download URL: ayuabtu-0.0.3.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff86e21eab627caf8b90ead5e0af58f78d8e1afc1840c37fa7aadff3a7dc57ba |
|
MD5 | 41e614b14022509560e10fc4ea3bda45 |
|
BLAKE2b-256 | c4533d77cd700ccbed4d0a9de493f68a6a1fda98023e46359aae620d4a1d3ffe |
File details
Details for the file ayuabtu-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: ayuabtu-0.0.3-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6eef651d1dc91c49d3188376e6ebae11385240d72a0a2adfca1d74516f9fd4f9 |
|
MD5 | e4663d3998e8ee563b45a213c8a9e03d |
|
BLAKE2b-256 | 8ab64e7b29ae956e456badb7b6a215174c6e344d0a534837f691ccd8e536d8e7 |