Source code for src.quality.rd_result

from dataclasses import asdict, dataclass
from typing import Any, Dict, Tuple


[docs] @dataclass(frozen=True) class RDResult: bpp: float min: float max: float mean: float stddev: float def __getitem__(self, key: str) -> Any: """Gets an attribute by key. :param key: Attribute name :type key: str :return: Attribute value :rtype: Any """ return getattr(self, key) def __iter__(self): return iter(self.__dataclass_fields__) def __len__(self) -> int: return len(self.__dataclass_fields__)
[docs] def asdict(self, exclude: Tuple = ()) -> Dict: """Converts the RDResult to a dictionary, excluding specified keys. :param exclude: Tuple of keys to exclude, defaults to () :type exclude: Tuple, optional :return: Dictionary representation :rtype: Dict """ return {k: v for k, v in asdict(self).items() if k not in exclude}