From 2d4a213046f3a70a1d84cb6e9fe680492bff7482 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Wed, 29 May 2024 23:37:44 -0700 Subject: [PATCH] stdlib: Make PyStat SimStat inherit from Group The SimStat Object is nothing more than a group of other SimStats and is therefore logically a group. With this, functionality can be shared more easily. Change-Id: I5dce23a02d5871e640b422654ca063e590b1429a --- src/python/m5/ext/pystats/group.py | 4 +--- src/python/m5/ext/pystats/simstat.py | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/python/m5/ext/pystats/group.py b/src/python/m5/ext/pystats/group.py index d37f39459a..7bdc5523c9 100644 --- a/src/python/m5/ext/pystats/group.py +++ b/src/python/m5/ext/pystats/group.py @@ -54,9 +54,7 @@ class Group(AbstractStat): str, Union["Group", Statistic, List["Group"], List["Statistic"]] ], ): - if type is None: - self.type = "Group" - else: + if type: self.type = type self.time_conversion = time_conversion diff --git a/src/python/m5/ext/pystats/simstat.py b/src/python/m5/ext/pystats/simstat.py index 06858bb9ad..ec8b68623e 100644 --- a/src/python/m5/ext/pystats/simstat.py +++ b/src/python/m5/ext/pystats/simstat.py @@ -32,22 +32,16 @@ from typing import ( Union, ) -from .abstract_stat import AbstractStat from .group import Group from .statistic import Statistic from .timeconversion import TimeConversion -class SimStat(AbstractStat): +class SimStat(Group): """ Contains all the statistics for a given simulation. """ - creation_time: Optional[datetime] - time_conversion: Optional[TimeConversion] - simulated_begin_time: Optional[Union[int, float]] - simulated_end_time: Optional[Union[int, float]] - def __init__( self, creation_time: Optional[datetime] = None, @@ -56,10 +50,10 @@ class SimStat(AbstractStat): simulated_end_time: Optional[Union[int, float]] = None, **kwargs: Dict[str, Union[Group, Statistic, List[Group]]] ): - self.creation_time = creation_time - self.time_conversion = time_conversion - self.simulated_begin_time = simulated_begin_time - self.simulated_end_time = simulated_end_time - - for key, value in kwargs.items(): - setattr(self, key, value) + super().__init__( + creation_time=creation_time, + time_conversion=time_conversion, + simulated_begin_time=simulated_begin_time, + simulated_end_time=simulated_end_time, + **kwargs + )