weldx.utility.
ureg_check_class
Decorate class __init__ function with pint.UnitRegistry.check.
__init__
pint.UnitRegistry.check
Useful for adding unit checks to classes created with @dataclass decorator.
@dataclass
args (str or pint.util.UnitsContainer or None) – Dimensions of each of the input arguments. Use None to skip argument conversion.
None
The class with unit checks added to its __init__ function.
type
TypeError – If number of given dimensions does not match the number of function parameters.
ValueError – If the any of the provided dimensions cannot be parsed as a dimension.
Examples
A simple dataclass could look like this:
@ureg_check_class("[length]","[time]") @dataclass class A: a: pint.Quantity b: pint.Quantity A(Q_(3,"mm"),Q_(3,"s"))