diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index 41c61985..9868a5c1 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -402,7 +402,7 @@ class Corr: if plateau: if isinstance(plateau, Obs): - ax1.axhline(y=plateau.value, linewidth=2, color=plt.rcParams['text.color'], alpha=0.6, marker=',', ls='--', label=plateau.__repr__()[4:-1]) + ax1.axhline(y=plateau.value, linewidth=2, color=plt.rcParams['text.color'], alpha=0.6, marker=',', ls='--', label=plateau.__repr__()) ax1.axhspan(plateau.value - plateau.dvalue, plateau.value + plateau.dvalue, alpha=0.25, color=plt.rcParams['text.color'], ls='-') else: raise Exception('plateau must be an Obs') @@ -451,7 +451,7 @@ class Corr: else: content_string += str(i + range[0]) for element in sub_corr: - content_string += '\t' + element.__repr__()[4:-1] + content_string += '\t' + element.__repr__() content_string += '\n' return content_string diff --git a/pyerrors/pyerrors.py b/pyerrors/pyerrors.py index 65613ee8..5b0dfb95 100644 --- a/pyerrors/pyerrors.py +++ b/pyerrors/pyerrors.py @@ -474,14 +474,17 @@ class Obs: def __repr__(self): if self.dvalue == 0.0: - return 'Obs[' + str(self.value) + ']' + return str(self.value) fexp = np.floor(np.log10(self.dvalue)) if fexp < 0.0: - return 'Obs[{:{form}}({:2.0f})]'.format(self.value, self.dvalue * 10 ** (-fexp + 1), form='.' + str(-int(fexp) + 1) + 'f') + return '{:{form}}({:2.0f})'.format(self.value, self.dvalue * 10 ** (-fexp + 1), form='.' + str(-int(fexp) + 1) + 'f') elif fexp == 0.0: - return 'Obs[{:.1f}({:1.1f})]'.format(self.value, self.dvalue) + return '{:.1f}({:1.1f})'.format(self.value, self.dvalue) else: - return 'Obs[{:.0f}({:2.0f})]'.format(self.value, self.dvalue) + return '{:.0f}({:2.0f})'.format(self.value, self.dvalue) + + def __str__(self): + return 'Obs[' + str(self) + ']' # Overload comparisons def __lt__(self, other):