MCPcopy
hub / github.com/redis/redis-py / test_tdigest_quantile

Function test_tdigest_quantile

tests/test_bloom.py:493–509  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

491@pytest.mark.redismod
492@skip_ifmodversion_lt("2.4.0", "bf")
493def test_tdigest_quantile(client):
494 assert client.tdigest().create("tDigest", 500)
495 # insert data-points into sketch
496 assert client.tdigest().add("tDigest", list([x * 0.01 for x in range(1, 10000)]))
497 # assert min min/max have same result as quantile 0 and 1
498 res = client.tdigest().quantile("tDigest", 1.0)
499 assert client.tdigest().max("tDigest") == res[0]
500 res = client.tdigest().quantile("tDigest", 0.0)
501 assert client.tdigest().min("tDigest") == res[0]
502
503 assert 1.0 == round(client.tdigest().quantile("tDigest", 0.01)[0], 2)
504 assert 99.0 == round(client.tdigest().quantile("tDigest", 0.99)[0], 2)
505
506 # test multiple quantiles
507 assert client.tdigest().create("t-digest", 100)
508 assert client.tdigest().add("t-digest", [1, 2, 3, 4, 5])
509 assert [3.0, 5.0] == client.tdigest().quantile("t-digest", 0.5, 0.8)
510
511
512@pytest.mark.experimental

Callers

nothing calls this directly

Calls 6

quantileMethod · 0.80
maxMethod · 0.80
minMethod · 0.80
createMethod · 0.45
tdigestMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected