def test_merge_bigger(): x1 = VarianceTracker() for i in range(10): x1.update(i) assert x1.variance() == pytest.approx(9.1667, 1e-4) assert x1.count == 10 assert x1.mean == pytest.approx(4.5, 1e-7) merged = x1.merge(x1.copy()) assert merged.variance() == pytest.approx(8.684, 1e-4) assert merged.count == 20 assert merged.mean == pytest.approx(4.5, 1e-7)
def test_copy(): x1 = VarianceTracker() for i in range(10): x1.update(i) var = x1.variance() count = x1.count mean = x1.mean x2 = x1.copy() assert x2.variance() == var assert x2.count == count assert x2.mean == mean for i in range(3): x1.update(i) assert x1.variance() != var assert x1.count == count + 3 assert x1.mean != mean assert x2.variance() == var assert x2.mean == mean assert x2.count == count