stdlib: Fix PyStats Distribution to be vector of Scalars

As Distribution inherits from Vector, it should be constructed with
a Dictionary of scalars (in our implementation, a dictionary mapping the
vector position's unique id for each bin and the value of that bin).

Change-Id: Ie603c248e5db4b6dd7f71cc453eebd78793f69a3
This commit is contained in:
Bobby R. Bruce
2024-03-27 10:01:21 -07:00
parent 252dbe9c72
commit 940e1d2063
2 changed files with 10 additions and 2 deletions

View File

@@ -164,7 +164,7 @@ class Distribution(Vector):
def __init__(
self,
value: Iterable[int],
value: Dict[Union[int, float], Scalar],
min: Union[float, int],
max: Union[float, int],
num_bins: int,

View File

@@ -167,8 +167,16 @@ def __get_distribution(statistic: _m5.stats.DistInfo) -> Distribution:
overflow = statistic.overflow
logs = statistic.logs
parsed_values = {}
for index in range(len(value)):
parsed_values[index] = Scalar(
value=value[index],
unit=statistic.unit,
datatype=StorageType["f64"],
)
return Distribution(
value=value,
value=parsed_values,
min=min,
max=max,
num_bins=num_bins,