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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user