From 858a3553969697608ad740a0ac9711f109432e3d Mon Sep 17 00:00:00 2001 From: mzwiessele Date: Wed, 30 Sep 2015 18:14:33 +0100 Subject: [PATCH] [plotting] py3 compatibility, is it right, that relative imports always have to be in the format from . import <.> --- GPy/core/model.py | 4 ++-- GPy/core/parameterization/parameterized.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/GPy/core/model.py b/GPy/core/model.py index 8c00667e..42b8287a 100644 --- a/GPy/core/model.py +++ b/GPy/core/model.py @@ -422,7 +422,7 @@ class Model(Parameterized): to_print.append(super(Model, self)._repr_html_()) return "\n".join(to_print) - def __str__(self): + def __str__(self, VT100=True): model_details = [['Name', self.name], ['Log-likelihood', '{}'.format(float(self.log_likelihood()))], ["Number of Parameters", '{}'.format(self.size)], @@ -432,6 +432,6 @@ class Model(Parameterized): from operator import itemgetter max_len = reduce(lambda a, b: max(len(b[0]), a), model_details, 0) to_print = [""] + ["{0:{l}} : {1}".format(name, detail, l=max_len) for name, detail in model_details] + ["Parameters:"] - to_print.append(super(Model, self).__str__()) + to_print.append(super(Model, self).__str__(VT100=VT100)) return "\n".join(to_print) diff --git a/GPy/core/parameterization/parameterized.py b/GPy/core/parameterization/parameterized.py index 7f67c497..8378b4ce 100644 --- a/GPy/core/parameterization/parameterized.py +++ b/GPy/core/parameterization/parameterized.py @@ -405,7 +405,7 @@ class Parameterized(Parameterizable): """ return style + '\n' + '' + '\n'.format(sep).join(to_print) + '\n
' - def __str__(self, header=True): + def __str__(self, header=True, VT100=True): name = adjust_name_for_printing(self.name) + "." constrs = self._constraints_str; ts = self._ties_str @@ -416,7 +416,10 @@ class Parameterized(Parameterizable): cl = max([len(str(x)) if x else 0 for x in constrs + ["Constraint"]]) tl = max([len(str(x)) if x else 0 for x in ts + ["Tied to"]]) pl = max([len(str(x)) if x else 0 for x in prirs + ["Prior"]]) - format_spec = " \033[1m{{name:<{0}s}}\033[0;0m | {{desc:>{1}s}} | {{const:^{2}s}} | {{pri:^{3}s}} | {{t:^{4}s}}".format(nl, sl, cl, pl, tl) + if VT100: + format_spec = " \033[1m{{name:<{0}s}}\033[0;0m | {{desc:>{1}s}} | {{const:^{2}s}} | {{pri:^{3}s}} | {{t:^{4}s}}".format(nl, sl, cl, pl, tl) + else: + format_spec = " {{name:<{0}s}} | {{desc:>{1}s}} | {{const:^{2}s}} | {{pri:^{3}s}} | {{t:^{4}s}}".format(nl, sl, cl, pl, tl) to_print = [] for n, d, c, t, p in zip(names, desc, constrs, ts, prirs): to_print.append(format_spec.format(name=n, desc=d, const=c, t=t, pri=p))