PUQ Python API
Unit-aware quantities, measurements, and unit systems.
- class scinumtools3.puq.Quantity
A numerical value with physical units and optional measurement uncertainty.
- convert(*args, **kwargs)
Overloaded function.
convert(self: scinumtools3._snt.puq.Quantity, expression: str, system: scinumtools3._snt.puq.systems.SystemType = <SystemType.NONE: 12>, quantity: str = ‘’) -> scinumtools3._snt.puq.Quantity
Convert to target units or a target unit-system expression.
convert(self: scinumtools3._snt.puq.Quantity, dformat: scinumtools3._snt.puq.formats.Dformat, system: scinumtools3._snt.puq.systems.SystemType = <SystemType.NONE: 12>) -> scinumtools3._snt.puq.Quantity
Convert using a base-dimension format and optional unit system.
- static correlate(left: scinumtools3._snt.puq.Quantity, right: scinumtools3._snt.puq.Quantity, coefficient: SupportsFloat | SupportsIndex) None
Set the correlation coefficient between two primitive uncertain quantities.
- static correlate_many(quantities: collections.abc.Sequence, covariance: collections.abc.Sequence[collections.abc.Sequence[SupportsFloat | SupportsIndex]]) None
Assign a covariance matrix to scalar primitive uncertain quantities.
- info(self: scinumtools3._snt.puq.Quantity) None
Print detailed information about the quantity.
- static monte_carlo(model: collections.abc.Callable, inputs: collections.abc.Sequence, distributions: object = None, samples: SupportsInt | SupportsIndex = 100000, seed: SupportsInt | SupportsIndex = 0, coverage: SupportsFloat | SupportsIndex = 0.95) scinumtools3._snt.puq.MonteCarloResult
Propagate scalar inputs through a model; returns mean, standard deviation, and central coverage interval.
- rebase_dimensions(self: scinumtools3._snt.puq.Quantity) scinumtools3._snt.puq.Quantity
Rebase the quantity dimensions.
- rebase_prefixes(self: scinumtools3._snt.puq.Quantity) scinumtools3._snt.puq.Quantity
Rebase units using the selected prefixes.
- static set_propagation_mode(mode: str) None
Set process-wide uncertainty propagation to ‘standard’ or ‘interval’.
- shape(self: scinumtools3._snt.puq.Quantity) list[int]
Return the shape of the stored value.
- size(self: scinumtools3._snt.puq.Quantity) int
Return the number of stored values.
- to_numpy(self: scinumtools3._snt.puq.Quantity) numpy.typing.NDArray[numpy.float64]
Return the quantity value as a NumPy array.
- to_string(self: scinumtools3._snt.puq.Quantity, format: scinumtools3._snt.puq.UnitFormat = <scinumtools3._snt.puq.UnitFormat object at 0x7b178c572cf0>) str
Format the quantity as text.
- uncertainty(self: scinumtools3._snt.puq.Quantity, numpy: bool = False) float | list[float] | numpy.typing.NDArray[numpy.float64]
Return uncertainty as a scalar, list, or NumPy array.
- unit_system(self: scinumtools3._snt.puq.Quantity) str
Return the quantity’s unit system.
- property units
Return the quantity’s units as text.
- value(self: scinumtools3._snt.puq.Quantity, numpy: bool = False) float | list[float] | numpy.typing.NDArray[numpy.float64]
Return the value as a scalar, list, or NumPy array.
- class scinumtools3.puq.UnitSystem
Context manager for changing the active unit system.
- enter(self: scinumtools3._snt.puq.UnitSystem) scinumtools3._snt.puq.UnitSystem
Enter the unit-system context.
- exit(self: scinumtools3._snt.puq.UnitSystem, arg0: object, arg1: object, arg2: object) None
Leave the unit-system context and restore the previous system.
- to_string(self: scinumtools3._snt.puq.UnitSystem) str
Return a textual description of the active unit system.