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.

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'))

print("-"*50)



# ! 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'))

print("-"*50)
  • 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'))

print("-"*50)
  • 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'))

print("-"*50)
  • 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.0.0.tar.gz (6.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.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycuc-1.0.0.tar.gz
  • Upload date:
  • Size: 6.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.0.0.tar.gz
Algorithm Hash digest
SHA256 19ebd35e3870be3c773e8dd7ce8cf39c653f220de508e0b069bcac4ba3ec8093
MD5 d16e3e940616e3db3f060fda0d98033b
BLAKE2b-256 ce485b137bdf95a4514b72378177c29ed32413881013ba89b473077ed8d0097c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyCUC-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f15034d6e6685eb44403e75751b4ffc6df545a3b612c39ea05cbe1be385a283
MD5 f6f3df45cf95e01c65705a51e717ce97
BLAKE2b-256 3df6778d1db99940190949de49d4f1c349f9fb875a5117791ab7c1ee69a5e3f2

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