Skip to main content

CF-compliant unit registry and formatter for Pint

Project description

pint-cf

This package extends Pint with a CF-compliant unit registry and formatter.

Features

This package provides:

  • A CF-compliant Pint UnitRegistry, with explicit plurals.
  • A custom formatter cf, supporting both long and short (symbol) formats.

Known limitations:

  • Pint does not support time coordinates (e.g. days since 2001-01-01) or climate calendars (e.g., 360_days). Consider using cftime for that.
  • Pint does not support scaling factors in Unit expressions (e.g. pint.Unit('0.1 m')). You can work around this by adding your own unit definition.

Usage

Create a CF-ready unit registry with cf_unitregistry(). This function also registers the cf formatter.

from pint_cf import cf_unitregistry

ureg = cf_unitregistry()
print(type(ureg))  # <class 'pint.registry.UnitRegistry'>

q = ureg('10 meters per second^2').to('km s-2')

print(f"{q:cf}")   # 0.01 kilometer-second^-2
print(f"{q:~cf}")  # 0.01 km/s2

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

pint_cf-0.1.0a3.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

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

pint_cf-0.1.0a3-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file pint_cf-0.1.0a3.tar.gz.

File metadata

  • Download URL: pint_cf-0.1.0a3.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pint_cf-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 9d847a18143583a8645d5c03593d240be8bb88f3a00d483baf55c38ce79cc26c
MD5 f3793546238340176d45596c2671e097
BLAKE2b-256 585105ea58c1a02818214ed8417bab3a64adc8f11f9d2f7126ea4760d02ee017

See more details on using hashes here.

Provenance

The following attestation bundles were made for pint_cf-0.1.0a3.tar.gz:

Publisher: python-publish.yml on pgamez/pint-cf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pint_cf-0.1.0a3-py3-none-any.whl.

File metadata

  • Download URL: pint_cf-0.1.0a3-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pint_cf-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 3cfe757a38ebbb3e81db0221bd9868a5a58bf46a675798c5920f671b6e6d5851
MD5 0b318a648e3dea2d61cee14ac2a65e6f
BLAKE2b-256 7beb2813815b44c78502ea7689c7b463be1642738e4aadf6f2d0247371f72cb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pint_cf-0.1.0a3-py3-none-any.whl:

Publisher: python-publish.yml on pgamez/pint-cf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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