[Python-checkins] python/dist/src/Lib decimal.py,1.4,1.5

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sat Jul 3 09:49:05 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13623

Modified Files:
	decimal.py 
Log Message:
Namespace cleanups:
* delete temporary globals immediately after use
* move a global into a class variable
* Rename BasicDefaultContext and ExtendedDefaultContext
  to BasicContext and ExtendedContext.



Index: decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** decimal.py	3 Jul 2004 12:26:21 -0000	1.4
--- decimal.py	3 Jul 2004 13:48:56 -0000	1.5
***************
*** 121,125 ****
  
      # Contexts
!     'DefaultContext', 'BasicDefaultContext', 'ExtendedDefaultContext',
  
      # Exceptions
--- 121,125 ----
  
      # Contexts
!     'DefaultContext', 'BasicContext', 'ExtendedContext',
  
      # Exceptions
***************
*** 148,152 ****
  import math
  import operator
- xor = operator.xor
  
  #Exponent Range
--- 148,151 ----
***************
*** 163,167 ****
  ROUND_HALF_DOWN = 'half_down'
  
! #Rounding decision
  NEVER_ROUND = 'never'    # Round in division (non-divmod), sqrt ONLY
  ALWAYS_ROUND = 'always'  # Every operation rounds at end.
--- 162,166 ----
  ROUND_HALF_DOWN = 'half_down'
  
! #Rounding decision (not part of the public API)
  NEVER_ROUND = 'never'    # Round in division (non-divmod), sqrt ONLY
  ALWAYS_ROUND = 'always'  # Every operation rounds at end.
***************
*** 1051,1055 ****
              return ans
  
!         resultsign = xor(self._sign, other._sign)
          if self._isinfinity():
              if not other:
--- 1050,1054 ----
              return ans
  
!         resultsign = operator.xor(self._sign, other._sign)
          if self._isinfinity():
              if not other:
***************
*** 1145,1149 ****
                  return ans
  
!         sign = xor(self._sign, other._sign)
          if not self and not other:
              if divmod:
--- 1144,1148 ----
                  return ans
  
!         sign = operator.xor(self._sign, other._sign)
          if not self and not other:
              if divmod:
***************
*** 2114,2118 ****
      Decimal._pick_rounding_function[val] = name
  
! DefaultLock = threading.Lock()
  
  class Context(object):
--- 2113,2117 ----
      Decimal._pick_rounding_function[val] = name
  
! del name, val, globalname, rounding_functions
  
  class Context(object):
***************
*** 2136,2139 ****
--- 2135,2141 ----
      clamp - If 1, change exponents if too high (Default 0)
      """
+ 
+     DefaultLock = threading.Lock()
+ 
      def __init__(self, prec=None, rounding=None,
                   trap_enablers=None, flags=None,
***************
*** 2144,2148 ****
          if flags is None:
              flags = dict.fromkeys(Signals, 0)
!         DefaultLock.acquire()
          for name, val in locals().items():
              if val is None:
--- 2146,2150 ----
          if flags is None:
              flags = dict.fromkeys(Signals, 0)
!         self.DefaultLock.acquire()
          for name, val in locals().items():
              if val is None:
***************
*** 2150,2154 ****
              else:
                  setattr(self, name, val)
!         DefaultLock.release()
          del self.self
  
--- 2152,2156 ----
              else:
                  setattr(self, name, val)
!         self.DefaultLock.release()
          del self.self
  
***************
*** 2164,2167 ****
--- 2166,2170 ----
                           self.capitals, self._clamp, self._ignored_flags)
          return nc
+     __copy__ = copy
  
      def _raise_error(self, error, explanation = None, *args):
***************
*** 2265,2275 ****
          the plus operation on the operand.
  
!         >>> ExtendedDefaultContext.abs(Decimal('2.1'))
          Decimal("2.1")
!         >>> ExtendedDefaultContext.abs(Decimal('-100'))
          Decimal("100")
!         >>> ExtendedDefaultContext.abs(Decimal('101.5'))
          Decimal("101.5")
!         >>> ExtendedDefaultContext.abs(Decimal('-101.5'))
          Decimal("101.5")
          """
--- 2268,2278 ----
          the plus operation on the operand.
  
!         >>> ExtendedContext.abs(Decimal('2.1'))
          Decimal("2.1")
!         >>> ExtendedContext.abs(Decimal('-100'))
          Decimal("100")
!         >>> ExtendedContext.abs(Decimal('101.5'))
          Decimal("101.5")
!         >>> ExtendedContext.abs(Decimal('-101.5'))
          Decimal("101.5")
          """
***************
*** 2279,2285 ****
          """Return the sum of the two operands.
  
!         >>> ExtendedDefaultContext.add(Decimal('12'), Decimal('7.00'))
          Decimal("19.00")
!         >>> ExtendedDefaultContext.add(Decimal('1E+2'), Decimal('1.01E+4'))
          Decimal("1.02E+4")
          """
--- 2282,2288 ----
          """Return the sum of the two operands.
  
!         >>> ExtendedContext.add(Decimal('12'), Decimal('7.00'))
          Decimal("19.00")
!         >>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4'))
          Decimal("1.02E+4")
          """
***************
*** 2303,2317 ****
          zero or negative zero, or '1' if the result is greater than zero.
  
!         >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('3'))
          Decimal("-1")
!         >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('2.1'))
          Decimal("0")
!         >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('2.10'))
          Decimal("0")
!         >>> ExtendedDefaultContext.compare(Decimal('3'), Decimal('2.1'))
          Decimal("1")
!         >>> ExtendedDefaultContext.compare(Decimal('2.1'), Decimal('-3'))
          Decimal("1")
!         >>> ExtendedDefaultContext.compare(Decimal('-3'), Decimal('2.1'))
          Decimal("-1")
          """
--- 2306,2320 ----
          zero or negative zero, or '1' if the result is greater than zero.
  
!         >>> ExtendedContext.compare(Decimal('2.1'), Decimal('3'))
          Decimal("-1")
!         >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.1'))
          Decimal("0")
!         >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.10'))
          Decimal("0")
!         >>> ExtendedContext.compare(Decimal('3'), Decimal('2.1'))
          Decimal("1")
!         >>> ExtendedContext.compare(Decimal('2.1'), Decimal('-3'))
          Decimal("1")
!         >>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1'))
          Decimal("-1")
          """
***************
*** 2321,2343 ****
          """Decimal division in a specified context.
  
!         >>> ExtendedDefaultContext.divide(Decimal('1'), Decimal('3'))
          Decimal("0.333333333")
!         >>> ExtendedDefaultContext.divide(Decimal('2'), Decimal('3'))
          Decimal("0.666666667")
!         >>> ExtendedDefaultContext.divide(Decimal('5'), Decimal('2'))
          Decimal("2.5")
!         >>> ExtendedDefaultContext.divide(Decimal('1'), Decimal('10'))
          Decimal("0.1")
!         >>> ExtendedDefaultContext.divide(Decimal('12'), Decimal('12'))
          Decimal("1")
!         >>> ExtendedDefaultContext.divide(Decimal('8.00'), Decimal('2'))
          Decimal("4.00")
!         >>> ExtendedDefaultContext.divide(Decimal('2.400'), Decimal('2.0'))
          Decimal("1.20")
!         >>> ExtendedDefaultContext.divide(Decimal('1000'), Decimal('100'))
          Decimal("10")
!         >>> ExtendedDefaultContext.divide(Decimal('1000'), Decimal('1'))
          Decimal("1000")
!         >>> ExtendedDefaultContext.divide(Decimal('2.40E+6'), Decimal('2'))
          Decimal("1.20E+6")
          """
--- 2324,2346 ----
          """Decimal division in a specified context.
  
!         >>> ExtendedContext.divide(Decimal('1'), Decimal('3'))
          Decimal("0.333333333")
!         >>> ExtendedContext.divide(Decimal('2'), Decimal('3'))
          Decimal("0.666666667")
!         >>> ExtendedContext.divide(Decimal('5'), Decimal('2'))
          Decimal("2.5")
!         >>> ExtendedContext.divide(Decimal('1'), Decimal('10'))
          Decimal("0.1")
!         >>> ExtendedContext.divide(Decimal('12'), Decimal('12'))
          Decimal("1")
!         >>> ExtendedContext.divide(Decimal('8.00'), Decimal('2'))
          Decimal("4.00")
!         >>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0'))
          Decimal("1.20")
!         >>> ExtendedContext.divide(Decimal('1000'), Decimal('100'))
          Decimal("10")
!         >>> ExtendedContext.divide(Decimal('1000'), Decimal('1'))
          Decimal("1000")
!         >>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2'))
          Decimal("1.20E+6")
          """
***************
*** 2347,2355 ****
          """Divides two numbers and returns the integer part of the result.
  
!         >>> ExtendedDefaultContext.divide_int(Decimal('2'), Decimal('3'))
          Decimal("0")
!         >>> ExtendedDefaultContext.divide_int(Decimal('10'), Decimal('3'))
          Decimal("3")
!         >>> ExtendedDefaultContext.divide_int(Decimal('1'), Decimal('0.3'))
          Decimal("3")
          """
--- 2350,2358 ----
          """Divides two numbers and returns the integer part of the result.
  
!         >>> ExtendedContext.divide_int(Decimal('2'), Decimal('3'))
          Decimal("0")
!         >>> ExtendedContext.divide_int(Decimal('10'), Decimal('3'))
          Decimal("3")
!         >>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3'))
          Decimal("3")
          """
***************
*** 2368,2376 ****
          infinity) of the two operands is chosen as the result.
  
!         >>> ExtendedDefaultContext.max(Decimal('3'), Decimal('2'))
          Decimal("3")
!         >>> ExtendedDefaultContext.max(Decimal('-10'), Decimal('3'))
          Decimal("3")
!         >>> ExtendedDefaultContext.max(Decimal('1.0'), Decimal('1'))
          Decimal("1.0")
          """
--- 2371,2379 ----
          infinity) of the two operands is chosen as the result.
  
!         >>> ExtendedContext.max(Decimal('3'), Decimal('2'))
          Decimal("3")
!         >>> ExtendedContext.max(Decimal('-10'), Decimal('3'))
          Decimal("3")
!         >>> ExtendedContext.max(Decimal('1.0'), Decimal('1'))
          Decimal("1.0")
          """
***************
*** 2386,2394 ****
          infinity) of the two operands is chosen as the result.
  
!         >>> ExtendedDefaultContext.min(Decimal('3'), Decimal('2'))
          Decimal("2")
!         >>> ExtendedDefaultContext.min(Decimal('-10'), Decimal('3'))
          Decimal("-10")
!         >>> ExtendedDefaultContext.min(Decimal('1.0'), Decimal('1'))
          Decimal("1.0")
          """
--- 2389,2397 ----
          infinity) of the two operands is chosen as the result.
  
!         >>> ExtendedContext.min(Decimal('3'), Decimal('2'))
          Decimal("2")
!         >>> ExtendedContext.min(Decimal('-10'), Decimal('3'))
          Decimal("-10")
!         >>> ExtendedContext.min(Decimal('1.0'), Decimal('1'))
          Decimal("1.0")
          """
***************
*** 2402,2408 ****
          has the same exponent as the operand.
  
!         >>> ExtendedDefaultContext.minus(Decimal('1.3'))
          Decimal("-1.3")
!         >>> ExtendedDefaultContext.minus(Decimal('-1.3'))
          Decimal("1.3")
          """
--- 2405,2411 ----
          has the same exponent as the operand.
  
!         >>> ExtendedContext.minus(Decimal('1.3'))
          Decimal("-1.3")
!         >>> ExtendedContext.minus(Decimal('-1.3'))
          Decimal("1.3")
          """
***************
*** 2417,2429 ****
          of the two operands.
  
!         >>> ExtendedDefaultContext.multiply(Decimal('1.20'), Decimal('3'))
          Decimal("3.60")
!         >>> ExtendedDefaultContext.multiply(Decimal('7'), Decimal('3'))
          Decimal("21")
!         >>> ExtendedDefaultContext.multiply(Decimal('0.9'), Decimal('0.8'))
          Decimal("0.72")
!         >>> ExtendedDefaultContext.multiply(Decimal('0.9'), Decimal('-0'))
          Decimal("-0.0")
!         >>> ExtendedDefaultContext.multiply(Decimal('654321'), Decimal('654321'))
          Decimal("4.28135971E+11")
          """
--- 2420,2432 ----
          of the two operands.
  
!         >>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3'))
          Decimal("3.60")
!         >>> ExtendedContext.multiply(Decimal('7'), Decimal('3'))
          Decimal("21")
!         >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8'))
          Decimal("0.72")
!         >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0'))
          Decimal("-0.0")
!         >>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321'))
          Decimal("4.28135971E+11")
          """
***************
*** 2436,2450 ****
          result.
  
!         >>> ExtendedDefaultContext.normalize(Decimal('2.1'))
          Decimal("2.1")
!         >>> ExtendedDefaultContext.normalize(Decimal('-2.0'))
          Decimal("-2")
!         >>> ExtendedDefaultContext.normalize(Decimal('1.200'))
          Decimal("1.2")
!         >>> ExtendedDefaultContext.normalize(Decimal('-120'))
          Decimal("-1.2E+2")
!         >>> ExtendedDefaultContext.normalize(Decimal('120.00'))
          Decimal("1.2E+2")
!         >>> ExtendedDefaultContext.normalize(Decimal('0.00'))
          Decimal("0")
          """
--- 2439,2453 ----
          result.
  
!         >>> ExtendedContext.normalize(Decimal('2.1'))
          Decimal("2.1")
!         >>> ExtendedContext.normalize(Decimal('-2.0'))
          Decimal("-2")
!         >>> ExtendedContext.normalize(Decimal('1.200'))
          Decimal("1.2")
!         >>> ExtendedContext.normalize(Decimal('-120'))
          Decimal("-1.2E+2")
!         >>> ExtendedContext.normalize(Decimal('120.00'))
          Decimal("1.2E+2")
!         >>> ExtendedContext.normalize(Decimal('0.00'))
          Decimal("0")
          """
***************
*** 2458,2464 ****
          has the same exponent as the operand.
  
!         >>> ExtendedDefaultContext.plus(Decimal('1.3'))
          Decimal("1.3")
!         >>> ExtendedDefaultContext.plus(Decimal('-1.3'))
          Decimal("-1.3")
          """
--- 2461,2467 ----
          has the same exponent as the operand.
  
!         >>> ExtendedContext.plus(Decimal('1.3'))
          Decimal("1.3")
!         >>> ExtendedContext.plus(Decimal('-1.3'))
          Decimal("-1.3")
          """
***************
*** 2483,2513 ****
          continues.
  
!         >>> ExtendedDefaultContext.power(Decimal('2'), Decimal('3'))
          Decimal("8")
!         >>> ExtendedDefaultContext.power(Decimal('2'), Decimal('-3'))
          Decimal("0.125")
!         >>> ExtendedDefaultContext.power(Decimal('1.7'), Decimal('8'))
          Decimal("69.7575744")
!         >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('-2'))
          Decimal("0")
!         >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('-1'))
          Decimal("0")
!         >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('0'))
          Decimal("1")
!         >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('1'))
          Decimal("Infinity")
!         >>> ExtendedDefaultContext.power(Decimal('Infinity'), Decimal('2'))
          Decimal("Infinity")
!         >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('-2'))
          Decimal("0")
!         >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('-1'))
          Decimal("-0")
!         >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('0'))
          Decimal("1")
!         >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('1'))
          Decimal("-Infinity")
!         >>> ExtendedDefaultContext.power(Decimal('-Infinity'), Decimal('2'))
          Decimal("Infinity")
!         >>> ExtendedDefaultContext.power(Decimal('0'), Decimal('0'))
          Decimal("NaN")
          """
--- 2486,2516 ----
          continues.
  
!         >>> ExtendedContext.power(Decimal('2'), Decimal('3'))
          Decimal("8")
!         >>> ExtendedContext.power(Decimal('2'), Decimal('-3'))
          Decimal("0.125")
!         >>> ExtendedContext.power(Decimal('1.7'), Decimal('8'))
          Decimal("69.7575744")
!         >>> ExtendedContext.power(Decimal('Infinity'), Decimal('-2'))
          Decimal("0")
!         >>> ExtendedContext.power(Decimal('Infinity'), Decimal('-1'))
          Decimal("0")
!         >>> ExtendedContext.power(Decimal('Infinity'), Decimal('0'))
          Decimal("1")
!         >>> ExtendedContext.power(Decimal('Infinity'), Decimal('1'))
          Decimal("Infinity")
!         >>> ExtendedContext.power(Decimal('Infinity'), Decimal('2'))
          Decimal("Infinity")
!         >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('-2'))
          Decimal("0")
!         >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('-1'))
          Decimal("-0")
!         >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('0'))
          Decimal("1")
!         >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('1'))
          Decimal("-Infinity")
!         >>> ExtendedContext.power(Decimal('-Infinity'), Decimal('2'))
          Decimal("Infinity")
!         >>> ExtendedContext.power(Decimal('0'), Decimal('0'))
          Decimal("NaN")
          """
***************
*** 2532,2564 ****
          if the result is subnormal and inexact.
  
!         >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.001'))
          Decimal("2.170")
!         >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.01'))
          Decimal("2.17")
!         >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('0.1'))
          Decimal("2.2")
!         >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('1e+0'))
          Decimal("2")
!         >>> ExtendedDefaultContext.quantize(Decimal('2.17'), Decimal('1e+1'))
          Decimal("0E+1")
!         >>> ExtendedDefaultContext.quantize(Decimal('-Inf'), Decimal('Infinity'))
          Decimal("-Infinity")
!         >>> ExtendedDefaultContext.quantize(Decimal('2'), Decimal('Infinity'))
          Decimal("NaN")
!         >>> ExtendedDefaultContext.quantize(Decimal('-0.1'), Decimal('1'))
          Decimal("-0")
!         >>> ExtendedDefaultContext.quantize(Decimal('-0'), Decimal('1e+5'))
          Decimal("-0E+5")
!         >>> ExtendedDefaultContext.quantize(Decimal('+35236450.6'), Decimal('1e-2'))
          Decimal("NaN")
!         >>> ExtendedDefaultContext.quantize(Decimal('-35236450.6'), Decimal('1e-2'))
          Decimal("NaN")
!         >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e-1'))
          Decimal("217.0")
!         >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e-0'))
          Decimal("217")
!         >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e+1'))
          Decimal("2.2E+2")
!         >>> ExtendedDefaultContext.quantize(Decimal('217'), Decimal('1e+2'))
          Decimal("2E+2")
          """
--- 2535,2567 ----
          if the result is subnormal and inexact.
  
!         >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001'))
          Decimal("2.170")
!         >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01'))
          Decimal("2.17")
!         >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1'))
          Decimal("2.2")
!         >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0'))
          Decimal("2")
!         >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1'))
          Decimal("0E+1")
!         >>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity'))
          Decimal("-Infinity")
!         >>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity'))
          Decimal("NaN")
!         >>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1'))
          Decimal("-0")
!         >>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5'))
          Decimal("-0E+5")
!         >>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2'))
          Decimal("NaN")
!         >>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2'))
          Decimal("NaN")
!         >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1'))
          Decimal("217.0")
!         >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0'))
          Decimal("217")
!         >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1'))
          Decimal("2.2E+2")
!         >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2'))
          Decimal("2E+2")
          """
***************
*** 2577,2591 ****
          remainder cannot be calculated).
  
!         >>> ExtendedDefaultContext.remainder(Decimal('2.1'), Decimal('3'))
          Decimal("2.1")
!         >>> ExtendedDefaultContext.remainder(Decimal('10'), Decimal('3'))
          Decimal("1")
!         >>> ExtendedDefaultContext.remainder(Decimal('-10'), Decimal('3'))
          Decimal("-1")
!         >>> ExtendedDefaultContext.remainder(Decimal('10.2'), Decimal('1'))
          Decimal("0.2")
!         >>> ExtendedDefaultContext.remainder(Decimal('10'), Decimal('0.3'))
          Decimal("0.1")
!         >>> ExtendedDefaultContext.remainder(Decimal('3.6'), Decimal('1.3'))
          Decimal("1.0")
          """
--- 2580,2594 ----
          remainder cannot be calculated).
  
!         >>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3'))
          Decimal("2.1")
!         >>> ExtendedContext.remainder(Decimal('10'), Decimal('3'))
          Decimal("1")
!         >>> ExtendedContext.remainder(Decimal('-10'), Decimal('3'))
          Decimal("-1")
!         >>> ExtendedContext.remainder(Decimal('10.2'), Decimal('1'))
          Decimal("0.2")
!         >>> ExtendedContext.remainder(Decimal('10'), Decimal('0.3'))
          Decimal("0.1")
!         >>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3'))
          Decimal("1.0")
          """
***************
*** 2602,2618 ****
          remainder cannot be calculated).
  
!         >>> ExtendedDefaultContext.remainder_near(Decimal('2.1'), Decimal('3'))
          Decimal("-0.9")
!         >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('6'))
          Decimal("-2")
!         >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('3'))
          Decimal("1")
!         >>> ExtendedDefaultContext.remainder_near(Decimal('-10'), Decimal('3'))
          Decimal("-1")
!         >>> ExtendedDefaultContext.remainder_near(Decimal('10.2'), Decimal('1'))
          Decimal("0.2")
!         >>> ExtendedDefaultContext.remainder_near(Decimal('10'), Decimal('0.3'))
          Decimal("0.1")
!         >>> ExtendedDefaultContext.remainder_near(Decimal('3.6'), Decimal('1.3'))
          Decimal("-0.3")
          """
--- 2605,2621 ----
          remainder cannot be calculated).
  
!         >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3'))
          Decimal("-0.9")
!         >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6'))
          Decimal("-2")
!         >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3'))
          Decimal("1")
!         >>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3'))
          Decimal("-1")
!         >>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1'))
          Decimal("0.2")
!         >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3'))
          Decimal("0.1")
!         >>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3'))
          Decimal("-0.3")
          """
***************
*** 2625,2635 ****
          either operand.
  
!         >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('0.001'))
          False
!         >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('0.01'))
          True
!         >>> ExtendedDefaultContext.same_quantum(Decimal('2.17'), Decimal('1'))
          False
!         >>> ExtendedDefaultContext.same_quantum(Decimal('Inf'), Decimal('-Inf'))
          True
          """
--- 2628,2638 ----
          either operand.
  
!         >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001'))
          False
!         >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.01'))
          True
!         >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('1'))
          False
!         >>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf'))
          True
          """
***************
*** 2642,2664 ****
          algorithm.
  
!         >>> ExtendedDefaultContext.sqrt(Decimal('0'))
          Decimal("0")
!         >>> ExtendedDefaultContext.sqrt(Decimal('-0'))
          Decimal("-0")
!         >>> ExtendedDefaultContext.sqrt(Decimal('0.39'))
          Decimal("0.624499800")
!         >>> ExtendedDefaultContext.sqrt(Decimal('100'))
          Decimal("10")
!         >>> ExtendedDefaultContext.sqrt(Decimal('1'))
          Decimal("1")
!         >>> ExtendedDefaultContext.sqrt(Decimal('1.0'))
          Decimal("1.0")
!         >>> ExtendedDefaultContext.sqrt(Decimal('1.00'))
          Decimal("1.0")
!         >>> ExtendedDefaultContext.sqrt(Decimal('7'))
          Decimal("2.64575131")
!         >>> ExtendedDefaultContext.sqrt(Decimal('10'))
          Decimal("3.16227766")
!         >>> ExtendedDefaultContext.prec
          9
          """
--- 2645,2667 ----
          algorithm.
  
!         >>> ExtendedContext.sqrt(Decimal('0'))
          Decimal("0")
!         >>> ExtendedContext.sqrt(Decimal('-0'))
          Decimal("-0")
!         >>> ExtendedContext.sqrt(Decimal('0.39'))
          Decimal("0.624499800")
!         >>> ExtendedContext.sqrt(Decimal('100'))
          Decimal("10")
!         >>> ExtendedContext.sqrt(Decimal('1'))
          Decimal("1")
!         >>> ExtendedContext.sqrt(Decimal('1.0'))
          Decimal("1.0")
!         >>> ExtendedContext.sqrt(Decimal('1.00'))
          Decimal("1.0")
!         >>> ExtendedContext.sqrt(Decimal('7'))
          Decimal("2.64575131")
!         >>> ExtendedContext.sqrt(Decimal('10'))
          Decimal("3.16227766")
!         >>> ExtendedContext.prec
          9
          """
***************
*** 2668,2676 ****
          """Return the sum of the two operands.
  
!         >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('1.07'))
          Decimal("0.23")
!         >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('1.30'))
          Decimal("0.00")
!         >>> ExtendedDefaultContext.subtract(Decimal('1.3'), Decimal('2.07'))
          Decimal("-0.77")
          """
--- 2671,2679 ----
          """Return the sum of the two operands.
  
!         >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07'))
          Decimal("0.23")
!         >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30'))
          Decimal("0.00")
!         >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07'))
          Decimal("-0.77")
          """
***************
*** 2700,2718 ****
          be set. The rounding mode is taken from the context.
  
!         >>> ExtendedDefaultContext.to_integral(Decimal('2.1'))
          Decimal("2")
!         >>> ExtendedDefaultContext.to_integral(Decimal('100'))
          Decimal("100")
!         >>> ExtendedDefaultContext.to_integral(Decimal('100.0'))
          Decimal("100")
!         >>> ExtendedDefaultContext.to_integral(Decimal('101.5'))
          Decimal("102")
!         >>> ExtendedDefaultContext.to_integral(Decimal('-101.5'))
          Decimal("-102")
!         >>> ExtendedDefaultContext.to_integral(Decimal('10E+5'))
          Decimal("1.0E+6")
!         >>> ExtendedDefaultContext.to_integral(Decimal('7.89E+77'))
          Decimal("7.89E+77")
!         >>> ExtendedDefaultContext.to_integral(Decimal('-Inf'))
          Decimal("-Infinity")
          """
--- 2703,2721 ----
          be set. The rounding mode is taken from the context.
  
!         >>> ExtendedContext.to_integral(Decimal('2.1'))
          Decimal("2")
!         >>> ExtendedContext.to_integral(Decimal('100'))
          Decimal("100")
!         >>> ExtendedContext.to_integral(Decimal('100.0'))
          Decimal("100")
!         >>> ExtendedContext.to_integral(Decimal('101.5'))
          Decimal("102")
!         >>> ExtendedContext.to_integral(Decimal('-101.5'))
          Decimal("-102")
!         >>> ExtendedContext.to_integral(Decimal('10E+5'))
          Decimal("1.0E+6")
!         >>> ExtendedContext.to_integral(Decimal('7.89E+77'))
          Decimal("7.89E+77")
!         >>> ExtendedContext.to_integral(Decimal('-Inf'))
          Decimal("-Infinity")
          """
***************
*** 2975,2979 ****
  # of the spec.
  
! BasicDefaultContext = Context(
          prec=9, rounding=ROUND_HALF_UP,
          trap_enablers=_basic_traps,
--- 2978,2982 ----
  # of the spec.
  
! BasicContext = Context(
          prec=9, rounding=ROUND_HALF_UP,
          trap_enablers=_basic_traps,
***************
*** 2982,2986 ****
  )
  
! ExtendedDefaultContext = Context(
          prec=9, rounding=ROUND_HALF_EVEN,
          trap_enablers=dict.fromkeys(Signals, 0),
--- 2985,2989 ----
  )
  
! ExtendedContext = Context(
          prec=9, rounding=ROUND_HALF_EVEN,
          trap_enablers=dict.fromkeys(Signals, 0),




More information about the Python-checkins mailing list