Lines Matching refs:self
191 def __init__(self, c_ctx=None, p_ctx=None):
193 self.c = C.getcontext() if c_ctx is None else c_ctx
194 self.p = P.getcontext() if p_ctx is None else p_ctx
195 self.p.prec = self.c.prec
196 self.p.Emin = self.c.Emin
197 self.p.Emax = self.c.Emax
198 self.p.rounding = self.c.rounding
199 self.p.capitals = self.c.capitals
200 self.settraps([sig for sig in self.c.traps if self.c.traps[sig]])
201 self.setstatus([sig for sig in self.c.flags if self.c.flags[sig]])
202 self.p.clamp = self.c.clamp
204 def __str__(self):
205 return str(self.c) + '\n' + str(self.p)
207 def getprec(self):
208 assert(self.c.prec == self.p.prec)
209 return self.c.prec
211 def setprec(self, val):
212 self.c.prec = val
213 self.p.prec = val
215 def getemin(self):
216 assert(self.c.Emin == self.p.Emin)
217 return self.c.Emin
219 def setemin(self, val):
220 self.c.Emin = val
221 self.p.Emin = val
223 def getemax(self):
224 assert(self.c.Emax == self.p.Emax)
225 return self.c.Emax
227 def setemax(self, val):
228 self.c.Emax = val
229 self.p.Emax = val
231 def getround(self):
232 assert(self.c.rounding == self.p.rounding)
233 return self.c.rounding
235 def setround(self, val):
236 self.c.rounding = val
237 self.p.rounding = val
239 def getcapitals(self):
240 assert(self.c.capitals == self.p.capitals)
241 return self.c.capitals
243 def setcapitals(self, val):
244 self.c.capitals = val
245 self.p.capitals = val
247 def getclamp(self):
248 assert(self.c.clamp == self.p.clamp)
249 return self.c.clamp
251 def setclamp(self, val):
252 self.c.clamp = val
253 self.p.clamp = val
262 def clear_traps(self):
263 self.c.clear_traps()
264 for trap in self.p.traps:
265 self.p.traps[trap] = False
267 def clear_status(self):
268 self.c.clear_flags()
269 self.p.clear_flags()
271 def settraps(self, lst):
273 self.clear_traps()
275 self.c.traps[signal] = True
276 self.p.traps[CondMap[signal]] = True
278 def setstatus(self, lst):
280 self.clear_status()
282 self.c.flags[signal] = True
283 self.p.flags[CondMap[signal]] = True
285 def assert_eq_status(self):
287 for signal in self.c.flags:
288 if self.c.flags[signal] == (not self.p.flags[CondMap[signal]]):
332 def __getattribute__(self, name):
335 return list.__getattribute__(self, name)
336 def unsupported(self, *_):
352 def __init__(self, funcname, operands):
354 self.funcname = funcname.replace("context.", "")
355 self.contextfunc = True
357 self.funcname = funcname
358 self.contextfunc = False
359 self.op = operands # raw operand tuple
360 self.context = context # context used for the operation
361 self.cop = RestrictedList() # converted C.Decimal operands
362 self.cex = RestrictedList() # Python exceptions for C.Decimal
363 self.cresults = RestrictedList() # C.Decimal results
364 self.pop = RestrictedList() # converted P.Decimal operands
365 self.pex = RestrictedList() # Python exceptions for P.Decimal
366 self.presults = RestrictedList() # P.Decimal results
371 self.with_maxcontext = False
372 self.maxcontext = context.c.copy()
373 self.maxcontext.prec = C.MAX_PREC
374 self.maxcontext.Emax = C.MAX_EMAX
375 self.maxcontext.Emin = C.MIN_EMIN
376 self.maxcontext.clear_flags()
378 self.maxop = RestrictedList() # converted C.Decimal operands
379 self.maxex = RestrictedList() # Python exceptions for C.Decimal
380 self.maxresults = RestrictedList() # C.Decimal results
392 def __init__(self):
393 self.ulpdiff = 0
394 self.powmod_zeros = 0
395 self.maxctx = P.Context(Emax=10**18, Emin=-10**18)
397 def default(self, t):
402 def harrison_ulp(self, dec):
408 def standard_ulp(self, dec, prec):
411 def rounding_direction(self, x, mode):
433 def check_ulpdiff(self, exact, rounded):
446 self.maxctx.prec = p * 2
447 t = self.maxctx.subtract(y, x)
451 ulp = self.harrison_ulp(y)
453 ulp = self.standard_ulp(y, p)
455 err = self.maxctx.divide(t, ulp)
457 dir = self.rounding_direction(x, context.p.rounding)
475 def bin_resolve_ulp(self, t):
483 self.maxctx.prec = context.p.prec * 2
487 exact = getattr(self.maxctx, t.funcname)(op1, op2)
489 exact = getattr(op1, t.funcname)(op2, context=self.maxctx)
494 self.ulpdiff += 1
495 return self.check_ulpdiff(exact, rounded)
498 def resolve_underflow(self, t):
516 def exp(self, t):
518 return self.resolve_underflow(t)
520 def log10(self, t):
522 return self.resolve_underflow(t)
524 def ln(self, t):
526 return self.resolve_underflow(t)
528 def __pow__(self, t):
535 return self.bin_resolve_ulp(t)
541 def __float__(self, t):
549 def __radd__(self, t):
559 def __round__(self, t):
678 operand (self) is always converted to Decimal. If 'convstr' is