def test_shift_data(self):
# Test that shifting the data by a constant amount does not affect
# the variance or stdev. Or at least not much.
# Due to rounding, this test should be considered an ideal. We allow
# some tolerance away from "no change at all" by setting tol and/or rel
# attributes. Subclasses may set tighter or looser error tolerances.
raw = [1.03, 1.27, 1.94, 2.04, 2.58, 3.14, 4.75, 4.98, 5.42, 6.78]
expected = self.func(raw)
# Don't set shift too high, the bigger it is, the more rounding error.
shift = 1e5
data = [x + shift for x in raw]
self.assertApproxEqual(self.func(data), expected)
评论列表
文章目录