(self)
| 1971 | self.assertGreaterEqual(result, 0) # A negative result must fail. |
| 1972 | |
| 1973 | def test_shift_data(self): |
| 1974 | # Test that shifting the data by a constant amount does not affect |
| 1975 | # the variance or stdev. Or at least not much. |
| 1976 | |
| 1977 | # Due to rounding, this test should be considered an ideal. We allow |
| 1978 | # some tolerance away from "no change at all" by setting tol and/or rel |
| 1979 | # attributes. Subclasses may set tighter or looser error tolerances. |
| 1980 | raw = [1.03, 1.27, 1.94, 2.04, 2.58, 3.14, 4.75, 4.98, 5.42, 6.78] |
| 1981 | expected = self.func(raw) |
| 1982 | # Don't set shift too high, the bigger it is, the more rounding error. |
| 1983 | shift = 1e5 |
| 1984 | data = [x + shift for x in raw] |
| 1985 | self.assertApproxEqual(self.func(data), expected) |
| 1986 | |
| 1987 | def test_shift_data_exact(self): |
| 1988 | # Like test_shift_data, but result is always exact. |
nothing calls this directly
no test coverage detected