PROPERTY
Overview
This class is an abstract Pydantic BaseModel designed to standardise the representation, validation, and serialisation of physical properties computed for materials. It is meant to be subclassed for concrete properties and integrates with mat_record and process in DeWorks.
Each subclass must implement:
- Validation of the value
- Serialisation logic
Attributes
| Field | Type | Description |
|---|---|---|
| value | any | The actual value of the physical property. Intentionally flexible to allow various data types |
| name | str | None | Name of the property Defaults to class name or property_type |
| property_type | str (frozen) | Identifies type of property. Defaults to the class name. fronzen = True to prevent mutation |
| override | bool | To allow setting values outside the recommended range. default: FalseHidden from represenation Marked as deprecated |
call()
Returns the raw value/
Validator
default_name(self)
Sets the self.name to property_type if not provided.
validate_value(self)
Validate the value parsed to the PROPERTY object t ensure that it has the correct type and format, within the accepted range, if applicable. This function should also account for the de-serialistaion of the value when loading from JSON or dict format
Serialization
serialize_value(self, value: any)
Transform the value into a JSON serializable object.
Display Methods
show_value(self)
Returns a dictionary containing a human-readable form of the property.
Extra information are to be put in a key named 'extra' in a str.
show(self, brief: bool = False)
Returns a Pandas DataFrame representation of the property.
- If brief is False, includes name and property_type.
- Always includes value and optional extra information
Deprecated Method
get(cls, host: MatRecord, **kwargs)
Class method to retrieve and instantiate the property object form a material record's history. Currently commented out