Skip to main content

Frequenz Quantities Library

Build Status PyPI Package Docs

Introduction

This library provide types for holding quantities with units. The main goal is to avoid mistakes while working with different types of quantities, for example avoiding adding a length to a time.

It also prevents mistakes when operating between the same quantity but in different units, like adding a power in Joules to a power in Watts without converting one of them.

Quantities store the value in a base unit, and then provide methods to get that quantity as a particular unit.

Installation

Using pip

python3 -m pip install frequenz-quantities

Using pyproject.toml

Add this to your pyproject.toml file:

[project]
dependencies = [
    "frequenz-quantities >= 1.0.0, < 2"
]

[!NOTE] We recommend pinning the dependency to the latest version for programs, like "frequenz-quantities == 1.0.0", and specifying a version range spanning one major version for libraries, like "frequenz-quantities >= 1.0.0, < 2". We follow semver.

Quick Start

from frequenz.quantities import Power, Current, Voltage

# Create quantities using unit-specific constructors
power = Power.from_watts(1500.0)
current = Current.from_amperes(10.0)
voltage = Voltage.from_volts(230.0)

# Perform operations between quantities
total_power = power + Power.from_kilowatts(2.0)
print(f"Total power: {total_power}")  # Total power: 3500 W

# Convert to different units
print(f"Power in kW: {total_power.as_kilowatts()}")  # Power in kW: 3.5

# Type safety prevents invalid operations
# This would raise a TypeError:
# invalid = power + current  # Can't add power and current!

Documentation

For more information on how to use this library and examples, please check the Documentation website.

Supported Platforms

The following platforms are officially supported (tested):

  • Python: 3.11
  • Operating System: Ubuntu Linux 20.04
  • Architectures: amd64, arm64

Contributing

If you want to know how to build this project and contribute to it, please check out the Contributing Guide.

Metadata

Release files for frequenz-quantities 1.0.3

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

Source distribution (sdist)

Source distribution for frequenz-quantities 1.0.3
File Size Uploaded
frequenz_quantities-1.0.3.tar.gz 20.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for frequenz-quantities 1.0.3
File Interpreter ABI Platform
frequenz_quantities-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 46.8 kB

Release files / frequenz_quantities-1.0.3.tar.gz

Download URL frequenz_quantities-1.0.3.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fc4d07571920fad561b07dfc2af1936f8479010abd4486c4bca1994f8b4fe1a0
BLAKE2b-256 checksum
How to use checksums
0819204081bd292ee8ffbcf220818176e012e46df14b7fb4017709e2f948194c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / frequenz_quantities-1.0.3-py3-none-any.whl

Download URL frequenz_quantities-1.0.3-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50f19e7ae91a062f6619a30fa561cc3df4a50d790064bc06e95dd6dcc34bfb85
BLAKE2b-256 checksum
How to use checksums
0bb063f07b0d66c60adfe5f6936e9408c8373d6969de7813c784ad8e4a0d0672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

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