Source code for pydelfini.delfini_core.models.metrics_categorical_value
from typing import Any
from typing import Dict
from typing import Type
from typing import TypeVar
from attrs import define as _attrs_define
T = TypeVar("T", bound="MetricsCategoricalValue")
[docs]
@_attrs_define
class MetricsCategoricalValue:
"""MetricsCategoricalValue model
Attributes:
count (int):
percentage (float):
value (str):
"""
count: int
percentage: float
value: str
[docs]
def to_dict(self) -> Dict[str, Any]:
"""Convert to a dict"""
count = self.count
percentage = self.percentage
value = self.value
field_dict: Dict[str, Any] = {}
field_dict.update(
{
"count": count,
"percentage": percentage,
"value": value,
}
)
return field_dict
[docs]
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
"""Create an instance of :py:class:`MetricsCategoricalValue` from a dict"""
d = src_dict.copy()
count = d.pop("count")
percentage = d.pop("percentage")
value = d.pop("value")
metrics_categorical_value = cls(
count=count,
percentage=percentage,
value=value,
)
return metrics_categorical_value