Skip to main content

Measurement units conversion.

Project description

Python module to perform conversions between measurement units.

Usage example

>>> from unitc import unit_conversion
# Convert 1 kg to pounds
>>> unit_conversion(1, 'kg', 'lb')
2.204623
>>> unit_conversion(1, from_unit='kg', to_unit='lb')
2.204623

# If the conversion is done to or from SI units, they don't need to be specified explicitely
>>> unit_conversion(1, 'ft')  # Converts 1 ft to m
0.3047999902464003
>>> unit_conversion(1, to_unit='HP') # Converts 1 W to horse power (HP)
0.001341022

# Unit conversion works also with lists and arrays
>>> a = [1, 2, 3, 4, 5]
>>> unit_conversion(a, 'kPa', 'lbf/ft²')
array([ 20.88543648,  41.77087296,  62.65630944,  83.54174592, 104.42718239])

>>> b = np.array([2, 5, 8, 7])
>>> unit_conversion(b, 'kt', 'm/s')
array([1.02888947, 2.57222367, 4.11555787, 3.60111313])

# Input units can be specified in the input value as a string
>>> unit_conversion('4 g/cm³', to_unit='lb/in³')
0.14450917891460638

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

unitc-0.0.6.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

unitc-0.0.6-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file unitc-0.0.6.tar.gz.

File metadata

  • Download URL: unitc-0.0.6.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for unitc-0.0.6.tar.gz
Algorithm Hash digest
SHA256 61cd66e9451fce9f06b5501563ed8c8e8a34e497d911ab1b33b448dd2c000276
MD5 8f0da38baaa8627a751e1d379a609ebd
BLAKE2b-256 8e5c7fd542074556ee1935a7842774f48bfdef9873acc2947efc2ef3cffff304

See more details on using hashes here.

File details

Details for the file unitc-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: unitc-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for unitc-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 58022a414dc19d2c6e17d2d401ff9e0c7a1ef0336b67f182fc6b7d1974670345
MD5 5d38f289479b39b7d5621f448e6653b2
BLAKE2b-256 277728191e0e60b7620071d7745c4893bf6bb0becfa0a2c71821a19e448f2bee

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