Source code for pydelfini.delfini_core.models.metrics_boolean

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="MetricsBoolean")


[docs] @_attrs_define class MetricsBoolean: """MetricsBoolean model Attributes: false_count (int): true_count (int): true_percentage (float): """ false_count: int true_count: int true_percentage: float
[docs] def to_dict(self) -> Dict[str, Any]: """Convert to a dict""" false_count = self.false_count true_count = self.true_count true_percentage = self.true_percentage field_dict: Dict[str, Any] = {} field_dict.update( { "falseCount": false_count, "trueCount": true_count, "truePercentage": true_percentage, } ) return field_dict
[docs] @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: """Create an instance of :py:class:`MetricsBoolean` from a dict""" d = src_dict.copy() false_count = d.pop("falseCount") true_count = d.pop("trueCount") true_percentage = d.pop("truePercentage") metrics_boolean = cls( false_count=false_count, true_count=true_count, true_percentage=true_percentage, ) return metrics_boolean