Skip to main content

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.km or reg.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


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.2.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

dimpyu-0.1.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file dimpyu-0.1.2.tar.gz.

File metadata

  • Download URL: dimpyu-0.1.2.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for dimpyu-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d48f07f0ba98b75e5c9c787d225b26722c78e011516bdf4243d1dade26dae3bf
MD5 01f5646dc192d82cccef766fce555935
BLAKE2b-256 57728b9bf70bc8519fdee711d57cb73c254d0435f0bd39d99eaecbfd70c6df85

See more details on using hashes here.

File details

Details for the file dimpyu-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dimpyu-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for dimpyu-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 618ecdb0fd913cc2269b45875b8f0d9d04a96170b1855b4335c5fcae4e1cd801
MD5 876182db61e4f869a8a28d5d252e058f
BLAKE2b-256 a0c2ead17ca364b77c60f7af575c7a92bdb7ee8961dfcf6120d547e20b4aaf38

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