Skip to main content

cyquant

simple, efficient dimensional analysis

basics

from cyquant import si, SIUnit

miles = SIUnit(1609.344) * si.meters
marathon_miles = 26 * miles
marathon_miles.quantity  # 26

marathon_meters = marathon_miles.cvt_to(si.meters)
marathon_meters.quantity  # 41842.944
marathon_meters.get_as(miles)  # 26
marathon_meters.get_as(si.newton_meters)  # ValueError
marathon_miles == marathon_meters  # True

approximation & tolerances

# absolute tolerance
marathon_miles.a_approx(marathon_meters, atol=1e-9)  # True

# relative tolerance
marathon_miles.r_approx(marathon_meters, rtol=1e-9)  # True

# quantity tolerance
marathon_miles.q_approx(marathon_meters, qtol=1 * si.millimeters)

normalized string output

from cyquant.format_quantity import show_quantity
show_quantity(marathon_miles)  # 4.184e+04 m

with attrs

from cyquant import si, converter
from cyquant import Quantity as Q
from attrs import define, field

@define
class Foo:
    mass: Q = field(converter=converter(si.kilograms, promotes=True))
    size: Q = field(converter=converter(si.meters ** 3))

    def liters(self):
        return self.size.get_as(si.liters)

foo1 = Foo(mass=10, size=1 * si.meters ** 3)
foo2 = Foo(mass=10 * si.kilograms, size=1000000000 * si.millimeters ** 3)
assert foo1 == foo2

foo3 = Foo(mass=10, size=10) # TypeError

Metadata

Release files for cyquantx 1.1.0

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

Source distribution (sdist)

Source distribution for cyquantx 1.1.0
File Size Uploaded Provenance Actions
cyquantx-1.1.0.tar.gz 429.9 kB Without provenance Details for cyquantx-1.1.0.tar.gz

Release files / cyquantx-1.1.0.tar.gz

Download URL cyquantx-1.1.0.tar.gz
Size 429.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7b481ca9dfbb86b9efb24c6e7db96d8e9da7eb52dc9e63fec48422c3a4bea9fe
BLAKE2b-256 checksum
How to use checksums
f0a29efa269e960f9fb67126b18aad2551394236c92f72c18f4290e062776f0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Security for cyquantx 1.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

1 release file No provenance

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