From: Jiri Hubacek Date: Fri, 21 Sep 2018 07:13:56 +0000 (+0200) Subject: Add get latst/maxs functions to gplot X-Git-Tag: v0.2.0~34 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hubacji1/iamcar.git/commitdiff_plain/277bd7ffafc35e918d81aceba4ad3cd2157574f6 Add get latst/maxs functions to gplot Function `get_lasts_if_exist` returns the list of last values of some element of trajectory (i. e. *cost*). Function `get_maxs_if_exist` return the list of maximum values of some element of trajectory (i. e. *cost*). --- diff --git a/gplot.py b/gplot.py index abc9e90..c3e89e3 100644 --- a/gplot.py +++ b/gplot.py @@ -67,6 +67,36 @@ def count_if_exist(trajectories, what): pass return occ +def get_lasts_if_exist(trajectories, what): + """From multiple trajectories get the list of last values. + + Keyword arguments: + trajectories -- The list of trajectories. + what -- The last values of what to take. + """ + val = [] + for t in trajectories: + try: + val.append(t[what][-1]) + except: + val.append(9999) + return val + +def get_maxs_if_exist(trajectories, what): + """From multiple trajectories get the list of maximum values. + + Keyword arguments: + trajectories -- The list of trajectories. + what -- The maximum values of what to take. + """ + val = [] + for t in trajectories: + try: + val.append(max(t[what])) + except: + val.append(9999) + return val + def plot_successrate(): """Plot success rate of single/multi-core implementations.""" LOGF="logs_sq"