示例#1
0
    def test_trimmed_mean_negative(self):
        td = TDigest()
        for i in range(100):
            td.update(random.random())

        for i in range(10):
            td.update(i*100)

        mean = td.trimmed_mean(1, 99)
        assert mean >= 0
示例#2
0
    def test_data_comes_in_sorted_does_not_blow_up(self, empty_tdigest):
        t = TDigest()
        for x in range(10000):
            t.update(x, 1)

        assert len(t) < 5000

        t = TDigest()
        t.batch_update(range(10000))
        assert len(t) < 1000
示例#3
0
    def test_data_comes_in_sorted_does_not_blow_up(self, empty_tdigest):
        t = TDigest()
        for x in range(10000):
            t.update(x,1)

        assert len(t) < 5000

        t = TDigest()
        t.batch_update(range(10000))
        assert len(t) < 1000
示例#4
0
    def test_trimmed_mean_corner_cases(self):
        td = TDigest()

        mean = td.trimmed_mean(0, 100)
        assert mean == 0

        td.update(1)
        mean = td.trimmed_mean(0, 100)
        assert mean == 1

        td.update(1000)
        mean = td.trimmed_mean(0, 100)
        assert mean == 500.5