Unit
Kind: Class
Domain: Expressions, units, and tolerances
Canonical import: from cadflow import Unit
Signature
class Unit(symbol: 'str', dimension: 'Dimension', scale_to_canonical: 'float') -> None
Description
Named unit with a scale to CadFlow's canonical numeric units.
Named unit with a scale to CadFlow's canonical numeric units.
Custom units are supported and serialize their symbol, dimension, and scale. Registered built-in units serialize as compact symbols.
Parameters
| Name | Type | Required | Default | Source description |
|---|---|---|---|---|
symbol | 'str' | yes | - | Not explicitly described in the source docstring. |
dimension | 'Dimension' | yes | - | Not explicitly described in the source docstring. |
scale_to_canonical | 'float' | yes | - | Not explicitly described in the source docstring. |
Returns
Type: None
The source docstring does not declare additional return semantics.
Errors
The source docstring does not declare a narrower exception contract. Invalid types, values, ownership, paths, or backend state may still raise the corresponding public error.
Data fields
| Name | Type | Default |
|---|---|---|
symbol | 'str' | required |
dimension | 'Dimension' | required |
scale_to_canonical | 'float' | required |
Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
from_canonical | method | (self, value: 'int | float') -> 'float' | See the member signature. |
from_dict | class method | (cls, data: 'Mapping[str, Any]') -> "'Unit'" | Rebuild a custom unit from its serialized definition. |
to_canonical | method | (self, value: 'int | float') -> 'float' | See the member signature. |
to_dict | method | (self) -> 'Dict[str, Any]' | See the member signature. |
Behavior and constraints
- Instances are immutable dataclass values; update workflows return a replacement value.
Import check
from cadflow import Unit