(self)
| 85 | self.check_equal_hash(n, float(n)) |
| 86 | |
| 87 | def test_binary_floats(self): |
| 88 | # check that floats hash equal to corresponding Fractions and Decimals |
| 89 | |
| 90 | # floats that are distinct but numerically equal should hash the same |
| 91 | self.check_equal_hash(0.0, -0.0) |
| 92 | |
| 93 | # zeros |
| 94 | self.check_equal_hash(0.0, D(0)) |
| 95 | self.check_equal_hash(-0.0, D(0)) |
| 96 | self.check_equal_hash(-0.0, D('-0.0')) |
| 97 | self.check_equal_hash(0.0, F(0)) |
| 98 | |
| 99 | # infinities and nans |
| 100 | self.check_equal_hash(float('inf'), D('inf')) |
| 101 | self.check_equal_hash(float('-inf'), D('-inf')) |
| 102 | |
| 103 | for _ in range(1000): |
| 104 | x = random.random() * math.exp(random.random()*200.0 - 100.0) |
| 105 | self.check_equal_hash(x, D.from_float(x)) |
| 106 | self.check_equal_hash(x, F.from_float(x)) |
| 107 | |
| 108 | def test_complex(self): |
| 109 | # complex numbers with zero imaginary part should hash equal to |
nothing calls this directly
no test coverage detected