A lightweight, flexible Python library for handling physical units
Project description
DimPyU
A lightweight, flexible Python library for handling physical units, supporting arithmetic operations, dimensional analysis, and smart conversions.
Features
- Intuitive Syntax:
10 * reg.kmorreg.parse("10 km") - Arithmetic: Add, substract, multiply, and divide quantities (
m/s,kg * m/s^2). - Conversions: Easily convert between compatible units (
val.to('km')). - SI Prefixes: Automatically handles prefixes like
micro,giga,nano(e.g.micrometer). - Numpy Support: Seamlessly works with Numpy arrays for high-performance calculations on vectors.
- Physical Constants: Includes standard constants like Speed of Light ($c$), Gravity ($g_0$), etc.
Installation
From Source (Local)
pip install .
From GitHub
You can install directly from your repository:
pip install git+https://github.com/YOUR_USERNAME/dimpyu.git
From PyPI (Coming working)
pip install dimpyu
Usage
from dimpyu import UnitRegistry
# Initialize registry (loads default units)
reg = UnitRegistry()
# 1. Simple Quantity Creation
distance = 10 * reg.km
time = 0.5 * reg.hr
speed = distance / time
print(speed) # 20.0 km / hr
print(speed.to('m/s')) # 5.555... m / s
# 2. String Parsing
q = reg.parse("50 kg * m / s^2")
print(q) # 50.0 kg m/s^2
print(q.to('N')) # 50.0 N
# 3. Array / Numpy Support
lengths = [1, 2, 3] * reg.meter
print(lengths.to('cm')) # [100., 200., 300.] centimeter
# 4. Physical Constants
from dimpyu import constants
energy = constants.h * constants.c / (500 * reg.nm)
print(energy.to('J'))
Project Structure
dimpyu/: Core package code.main.py: Demo script.fluid_mechanics_example.py: Example solution for a pump calculation.heat_transfer_example.py: Example solution for a heat transfer problem.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dimpyu-0.1.1.tar.gz
(11.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
dimpyu-0.1.1-py3-none-any.whl
(10.7 kB
view details)
File details
Details for the file dimpyu-0.1.1.tar.gz.
File metadata
- Download URL: dimpyu-0.1.1.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c31a7af2ae751dcad0988fb68cf9a9343ba39886a2e24bd14e58412892d7f28
|
|
| MD5 |
6a8f64c1bf5ce9f1f4f0bb33ee9f1a33
|
|
| BLAKE2b-256 |
3351b402f73d1b834494ec91b1bc7df7545a6fd5dec00a52ae3d0707dc438e51
|
File details
Details for the file dimpyu-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dimpyu-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2003dd42c6a20a27550d1181161f11b8b35809a64e0e60c654cba008d7ec1271
|
|
| MD5 |
749b13257d58145b324dbd3f1d7d3539
|
|
| BLAKE2b-256 |
b557b1debec3ed4a472d8f3cd13d9be173bf900a1005729595a4288cedc0fc7a
|