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
This commit is contained in:
Bobby R. Bruce
2024-05-29 23:37:44 -07:00
parent 6d174c43e4
commit 2d4a213046
2 changed files with 9 additions and 17 deletions

View File

@@ -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

View File

@@ -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
)