diff options
author | Kapileshwar Singh <kapileshwarsingh@gmail.com> | 2015-12-07 16:29:43 +0000 |
---|---|---|
committer | Kapileshwar Singh <kapileshwarsingh@gmail.com> | 2015-12-07 16:29:43 +0000 |
commit | 03b31786ba6059157f625111615f12abd575853a (patch) | |
tree | ec797e98dd42dc725a1a982d6b0ab296995051c3 | |
parent | 9641dbd2abcaf67677ee4b94399c077b8c593f3a (diff) | |
parent | 8f65a403eead2df535a006c901264f6f6454eb61 (diff) | |
download | bart-03b31786ba6059157f625111615f12abd575853a.tar.gz |
Merge pull request #42 from JaviMerino/get_listify
bart: grow your own listify
-rw-r--r-- | bart/common/Utils.py | 10 | ||||
-rwxr-xr-x | bart/sched/SchedAssert.py | 3 | ||||
-rwxr-xr-x | bart/sched/SchedMatrix.py | 3 | ||||
-rwxr-xr-x | bart/sched/SchedMultiAssert.py | 3 |
4 files changed, 13 insertions, 6 deletions
diff --git a/bart/common/Utils.py b/bart/common/Utils.py index d9c90a8..137bf73 100644 --- a/bart/common/Utils.py +++ b/bart/common/Utils.py @@ -21,6 +21,16 @@ import numpy as np # pylint fails to recognize numpy members. # pylint: disable=no-member +def listify(to_select): + """Utitlity function to handle both single and + list inputs + """ + + if not isinstance(to_select, list): + to_select = [to_select] + + return to_select + def init_run(trace): """Initialize the Run Object diff --git a/bart/sched/SchedAssert.py b/bart/sched/SchedAssert.py index b3cadfc..f9d19f4 100755 --- a/bart/sched/SchedAssert.py +++ b/bart/sched/SchedAssert.py @@ -22,7 +22,6 @@ to aggregate statistics over processor hierarchies. import trappy import itertools import math -from trappy.plotter.Utils import listify from trappy.stats.Aggregator import MultiTriggerAggregator from trappy.stats import SchedConf as sconf from bart.common import Utils @@ -609,7 +608,7 @@ class SchedAssert(object): """ first_cpu = self.getFirstCpu(window=window) - cpus = listify(cpus) + cpus = Utils.listify(cpus) return first_cpu in cpus def generate_events(self, level, start_id=0, window=None): diff --git a/bart/sched/SchedMatrix.py b/bart/sched/SchedMatrix.py index 3a91fae..a01ad71 100755 --- a/bart/sched/SchedMatrix.py +++ b/bart/sched/SchedMatrix.py @@ -70,7 +70,6 @@ import trappy import numpy as np from trappy.stats.Aggregator import MultiTriggerAggregator from trappy.stats.Correlator import Correlator -from trappy.plotter.Utils import listify from trappy.stats import SchedConf as sconf from bart.common import Utils @@ -156,7 +155,7 @@ class SchedMatrix(object): run = Utils.init_run(trace) reference_run = Utils.init_run(reference_trace) - self._execnames = listify(execnames) + self._execnames = Utils.listify(execnames) self._reference_pids = self._populate_pids(reference_run) self._pids = self._populate_pids(run) self._dimension = len(self._pids) diff --git a/bart/sched/SchedMultiAssert.py b/bart/sched/SchedMultiAssert.py index 94feb56..94404d7 100755 --- a/bart/sched/SchedMultiAssert.py +++ b/bart/sched/SchedMultiAssert.py @@ -20,7 +20,6 @@ import re import inspect import trappy from trappy.stats import SchedConf as sconf -from trappy.plotter.Utils import listify from bart.sched.SchedAssert import SchedAssert from bart.common import Utils @@ -144,7 +143,7 @@ class SchedMultiAssert(object): if execnames and pids: raise ValueError('Either pids or execnames must be specified') if execnames: - self._execnames = listify(execnames) + self._execnames = Utils.listify(execnames) self._pids = self._populate_pids() elif pids: self._pids = pids |