Skip to main content

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.

Metadata

Release files for metrological-quantity 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metrological-quantity 1.0.1
File Size Uploaded
metrological_quantity-1.0.1.tar.gz 29.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metrological-quantity 1.0.1
File Interpreter ABI Platform
metrological_quantity-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 58.7 kB

Release files / metrological_quantity-1.0.1.tar.gz

Download URL metrological_quantity-1.0.1.tar.gz
Size 29.8 kB
Tags Source
SHA-256 checksum
How to use checksums
09f481edc04f885e7243b5ff5d5977c8bda28f2fe1fa8183745a3278ad86220a
BLAKE2b-256 checksum
How to use checksums
a8b9163276ce5d3a2e43f739cf8257c7d14cd5786bdbf14bd41e3694c82cbfa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / metrological_quantity-1.0.1-py3-none-any.whl

Download URL metrological_quantity-1.0.1-py3-none-any.whl
Size 28.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
929364880a467ccd1012bc84942fd089ff05a47cca1fe7f8e86095cf7942c83d
BLAKE2b-256 checksum
How to use checksums
a5bc779c5eabfc9ab88117e7df450fb14a07b4c336ac4fd8508f242ab0f76970
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page