Skip to content

Commit 3a23873

Browse files
committed
EHN: return labfloat with correct error in round method
1 parent b2ed759 commit 3a23873

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

labfis/uncertainty.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,20 @@ def list(cls, listargs):
147147
def __round__(self, p=0):
148148
current_contex = getcontext()
149149
setcontext(self.context)
150-
150+
151151
u = Decimal(self._uncertainty)
152152
m = Decimal(self._mean)
153153

154-
p += -u.adjusted()*(not p)
154+
p += -u.adjusted() * (not p)
155155

156156
u = round(u, p)
157+
u += Decimal("1e{}".format(-p)) * (not u)
158+
157159
m = round(m, p)
158-
160+
159161
setcontext(current_contex)
160162

161-
return m, u
163+
return labfloat(type(self._mean)(m), type(self._uncertainty)(u))
162164

163165
def split(self):
164166
m, u = self.__round__()

0 commit comments

Comments
 (0)