summaryrefslogtreecommitdiff
path: root/lib/dfatool.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-10-07 16:38:46 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-10-07 16:38:46 +0200
commit5d0fdb101f3c23b3df1b5ab9cb2c85dd41edb25f (patch)
treecae9f63e238374403f54f7b4ff8dd184b9856a40 /lib/dfatool.py
parenteb634401bfa4f93154eeb6265f100fd9db2bf7d4 (diff)
Move codependent parameter logic to ParamStats / parameters.py
Diffstat (limited to 'lib/dfatool.py')
-rwxr-xr-xlib/dfatool.py48
1 files changed, 2 insertions, 46 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py
index 3151c65..cc07026 100755
--- a/lib/dfatool.py
+++ b/lib/dfatool.py
@@ -16,7 +16,8 @@ from automata import PTA
from functions import analytic
from functions import AnalyticFunction
from parameters import ParamStats
-from utils import vprint, is_numeric, soft_cast_int, param_slice_eq, remove_index_from_tuple, is_power_of_two
+from utils import vprint, is_numeric, soft_cast_int, param_slice_eq, remove_index_from_tuple
+from utils import by_name_to_by_param
arg_support_enabled = True
@@ -180,26 +181,6 @@ class KeysightCSV:
currents[i] = float(row[2]) * -1
return timestamps, currents
-def by_name_to_by_param(by_name: dict):
- """
- Convert aggregation by name to aggregation by name and parameter values.
- """
- by_param = dict()
- for name in by_name.keys():
- for i, parameters in enumerate(by_name[name]['param']):
- param_key = (name, tuple(parameters))
- if param_key not in by_param:
- by_param[param_key] = dict()
- for key in by_name[name].keys():
- by_param[param_key][key] = list()
- by_param[param_key]['attributes'] = by_name[name]['attributes']
- # special case for PTA models
- if 'isa' in by_name[name]:
- by_param[param_key]['isa'] = by_name[name]['isa']
- for attribute in by_name[name]['attributes']:
- by_param[param_key][attribute].append(by_name[name][attribute][i])
- return by_param
-
def _xv_partitions_kfold(length, num_slices):
pairs = []
@@ -1403,31 +1384,6 @@ def _add_trace_data_to_aggregate(aggregate, key, element):
for datakey, dataval in element['offline_aggregates'].items():
aggregate[key][datakey].extend(dataval)
-def filter_aggregate_by_param(aggregate, parameters, parameter_filter):
- """
- Remove entries which do not have certain parameter values from `aggregate`.
-
- :param aggregate: aggregated measurement data, must be a dict conforming to
- aggregate[state or transition name]['param'] = (first parameter value, second parameter value, ...)
- and
- aggregate[state or transition name]['attributes'] = [list of keys with measurement data, e.g. 'power' or 'duration']
- :param parameters: list of parameters, used to map parameter index to parameter name. parameters=['foo', ...] means 'foo' is the first parameter
- :param parameter_filter: [[name, value], [name, value], ...] list of parameter values to keep, all others are removed. Values refer to normalizad parameter data.
- """
- for param_name_and_value in parameter_filter:
- param_index = parameters.index(param_name_and_value[0])
- param_value = soft_cast_int(param_name_and_value[1])
- names_to_remove = set()
- for name in aggregate.keys():
- indices_to_keep = list(map(lambda x: x[param_index] == param_value, aggregate[name]['param']))
- aggregate[name]['param'] = list(map(lambda iv: iv[1], filter(lambda iv: indices_to_keep[iv[0]], enumerate(aggregate[name]['param']))))
- for attribute in aggregate[name]['attributes']:
- aggregate[name][attribute] = aggregate[name][attribute][indices_to_keep]
- if len(aggregate[name][attribute]) == 0:
- names_to_remove.add(name)
- for name in names_to_remove:
- aggregate.pop(name)
-
def pta_trace_to_aggregate(traces, ignore_trace_indexes = []):
u"""