diff --git a/src/python/m5/ext/pystats/group.py b/src/python/m5/ext/pystats/group.py index 6e2da87dfc..680a5d547a 100644 --- a/src/python/m5/ext/pystats/group.py +++ b/src/python/m5/ext/pystats/group.py @@ -56,7 +56,7 @@ class Group(SerializableStat): time_conversion: Optional[TimeConversion] = None, **kwargs: Dict[ str, Union["Group", Statistic, List["Group"], List["Statistic"]] - ] + ], ): if type is None: self.type = "Group" @@ -140,6 +140,15 @@ class Group(SerializableStat): pattern = regex yield from self.children(lambda _name: bool(pattern.search(_name))) + def _repr_name(self) -> str: + return "Group" + + def __repr__(self) -> str: + stats_list = [] + for key in self.__dict__: + stats_list.append(key) + return f"{self._repr_name()}: {stats_list}" + class Vector(Group): """ @@ -152,3 +161,6 @@ class Vector(Group): def __init__(self, scalar_map: Mapping[str, Scalar]): super().__init__(type="Vector", time_conversion=None, **scalar_map) + + def _repr_name(self) -> str: + return "Vector" diff --git a/src/python/m5/ext/pystats/statistic.py b/src/python/m5/ext/pystats/statistic.py index 446c9ba346..b018060ddc 100644 --- a/src/python/m5/ext/pystats/statistic.py +++ b/src/python/m5/ext/pystats/statistic.py @@ -56,6 +56,9 @@ class Statistic(ABC, SerializableStat): self.description = description self.datatype = datatype + def __repr__(self): + return str(self.value) + class Scalar(Statistic): """