Source code for ts_ids_core.schema.parameter

from __future__ import annotations

from typing_extensions import deprecated

from ts_ids_core.annotations import Nullable
from ts_ids_core.base.ids_element import IdsElement
from ts_ids_core.base.ids_field import IdsField
from ts_ids_core.schema.sample import ValueDataType


[docs] @deprecated( "Use ParameterRaw, which also records the unit of a numerical value as it was " "expressed in the primary data.", category=None, ) class Parameter(IdsElement): """A structure for capturing individual values with varying datatypes.""" key: str = IdsField(description="This is the property name.") value: str = IdsField( description="The original string value of the parameter from the raw file." ) value_data_type: ValueDataType = IdsField( description="This is the true type of the original value." ) string_value: Nullable[str] = IdsField( description=( "If string_value has a value, then numerical_value, numerical_value_unit " "and boolean_value have to be null." ) ) numerical_value: Nullable[float] = IdsField( description=( "If numerical_value has a value, then string_value and boolean_value " "have to be null." ) ) numerical_value_unit: Nullable[str] = IdsField( description="Unit for the numerical value." ) boolean_value: Nullable[bool] = IdsField( description=( "If boolean_value has a value, then numerical_value, " "numerical_value_unit and string_value have to be null." ) )
# ParameterRaw extends the deprecated class to keep the fields and validation of Parameter.
[docs] class ParameterRaw(Parameter): # pyright: ignore[reportDeprecated] """A structure for capturing individual values with varying datatypes, including the raw unit from the primary data.""" string_value: Nullable[str] = IdsField( description=( "If string_value has a value, then numerical_value, numerical_value_unit, " "raw_numerical_value_unit and boolean_value have to be null." ) ) boolean_value: Nullable[bool] = IdsField( description=( "If boolean_value has a value, then numerical_value, numerical_value_unit, " "raw_numerical_value_unit and string_value have to be null." ) ) raw_numerical_value_unit: Nullable[str] = IdsField( description="The raw, untransformed unit for the numerical value from the primary data." )