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.2

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.2
File Size Uploaded
frequenz_quantities-1.0.2.tar.gz 20.5 kB Details

Built distribution (wheel)

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

Total release size: 46.7 kB

Release files / frequenz_quantities-1.0.2.tar.gz

Download URL frequenz_quantities-1.0.2.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cc7ef321365f12d9dd91455c30e19f6c25ca2d4855a071d23b2377da498fdec3
BLAKE2b-256 checksum
How to use checksums
80bdbd50139a566ff58c2aa8ae275fa660a71e195a0dfc81b0a7ae88be6aca8b
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 7, 2026.

Transparency log

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

Download URL frequenz_quantities-1.0.2-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d53a9f9982add409f3ae7e31510335212f645163054bfc8c779edb71598dca3c
BLAKE2b-256 checksum
How to use checksums
cf287f18b269b42231ff7460a0cf9714e924b5a8ce9fe6b4d5c5148e31451dcd
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 7, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.3

2 release files

This release

1.0.2 This release

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