From e358322e99744c440c1b2c20ab573cf08a402369 Mon Sep 17 00:00:00 2001 From: nikohansen Date: Tue, 26 Jan 2016 13:45:01 +0100 Subject: [PATCH] DataSet.plot/plot_funvals for evals and funvals attribute improved/added modified: code-postprocessing/bbob_pproc/pproc.py --- code-postprocessing/bbob_pproc/pproc.py | 37 +++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/code-postprocessing/bbob_pproc/pproc.py b/code-postprocessing/bbob_pproc/pproc.py index abbea393d..5f9dda3de 100644 --- a/code-postprocessing/bbob_pproc/pproc.py +++ b/code-postprocessing/bbob_pproc/pproc.py @@ -595,6 +595,7 @@ class DataSet(): nbRuns pickle plot + plot_funvals precision readfinalFminusFtarget readmaxevals @@ -1336,14 +1337,34 @@ def _detEvals2(self, targets): return list(tmp[i][1:] for i in targets) - def plot(self): - for evals in self.evals[:, 1:].transpose(): # loop over the rows of the transposed array - idx = self.evals[:, 0] > 0 + def plot_funvals(self, **kwargs): + """plot data of `funvals` attribute, versatile""" + kwargs.setdefault('clip_on', False) + for funvals in self.funvals.T[1:]: # loop over the rows of the transposed array + idx = isfinite(funvals > 1e-19) + plt.loglog(self.funvals[idx, 0], funvals[idx], **kwargs) + plt.ylabel('target $\Delta f$ value') + plt.xlabel('number of function evaluations') + plt.xlim(1, max(self.maxevals)) + return plt.gca() + def plot(self, **kwargs): + """plot data from `evals` attribute. + + `**kwargs` is passed to `matplolib.loglog`. """ + kwargs.setdefault('clip_on', False) + for evals in self.evals.T[1:]: # loop over the rows of the transposed array + idx = np.logical_and(self.evals[:, 0] > 1e-19, isfinite(evals)) # plt.semilogx(self.evals[idx, 0], evals[idx]) - plt.loglog(self.evals[idx, 0], evals[idx]) - plt.gca().invert_xaxis() - plt.xlabel('target $\Delta f$ value') - plt.ylabel('number of function evaluations') + if 1 < 3: + plt.loglog(evals[idx], self.evals[idx, 0], **kwargs) + plt.ylabel('target $\Delta f$ value') + plt.xlabel('number of function evaluations') + plt.xlim(1, max(self.maxevals)) + else: # old version + plt.loglog(self.evals[idx, 0], evals[idx]) + plt.gca().invert_xaxis() + plt.xlabel('target $\Delta f$ value') + plt.ylabel('number of function evaluations') return plt.gca() @@ -1441,7 +1462,7 @@ def __init__(self, args=[], verbose=False, check_data_type=True): data_consistent = True for ds in self: data_consistent = data_consistent and ds.consistency_check() - if data_consistent and len(self): + if len(self) and data_consistent: print(" Data consistent according to test in consistency_check() in pproc.DataSet") def processIndexFile(self, indexFile, verbose=True):