Return true iff complexes x and y "are close".
(self, x, y, eps=1e-9)
| 73 | unittest.TestCase.assertAlmostEqual(self, a, b) |
| 74 | |
| 75 | def assertClose(self, x, y, eps=1e-9): |
| 76 | """Return true iff complexes x and y "are close".""" |
| 77 | # put the one with larger magnitude second |
| 78 | if abs(x) > abs(y): |
| 79 | x, y = y, x |
| 80 | if y == 0: |
| 81 | return abs(x) < eps |
| 82 | if x == 0: |
| 83 | return abs(y) < eps |
| 84 | # check that relative difference < eps |
| 85 | self.assertTrue(abs(x-y)/abs(y) < eps) |
| 86 | |
| 87 | def check_div(self, x, y): |
| 88 | """Compute complex z=x*y, and check that z/x==y and z/y==x.""" |
no test coverage detected