Skip to main content

PyCUC: A lightweight Python package for creating custom unit conversions.

Project description

Python Custom Unit Converter (PyCUC)

Downloads PyPI Python Version License

Python Custom Unit Converter (PyCUC) is an open-source package designed to simplify unit conversions in Python. With PyCUC, you can effortlessly create custom conversion factors, convert between units, and streamline calculations in various fields, such as physics, engineering, and scientific computing.

Key Features:

  • Custom Conversion Factors: Define your own conversion factors for unique units.

  • Flexible Unit Conversions: Convert between units with ease, using a simple and intuitive methods.

  • Lightweight: Minimal dependencies and optimized for performance.

  • Easy to Use: Simple installation and straightforward usage.

Google Colab

You can use the following code to run PyCUC in Google Colab:

Open In Colab

Installation

Install PyCUC with pip

import pycuc

# check version

print(pycuc.__version__)

Usage Example

  • CREATE A CUSTOM UNIT CONVERTER
# ! pressure

my_cuc_1 = pycuc.create_cuc(1, 'MPa')

# convert to Pa

print(my_cuc_1.convert('Pa'))

print(my_cuc_1.convert('bar'))

print(my_cuc_1.convert('kPa'))



# ! temperature

my_cuc_2 = pycuc.create_cuc(358, 'K')

# convert to K

print(my_cuc_2.convert('C'))

print(my_cuc_2.convert('F'))

print(my_cuc_2.convert('R'))
  • CONVERT FROM TO
# ! pressure

print(pycuc.convert_from_to(1, 'MPa', 'Pa'))

# ! temperature

print(pycuc.convert_from_to(358, 'K', 'C'))

print(pycuc.convert_from_to(25, 'C', 'K'))
  • CONVERT FROM TO (short format)
# ! pressure

print(pycuc.to(125, 'MPa => Pa'))

# ! temperature

print(pycuc.to(360, 'K => C'))

print(pycuc.to(250, 'C => K'))
  • DEFINE A NEW UNIT
# ! heat capacity unit: J/mol.K

my_cuc_3 = pycuc.create_cuc(25, 'J/mol.K')

# add custom

my_cuc_3.add_custom_unit('J/mol.K', 1)

my_cuc_3.add_custom_unit('kJ/mol.K', 1000)

# conversion

print(my_cuc_3.convert('J/mol.K'))

print(my_cuc_3.convert('kJ/mol.K'))
  • CHECK REFERENCE
# ! pressure

print(my_cuc_3.check_reference('pressure'))

# ! temperature

print(my_cuc_3.check_reference('temperature'))

# ! custom

print(my_cuc_3.check_reference('custom'))

FAQ

For any question, contact me on LinkedIn

Authors

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

pycuc-1.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

PyCUC-1.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file pycuc-1.1.0.tar.gz.

File metadata

  • Download URL: pycuc-1.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for pycuc-1.1.0.tar.gz
Algorithm Hash digest
SHA256 fef3e5f46dd6d48690908a0e7ca8951dc715fecd48dc65e27016d2bf2266a169
MD5 a16f0d103d5c99819f10f200a93b69f5
BLAKE2b-256 4d15b3283143fb46022a2c923cc46b7a86b18f82175ff26cc27090a7f6bce18a

See more details on using hashes here.

File details

Details for the file PyCUC-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: PyCUC-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for PyCUC-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f33587e1099b94c83be472902abaa95ec33eb290c57e68919f212366ea933b3
MD5 b506ae57dc147c3597dc69ab0e0ba7f8
BLAKE2b-256 184a36a9407839351737bcfd6362e1c3249e0c266f91d42537daca99cc50a03d

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