Lines Matching refs:Decimal

21 from decimal import Decimal
38 >>> _nan_equal(Decimal('NAN'), Decimal('NAN'))
40 >>> _nan_equal(Decimal('sNAN'), Decimal('sNAN'))
42 >>> _nan_equal(Decimal('NAN'), Decimal('sNAN'))
44 >>> _nan_equal(Decimal(42), Decimal('NAN'))
52 >>> _nan_equal(float('NAN'), Decimal('NAN'))
320 args1 = [2456, 37.8, -12.45, Decimal('2.54'), Fraction(17, 54)]
321 args2 = [2459, 37.2, -12.41, Decimal('2.59'), Fraction(15, 54)]
343 for type_ in (int, float, Decimal, Fraction):
398 # Test that equal Decimal values are exactly equal.
399 D = Decimal
415 # Test equal Decimal values are exactly equal with an absolute error.
416 self.do_exactly_equal_test(Decimal("3.571"), Decimal("0.01"), 0)
417 self.do_exactly_equal_test(-Decimal("81.3971"), Decimal("0.01"), 0)
423 self.do_exactly_equal_test(Decimal("11.68"), 0, Decimal("0.01"))
429 D = Decimal
460 for d in map(Decimal, "3.1415 298.12 3.47 18.996 0.00245".split()):
500 delta = Decimal("0.01")
501 for d in map(Decimal, "1.0 3.5 36.08 61.79 7912.3648".split()):
544 for d in map(Decimal, "0.02 1.0 5.7 13.67 94.138 91027.9321".split()):
545 self.do_approx_equal_rel_test(d, Decimal("0.001"))
546 self.do_approx_equal_rel_test(-d, Decimal("0.05"))
587 for type_ in (float, Decimal):
597 for type_ in (float, Decimal):
607 nzero = Decimal("-0.0")
608 self.assertTrue(approx_equal(nzero, Decimal(0), tol=0.1, rel=0.1))
740 D = Decimal
750 class MyDecimal(Decimal):
753 for type_ in (float, MyFloat, Decimal, MyDecimal):
771 NAN = Decimal("NAN")
772 sNAN = Decimal("sNAN")
773 class MyDecimal(Decimal):
787 inf = Decimal('INF')
793 for nan in (Decimal('NAN'), Decimal('sNAN')):
803 numbers = [Decimal("9.8765e12"), Decimal("9.8765e-12")]
817 t = statistics._exact_ratio(Decimal("0.1234"))
822 t = statistics._exact_ratio(Decimal("1.234e7"))
828 t = statistics._exact_ratio(Decimal("1e2"))
830 t = statistics._exact_ratio(Decimal("1.47e5"))
839 for x in (5, Fraction(1, 3), 2.5, Decimal("5.5")):
844 for x in (float("inf"), Decimal("inf")):
849 for x in (float("nan"), Decimal("NAN"), Decimal("sNAN")):
878 for T in (int, float, Fraction, Decimal):
924 for typ in (float, Fraction, Decimal):
933 # Check that Decimal coerces correctly.
934 self.check_type_coercions(Decimal)
942 for good_type in (int, float, Fraction, Decimal):
949 self.assertCoerceRaises(T, Decimal)
950 self.assertCoerceRaises(MySubclass, Decimal)
990 # Test conversions to Decimal.
991 x = statistics._convert(Fraction(1, 40), Decimal)
992 self.check_exact_equal(x, Decimal("0.025"))
993 class MyDecimal(Decimal):
1000 for INF in (float('inf'), Decimal('inf')):
1006 for nan in (float('nan'), Decimal('NAN'), Decimal('sNAN')):
1020 values = [1, 2.0, Fraction(3), Decimal(4)]
1026 for x in [1, 2.0, Fraction(3), Decimal(4)]:
1138 for kind in (float, MyFloat, Decimal, Fraction):
1173 return (float, Decimal, Fraction, MyFloat)
1224 D = Decimal
1229 (Decimal, Decimal("20.686"), 8))
1251 self.assertRaises(TypeError, self.func, [1, 2.0, Decimal(1)])
1253 self.assertRaises(TypeError, self.func, [1, 2.0], Decimal(1))
1273 for type_ in (float, Decimal):
1300 inf = Decimal('inf')
1311 # Test adding Decimal INFs with opposite sign returns NAN.
1312 inf = Decimal('inf')
1318 # Test adding Decimal INFs with opposite sign raises InvalidOperation.
1319 inf = Decimal('inf')
1326 sNAN = Decimal('sNAN')
1338 for x in (23, 42.5, 1.3e15, Fraction(15, 19), Decimal('0.28')):
1342 return (3.5, 17, 2.5e15, Fraction(61, 67), Decimal('4.9712'))
1375 D = Decimal
1390 for kind in (float, Decimal):
1407 for kind in (float, Decimal):
1432 d = Decimal('1e4')
1461 return (3.5, 17, 2.5e15, Fraction(61, 67), Decimal('4.125'))
1507 D = Decimal
1612 D = Decimal
1620 D = Decimal
1660 D = Decimal
1687 D = Decimal
1740 for x in (5.3, 68, 4.3e17, Fraction(29, 101), Decimal('32.9714')):
1748 for x in (23, 42.5, 1.3e15, Fraction(15, 19), Decimal('0.28')):
1769 D = Decimal
1777 D = Decimal
1888 D = Decimal
1964 for x in (11, 19.8, 4.6e14, Fraction(21, 34), Decimal('8.392')):
1969 for x in (7.2, 49, 8.1e15, Fraction(3, 7), Decimal('62.4802')):
2048 # Test population variance with Decimal data.
2049 D = Decimal
2054 self.assertIsInstance(result, Decimal)
2071 for x in (35, 24.7, 8.2e15, Fraction(19, 30), Decimal('4.2084')):
2090 # Test sample variance with Decimal data.
2091 D = Decimal
2096 self.assertIsInstance(result, Decimal)
2187 root: Decimal
2192 (Decimal('0.4481904599041192673635338663'), 200874688349065940678243576378, 1000000000000000000000000000000), # No adj
2193 (Decimal('0.7924949131383786609961759598'), 628048187350206338833590574929, 1000000000000000000000000000000), # Adj up
2194 (Decimal('0.8500554152289934068192208727'), 722594208960136395984391238251, 1000000000000000000000000000000), # Adj down
2202 high_prec_ratio = Decimal(numerator) / Decimal(denominator)
2209 # Verify that corner cases and error handling match Decimal.sqrt()
2231 for x in (81, 203.74, 3.9e14, Fraction(5, 21), Decimal('35.719')):
2264 gm_decimal = math.prod(map(Decimal, rng)) ** (Decimal(1) / len(rng))
2270 D = Decimal
2374 for datatype in (float, Decimal, Fraction):
2429 for datatype in (float, Decimal, Fraction):