• Home
  • Raw
  • Download

Lines Matching full:decimal

8 import decimal
15 from decimal import Decimal
32 >>> _nan_equal(Decimal('NAN'), Decimal('NAN'))
34 >>> _nan_equal(Decimal('sNAN'), Decimal('sNAN'))
36 >>> _nan_equal(Decimal('NAN'), Decimal('sNAN'))
38 >>> _nan_equal(Decimal(42), Decimal('NAN'))
46 >>> _nan_equal(float('NAN'), Decimal('NAN'))
295 args1 = [2456, 37.8, -12.45, Decimal('2.54'), Fraction(17, 54)]
296 args2 = [2459, 37.2, -12.41, Decimal('2.59'), Fraction(15, 54)]
318 for type_ in (int, float, Decimal, Fraction):
373 # Test that equal Decimal values are exactly equal.
374 D = Decimal
390 # Test equal Decimal values are exactly equal with an absolute error.
391 self.do_exactly_equal_test(Decimal("3.571"), Decimal("0.01"), 0)
392 self.do_exactly_equal_test(-Decimal("81.3971"), Decimal("0.01"), 0)
398 self.do_exactly_equal_test(Decimal("11.68"), 0, Decimal("0.01"))
404 D = Decimal
435 for d in map(Decimal, "3.1415 298.12 3.47 18.996 0.00245".split()):
475 delta = Decimal("0.01")
476 for d in map(Decimal, "1.0 3.5 36.08 61.79 7912.3648".split()):
519 for d in map(Decimal, "0.02 1.0 5.7 13.67 94.138 91027.9321".split()):
520 self.do_approx_equal_rel_test(d, Decimal("0.001"))
521 self.do_approx_equal_rel_test(-d, Decimal("0.05"))
562 for type_ in (float, Decimal):
572 for type_ in (float, Decimal):
582 nzero = Decimal("-0.0")
583 self.assertTrue(approx_equal(nzero, Decimal(0), tol=0.1, rel=0.1))
715 D = Decimal
725 class MyDecimal(Decimal):
728 for type_ in (float, MyFloat, Decimal, MyDecimal):
746 NAN = Decimal("NAN")
747 sNAN = Decimal("sNAN")
748 class MyDecimal(Decimal):
762 inf = Decimal('INF')
768 for nan in (Decimal('NAN'), Decimal('sNAN')):
778 numbers = [Decimal("9.8765e12"), Decimal("9.8765e-12")]
792 t = statistics._exact_ratio(Decimal("0.1234"))
797 t = statistics._exact_ratio(Decimal("1.234e7"))
803 t = statistics._exact_ratio(Decimal("1e2"))
805 t = statistics._exact_ratio(Decimal("1.47e5"))
814 for x in (5, Fraction(1, 3), 2.5, Decimal("5.5")):
819 for x in (float("inf"), Decimal("inf")):
824 for x in (float("nan"), Decimal("NAN"), Decimal("sNAN")):
853 for T in (int, float, Fraction, Decimal):
899 for typ in (float, Fraction, Decimal):
908 # Check that Decimal coerces correctly.
909 self.check_type_coercions(Decimal)
917 for good_type in (int, float, Fraction, Decimal):
924 self.assertCoerceRaises(T, Decimal)
925 self.assertCoerceRaises(MySubclass, Decimal)
965 # Test conversions to Decimal.
966 x = statistics._convert(Fraction(1, 40), Decimal)
967 self.check_exact_equal(x, Decimal("0.025"))
968 class MyDecimal(Decimal):
975 for INF in (float('inf'), Decimal('inf')):
981 for nan in (float('nan'), Decimal('NAN'), Decimal('sNAN')):
991 values = [1, 2.0, Fraction(3), Decimal(4)]
997 for x in [1, 2.0, Fraction(3), Decimal(4)]:
1109 for kind in (float, MyFloat, Decimal, Fraction):
1141 return (float, Decimal, Fraction, MyFloat)
1198 D = Decimal
1203 (Decimal, Decimal("20.686"), 8))
1233 self.assertRaises(TypeError, self.func, [1, 2.0, Decimal(1)])
1235 self.assertRaises(TypeError, self.func, [1, 2.0], Decimal(1))
1255 for type_ in (float, Decimal):
1282 inf = Decimal('inf')
1293 # Test adding Decimal INFs with opposite sign returns NAN.
1294 inf = Decimal('inf')
1296 with decimal.localcontext(decimal.ExtendedContext):
1300 # Test adding Decimal INFs with opposite sign raises InvalidOperation.
1301 inf = Decimal('inf')
1303 with decimal.localcontext(decimal.BasicContext):
1304 self.assertRaises(decimal.InvalidOperation, statistics._sum, data)
1308 sNAN = Decimal('sNAN')
1310 self.assertRaises(decimal.InvalidOperation, statistics._sum, data)
1320 for x in (23, 42.5, 1.3e15, Fraction(15, 19), Decimal('0.28')):
1324 return (3.5, 17, 2.5e15, Fraction(61, 67), Decimal('4.9712'))
1357 D = Decimal
1372 for kind in (float, Decimal):
1389 for kind in (float, Decimal):
1414 d = Decimal('1e4')
1443 return (3.5, 17, 2.5e15, Fraction(61, 67), Decimal('4.125'))
1477 D = Decimal
1561 D = Decimal
1569 D = Decimal
1609 D = Decimal
1636 D = Decimal
1689 for x in (5.3, 68, 4.3e17, Fraction(29, 101), Decimal('32.9714')):
1712 D = Decimal
1720 D = Decimal
1827 for x in (11, 19.8, 4.6e14, Fraction(21, 34), Decimal('8.392')):
1832 for x in (7.2, 49, 8.1e15, Fraction(3, 7), Decimal('62.4802')):
1911 # Test population variance with Decimal data.
1912 D = Decimal
1917 self.assertIsInstance(result, Decimal)
1927 for x in (35, 24.7, 8.2e15, Fraction(19, 30), Decimal('4.2084')):
1946 # Test sample variance with Decimal data.
1947 D = Decimal
1952 self.assertIsInstance(result, Decimal)
1974 for x in (81, 203.74, 3.9e14, Fraction(5, 21), Decimal('35.719')):