Skip to main content

Multi purpose unit conversion package

Project description

Maßlos unit conversion library

coverage version MIT License

Set of functions to convert between different units including metric and imperial

< Add an optional screenshot of your project below >

Table of Contents

Installation

On macOS and Linux:

$ python -m pip install masslos

On Windows:

PS> python -m pip install masslos

Execution / Usage

Here are a few examples of using the masslos library in your code:

from masslos import DistanceUnit, SpeedUnit, WeightUnit
w = WeightUnit()
s = SpeedUnit()
d = DistanceUnit()

# without specifying the decimal digits (default = 2)
dist_in_meter = d.convert(10, "yd", "m")
weight_in_kg = w.convert(11, "lbs", "kg")

print("Speed units:")
print(s.list_units())
# with specifying the decimal digits
dist_in_meter = d.convert(value=10, from_unit="yd", to_unit="m", ndigits=3)
weight_in_kg = w.convert(value=11, from_unit="lbs", to_unit="kg", ndigits=3)

Usage exampe of the new measure classes:

from masslos import Distance, Speed, Weight
w1 = Weight(5, "kg")
w2 = Weight(5000, "g")
s = Speed(55, "mph")
d = Distance(5, "km")

# equals
print(w1 == w2) # True: 5kg is the same as 5,000g
print(w1 == d)  # False: 5kg is NOT equal to 5km

# math
print(w1 + w2)  # 10kg
print(w2 - w1)  # 0g
print(s / 5)    # 11mph
print(d * 4)    # 20km

For more examples, please refer to the project's Wiki or documentation page.

Technologies

masslos uses the following technologies and tools:

Features

masslos currently has the following set of features:

  • Converting distances including
    • metric
    • imperial
    • astronomical
  • Converting weights including
    • metric
    • imperial
  • Converting speeds

Author

Andreas Haberl – # – develop@haberl-info.de

Change log

  • 0.2.3
    • feat: add Measure classes
    • feat: changing class names
      BREAKING CHANGE: use new class names
    • test: update/ammend
    • docs: update/complete docstrings
  • 0.2.2
    • fix: packaging
  • 0.2.1
    • feat: add Speed class
    • feat: changing to class based API
      BREAKING CHANGE: use instance methods instead of function calls
    • feat: add function "list_units"
    • test: updates
    • docs: update README.md
  • 0.2.0
    • feat: argument for precision of conversion
  • 0.1.0
    • First working version

License

masslos is distributed under the MIT license. See LICENSE for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

masslos-0.2.3.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

masslos-0.2.3-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file masslos-0.2.3.tar.gz.

File metadata

  • Download URL: masslos-0.2.3.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.14

File hashes

Hashes for masslos-0.2.3.tar.gz
Algorithm Hash digest
SHA256 8351155c240a59465c30ed7044b712dcd4810e284d4fbf1e10afaacb3137aa36
MD5 9c18f285133000917ce47eaec0cdeeee
BLAKE2b-256 59506592964cc3c1a305bb5569558b36a93886b16806fbfb7e87beb899fc439b

See more details on using hashes here.

File details

Details for the file masslos-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: masslos-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.14

File hashes

Hashes for masslos-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e2dc27ad30968406cc578f7d9f7425ae636f86bc50cf012af2acdc50ab16e117
MD5 583f8c92bfe91d21fe100986d8bdeff1
BLAKE2b-256 34093909e13c55b106c7f06bd8af8e8976e16b97aed0e65344d9d15edae73258

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page