Skip to main content

Simple arithmetic operations with quantities including units and uncertainties

Project description

metrological-quantity

Basic arithmetic operations with uncertainty and units

Overview

metrological-quantity is a Python package for performing arithmetic operations on physical quantities, including support for units and propagation of uncertainties. It is designed for scientific, engineering, and educational applications where measurement uncertainty and unit consistency are important.

Features

  • Create quantities with values, uncertainties, and units
  • Automatic propagation of uncertainties in arithmetic operations
  • Support for addition, subtraction, multiplication, and division
  • Human-readable and machine-readable representations
  • Error handling for invalid operations (e.g., mismatched units)

Installation

Install with pip:

pip install metrological-quantity

Usage Example

from metrological_quantity import Quantity

# Create quantities
length = Quantity(10, 0.5, 'm')
width = Quantity(5, 0.2, 'm')

# Arithmetic operations
perimeter = 2 * (length + width)
area = length * width

print('Perimeter:', perimeter)
print('Area:', area)

# Uncertainty propagation
mass1 = Quantity(5, 0.1, 'kg')
mass2 = Quantity(7, 0.2, 'kg')
total_mass = mass1 + mass2
print('Total mass:', total_mass)

API Reference

Quantity

Quantity(value, uncertainty, unit, relative_uncertainty=False)
  • value: numerical value
  • uncertainty: absolute or relative uncertainty
  • unit: string representing the unit (e.g., 'm', 'kg')
  • relative_uncertainty: if True, interprets uncertainty as relative

Properties

  • relative_uncertainty: returns the relative uncertainty
  • percentage_uncertainty: returns the percentage uncertainty

Methods

  • __add__, __sub__, __mul__, __truediv__: arithmetic operations with uncertainty propagation

License

This project is licensed under the GNU General Public License.

Contributing

Contributions, issues, and feature requests are welcome! Please open an issue or submit a pull request.

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

metrological_quantity-1.0.1.tar.gz (29.8 kB view details)

Uploaded Source

Built Distribution

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

metrological_quantity-1.0.1-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file metrological_quantity-1.0.1.tar.gz.

File metadata

  • Download URL: metrological_quantity-1.0.1.tar.gz
  • Upload date:
  • Size: 29.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for metrological_quantity-1.0.1.tar.gz
Algorithm Hash digest
SHA256 09f481edc04f885e7243b5ff5d5977c8bda28f2fe1fa8183745a3278ad86220a
MD5 7b846089018158a2183f1590d1ac8050
BLAKE2b-256 a8b9163276ce5d3a2e43f739cf8257c7d14cd5786bdbf14bd41e3694c82cbfa9

See more details on using hashes here.

File details

Details for the file metrological_quantity-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for metrological_quantity-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 929364880a467ccd1012bc84942fd089ff05a47cca1fe7f8e86095cf7942c83d
MD5 db01cef8ec1b985653bf9bca364a96e5
BLAKE2b-256 a5bc779c5eabfc9ab88117e7df450fb14a07b4c336ac4fd8508f242ab0f76970

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