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.0a2.tar.gz (27.5 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.0a2-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pint_cf-0.1.0a2.tar.gz
  • Upload date:
  • Size: 27.5 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.0a2.tar.gz
Algorithm Hash digest
SHA256 ad282546d7f9cac67df0d9d6eb87eaaa0cf6b62d8ce75819e0824ea4e282fd78
MD5 2d2fe166b9222a17a653b16d9b55ef24
BLAKE2b-256 e2d16c85476c821c8622e7df3ebf4c7712068d9d05edaadf533044f1f438769c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pint_cf-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 24.0 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.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 3e638ed9f12c61112c31d30166f04f9a6033647cba9a0915f867620816bcea38
MD5 4e0694a05767f88a03a19556752ed8f0
BLAKE2b-256 2f482c8de6d49ad281e745771e312a265f92309ea2788de83971bb2425f68555

See more details on using hashes here.

Provenance

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