Skip to main content

A simple module with a selection of units to simple conversions, using library Pint.

Project description

myunits

PyPI - Version PyPI - Python Version

A simple module with a selection of units to simple conversions, using library pint

Installation

pip install myunits

Usage

Import all names from the module and make conversions:

>>> from myunits import *
...
>>> press = 1 * psi
>>> stress = 1 * MPa
>>> compressibility = 100e-6 * cm ** 2 / kgf
...
>>> print(
...     f"Pressure:\n    {press} = {press.to(kPa)}\n"
...     f"Stress:\n    {stress} = {stress.to(kgf / cm **2)}\n"
...     f"Compressibility:\n    {compressibility} = {compressibility.to(1/GPa)}\n"
>>> )
Pressure:
    1 pound_force_per_square_inch = 6.894757293168363 kilopascal
Stress:
    1 megapascal = 10.197162129779283 force_kilogram / centimeter ** 2
Compressibility:
    0.0001 centimeter ** 2 / force_kilogram = 1.0197162129779282 / gigapascal

The defined units are:

  • kg = kilogram
  • g = gram
  • mg = milligram
  • d = day
  • s = second
  • us = microsecond
  • m = meter
  • cm = centimeter
  • mm = millimeter
  • um = micrometer
  • ft = foot
  • bbl = oil_barrel
  • Pa = Pascal
  • kPa = kiloPascal
  • MPa = megaPascal
  • GPa = gigaPascal
  • psi = pound_force_per_square_inch
  • bar = bar
  • sip = 1.0 / pound_force_per_square_inch
  • rab = 1.0 / bar
  • microsip = 1e-06 / pound_force_per_square_inch
  • microrab = 1e-06 / bar
  • usip = 1e-06 / pound_force_per_square_inch
  • urab = 1e-06 / bar
  • K = Kelvin
  • R = degree_Rankine
  • oC = degree_Celsius
  • oF = degree_Fahrenheit
  • kgf = force_kilogram
  • N = Newton
  • daN = decaNewton
  • kN = kiloNewton
  • MN = megaNewton
  • GN = gigaNewton
  • D = Darcy
  • mD = miliDarcy
  • P = Poise
  • cP = centiPoise
  • J = Joule
  • kJ = kiloJoule
  • MJ = megaJoule
  • GJ = gigaJoule
  • W = Watt
  • kW = kiloWatt
  • MW = megaWatt
  • GW = gigaWatt

License

myunits is distributed under the terms of the MIT license.

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

myunits-0.3.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

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

myunits-0.3.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file myunits-0.3.0.tar.gz.

File metadata

  • Download URL: myunits-0.3.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for myunits-0.3.0.tar.gz
Algorithm Hash digest
SHA256 46a880aa4801b5470e91c414ea80aad2c3e77dd7466ae53a40a1abf17847e756
MD5 dffff43ce46a4c7747d0dc7b527b7922
BLAKE2b-256 164d5e2fe81fef2d5d2f3df0dd82dfcdf7929fe793b893f41c9a63cc57216726

See more details on using hashes here.

File details

Details for the file myunits-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: myunits-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for myunits-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93fdaf652753b9e37a120eecf316ac9ba7326f5aa28c5a851c1a6a4296975270
MD5 922eb3f6b6fb6919a044864d89ad3de5
BLAKE2b-256 68b3b1ea69ee797f6aff418d8727326f85be5e42bc843c1ad9e78aafa9189559

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