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.1.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.1-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file pint_cf-0.1.1.tar.gz.

File metadata

  • Download URL: pint_cf-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 d14570505731d9459e257de1b41fd914a4c5a9e9ca63b2bdc751225ae635e02e
MD5 070c217bd868db8251f72d48ada0e043
BLAKE2b-256 2e3eec88664cc32cb5dee3e13ca8e22da231df3b4960ef683a0cf9a12da3fffb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pint_cf-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pint_cf-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f16e42a70c4eb169b610776220b95058ed1f8f398de68f38c9c107b901054bb4
MD5 aef9a048dc9359ed5a6ae4db648d4b08
BLAKE2b-256 7f2f254c95eb5ab8a9c80edc7db7d9eb8b60b85110a73801b2b771495e4023fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pint_cf-0.1.1-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