Float
- class Float
Bases:
CommonBaseModel
Represents a floating-point number with enhanced attributes for engineering applications.
- value
The actual floating-point value.
- Type:
float
- units
Units of the variable, allowing for dimensional analysis.
- Type:
str
- description
A brief description of the variable.
- Type:
Optional[str]
- default
Default floating-point value of the variable, if any.
- Type:
Optional[float]
- Raises:
ValidationError – If the input value does not meet the validation criteria.
Attributes Summary
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Methods Summary
validate_default
(value, values)Validate and convert the default value to a float if it's provided as a string.
Attributes Documentation
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'protected_namespaces': (), 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Methods Documentation
- classmethod validate_default(value, values)
Validate and convert the default value to a float if it’s provided as a string.
- Parameters:
value (float | None) – The default value being validated.
values (dict) – The dictionary containing the field values.
- Returns:
The validated default value.
- Raises:
ValueError – If the default value is a string that cannot be converted to a float.
- Return type:
float | None
Methods:
validate_default
(value, values)Validate and convert the default value to a float if it's provided as a string.
Attributes:
__setattr__ handlers.
- classmethod validate_default(value, values)
Validate and convert the default value to a float if it’s provided as a string.
- Parameters:
value (float | None) – The default value being validated.
values (dict) – The dictionary containing the field values.
- Returns:
The validated default value.
- Raises:
ValueError – If the default value is a string that cannot be converted to a float.
- Return type:
float | None
- __pydantic_setattr_handlers__: ClassVar[Dict[str, Callable[[BaseModel, str, Any], None]]] = {}
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__