mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-07-01 17:29:27 +02:00
__repr__ of Obs changed to more convenient form
This commit is contained in:
parent
5f1fb285f5
commit
ea51df3719
2 changed files with 9 additions and 6 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue