datasketches 0.2.2 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/LICENSE +40 -3
- data/NOTICE +1 -1
- data/README.md +8 -8
- data/ext/datasketches/kll_wrapper.cpp +5 -1
- data/ext/datasketches/theta_wrapper.cpp +20 -4
- data/lib/datasketches/version.rb +1 -1
- data/vendor/datasketches-cpp/CMakeLists.txt +27 -5
- data/vendor/datasketches-cpp/LICENSE +40 -3
- data/vendor/datasketches-cpp/MANIFEST.in +3 -0
- data/vendor/datasketches-cpp/NOTICE +1 -1
- data/vendor/datasketches-cpp/README.md +76 -9
- data/vendor/datasketches-cpp/cmake/DataSketchesConfig.cmake.in +10 -0
- data/vendor/datasketches-cpp/common/CMakeLists.txt +18 -13
- data/vendor/datasketches-cpp/common/include/binomial_bounds.hpp +1 -0
- data/vendor/datasketches-cpp/common/include/common_defs.hpp +16 -0
- data/vendor/datasketches-cpp/{kll → common}/include/kolmogorov_smirnov.hpp +5 -3
- data/vendor/datasketches-cpp/{kll → common}/include/kolmogorov_smirnov_impl.hpp +13 -16
- data/vendor/datasketches-cpp/common/include/quantile_sketch_sorted_view.hpp +121 -0
- data/vendor/datasketches-cpp/common/include/quantile_sketch_sorted_view_impl.hpp +91 -0
- data/vendor/datasketches-cpp/common/test/test_type.hpp +2 -0
- data/vendor/datasketches-cpp/cpc/CMakeLists.txt +15 -35
- data/vendor/datasketches-cpp/cpc/include/cpc_common.hpp +10 -3
- data/vendor/datasketches-cpp/cpc/include/cpc_compressor_impl.hpp +1 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_confidence.hpp +1 -0
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch.hpp +1 -1
- data/vendor/datasketches-cpp/cpc/include/cpc_sketch_impl.hpp +5 -3
- data/vendor/datasketches-cpp/cpc/include/cpc_union.hpp +1 -1
- data/vendor/datasketches-cpp/cpc/include/cpc_union_impl.hpp +10 -6
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_allocation_test.cpp +17 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_sketch_test.cpp +1 -0
- data/vendor/datasketches-cpp/cpc/test/cpc_union_test.cpp +2 -0
- data/vendor/datasketches-cpp/fi/CMakeLists.txt +5 -15
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch.hpp +37 -5
- data/vendor/datasketches-cpp/fi/include/frequent_items_sketch_impl.hpp +30 -12
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_custom_type_test.cpp +2 -1
- data/vendor/datasketches-cpp/fi/test/frequent_items_sketch_test.cpp +1 -0
- data/vendor/datasketches-cpp/hll/CMakeLists.txt +33 -56
- data/vendor/datasketches-cpp/hll/include/AuxHashMap-internal.hpp +2 -0
- data/vendor/datasketches-cpp/hll/include/CompositeInterpolationXTable-internal.hpp +1 -0
- data/vendor/datasketches-cpp/hll/include/CouponHashSet-internal.hpp +2 -2
- data/vendor/datasketches-cpp/hll/include/CouponList-internal.hpp +1 -0
- data/vendor/datasketches-cpp/hll/include/HllSketch-internal.hpp +6 -4
- data/vendor/datasketches-cpp/hll/include/HllSketchImpl-internal.hpp +2 -0
- data/vendor/datasketches-cpp/hll/include/HllSketchImplFactory.hpp +2 -0
- data/vendor/datasketches-cpp/hll/test/AuxHashMapTest.cpp +1 -0
- data/vendor/datasketches-cpp/hll/test/CouponHashSetTest.cpp +1 -0
- data/vendor/datasketches-cpp/hll/test/CouponListTest.cpp +2 -0
- data/vendor/datasketches-cpp/hll/test/HllArrayTest.cpp +1 -0
- data/vendor/datasketches-cpp/hll/test/HllSketchTest.cpp +59 -0
- data/vendor/datasketches-cpp/hll/test/HllUnionTest.cpp +2 -0
- data/vendor/datasketches-cpp/hll/test/TablesTest.cpp +1 -0
- data/vendor/datasketches-cpp/kll/CMakeLists.txt +5 -19
- data/vendor/datasketches-cpp/kll/include/kll_helper.hpp +0 -4
- data/vendor/datasketches-cpp/kll/include/kll_helper_impl.hpp +3 -0
- data/vendor/datasketches-cpp/kll/include/kll_sketch.hpp +103 -44
- data/vendor/datasketches-cpp/kll/include/kll_sketch_impl.hpp +110 -130
- data/vendor/datasketches-cpp/kll/test/kll_sketch_test.cpp +156 -23
- data/vendor/datasketches-cpp/kll/test/kolmogorov_smirnov_test.cpp +1 -1
- data/vendor/datasketches-cpp/pyproject.toml +4 -2
- data/vendor/datasketches-cpp/python/CMakeLists.txt +17 -6
- data/vendor/datasketches-cpp/python/README.md +57 -50
- data/vendor/datasketches-cpp/python/pybind11Path.cmd +3 -0
- data/vendor/datasketches-cpp/python/src/cpc_wrapper.cpp +1 -1
- data/vendor/datasketches-cpp/python/src/datasketches.cpp +4 -0
- data/vendor/datasketches-cpp/python/src/fi_wrapper.cpp +6 -1
- data/vendor/datasketches-cpp/python/src/kll_wrapper.cpp +49 -14
- data/vendor/datasketches-cpp/python/src/ks_wrapper.cpp +68 -0
- data/vendor/datasketches-cpp/python/src/quantiles_wrapper.cpp +240 -0
- data/vendor/datasketches-cpp/python/src/req_wrapper.cpp +9 -2
- data/vendor/datasketches-cpp/python/src/theta_wrapper.cpp +2 -2
- data/vendor/datasketches-cpp/python/src/vector_of_kll.cpp +12 -5
- data/vendor/datasketches-cpp/python/tests/kll_test.py +12 -6
- data/vendor/datasketches-cpp/python/tests/quantiles_test.py +126 -0
- data/vendor/datasketches-cpp/python/tests/req_test.py +2 -2
- data/vendor/datasketches-cpp/python/tests/vector_of_kll_test.py +4 -4
- data/vendor/datasketches-cpp/quantiles/CMakeLists.txt +42 -0
- data/vendor/datasketches-cpp/quantiles/include/quantiles_sketch.hpp +641 -0
- data/vendor/datasketches-cpp/quantiles/include/quantiles_sketch_impl.hpp +1309 -0
- data/vendor/datasketches-cpp/quantiles/test/CMakeLists.txt +44 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.3.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.6.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.8.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n1000_v0.8.3.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.3.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.6.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.8.0.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/Qk128_n50_v0.8.3.sk +0 -0
- data/vendor/datasketches-cpp/quantiles/test/kolmogorov_smirnov_test.cpp +110 -0
- data/vendor/datasketches-cpp/quantiles/test/quantiles_compatibility_test.cpp +129 -0
- data/vendor/datasketches-cpp/quantiles/test/quantiles_sketch_test.cpp +912 -0
- data/vendor/datasketches-cpp/req/CMakeLists.txt +6 -21
- data/vendor/datasketches-cpp/req/include/req_common.hpp +0 -5
- data/vendor/datasketches-cpp/req/include/req_compactor_impl.hpp +3 -2
- data/vendor/datasketches-cpp/req/include/req_sketch.hpp +62 -23
- data/vendor/datasketches-cpp/req/include/req_sketch_impl.hpp +66 -61
- data/vendor/datasketches-cpp/req/test/req_sketch_test.cpp +5 -0
- data/vendor/datasketches-cpp/sampling/CMakeLists.txt +5 -9
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch.hpp +54 -12
- data/vendor/datasketches-cpp/sampling/include/var_opt_sketch_impl.hpp +45 -34
- data/vendor/datasketches-cpp/sampling/include/var_opt_union.hpp +41 -6
- data/vendor/datasketches-cpp/sampling/include/var_opt_union_impl.hpp +33 -15
- data/vendor/datasketches-cpp/sampling/test/var_opt_allocation_test.cpp +2 -2
- data/vendor/datasketches-cpp/sampling/test/var_opt_sketch_test.cpp +1 -0
- data/vendor/datasketches-cpp/sampling/test/var_opt_union_test.cpp +1 -0
- data/vendor/datasketches-cpp/setup.py +10 -7
- data/vendor/datasketches-cpp/theta/CMakeLists.txt +26 -45
- data/vendor/datasketches-cpp/theta/include/bounds_on_ratios_in_sampled_sets.hpp +1 -0
- data/vendor/datasketches-cpp/theta/include/compact_theta_sketch_parser_impl.hpp +92 -23
- data/vendor/datasketches-cpp/theta/include/theta_constants.hpp +9 -4
- data/vendor/datasketches-cpp/theta/include/theta_helpers.hpp +15 -0
- data/vendor/datasketches-cpp/theta/include/theta_intersection_base_impl.hpp +7 -6
- data/vendor/datasketches-cpp/theta/include/theta_set_difference_base_impl.hpp +3 -2
- data/vendor/datasketches-cpp/theta/include/theta_sketch.hpp +32 -15
- data/vendor/datasketches-cpp/theta/include/theta_sketch_impl.hpp +150 -93
- data/vendor/datasketches-cpp/theta/include/theta_union.hpp +6 -1
- data/vendor/datasketches-cpp/theta/include/theta_union_base.hpp +3 -1
- data/vendor/datasketches-cpp/theta/include/theta_union_base_impl.hpp +9 -2
- data/vendor/datasketches-cpp/theta/include/theta_union_impl.hpp +8 -5
- data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base.hpp +9 -5
- data/vendor/datasketches-cpp/theta/include/theta_update_sketch_base_impl.hpp +39 -10
- data/vendor/datasketches-cpp/theta/test/CMakeLists.txt +1 -0
- data/vendor/datasketches-cpp/theta/test/theta_a_not_b_test.cpp +2 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java_v1.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_empty_from_java_v2.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java_v1.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_estimation_from_java_v2.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_compact_exact_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_intersection_test.cpp +2 -0
- data/vendor/datasketches-cpp/theta/test/theta_setop_test.cpp +446 -0
- data/vendor/datasketches-cpp/theta/test/theta_sketch_test.cpp +429 -1
- data/vendor/datasketches-cpp/theta/test/theta_union_test.cpp +25 -11
- data/vendor/datasketches-cpp/tuple/CMakeLists.txt +18 -33
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch.hpp +1 -1
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_sketch_impl.hpp +3 -3
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union.hpp +1 -1
- data/vendor/datasketches-cpp/tuple/include/array_of_doubles_union_impl.hpp +3 -3
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch.hpp +29 -9
- data/vendor/datasketches-cpp/tuple/include/tuple_sketch_impl.hpp +34 -14
- data/vendor/datasketches-cpp/tuple/include/tuple_union.hpp +6 -1
- data/vendor/datasketches-cpp/tuple/include/tuple_union_impl.hpp +8 -3
- data/vendor/datasketches-cpp/tuple/test/array_of_doubles_sketch_test.cpp +16 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_a_not_b_test.cpp +1 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_intersection_test.cpp +1 -0
- data/vendor/datasketches-cpp/tuple/test/tuple_sketch_test.cpp +46 -8
- data/vendor/datasketches-cpp/tuple/test/tuple_union_test.cpp +8 -0
- metadata +34 -12
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator.hpp +0 -75
- data/vendor/datasketches-cpp/kll/include/kll_quantile_calculator_impl.hpp +0 -184
- data/vendor/datasketches-cpp/req/include/req_quantile_calculator.hpp +0 -69
- data/vendor/datasketches-cpp/req/include/req_quantile_calculator_impl.hpp +0 -60
- data/vendor/datasketches-cpp/theta/test/theta_update_empty_from_java.sk +0 -0
- data/vendor/datasketches-cpp/theta/test/theta_update_estimation_from_java.sk +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
# to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
|
12
|
+
# software distributed under the License is distributed on an
|
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
# KIND, either express or implied. See the License for the
|
|
15
|
+
# specific language governing permissions and limitations
|
|
16
|
+
# under the License.
|
|
17
|
+
|
|
18
|
+
import unittest
|
|
19
|
+
from datasketches import quantiles_ints_sketch, quantiles_floats_sketch, quantiles_doubles_sketch, ks_test
|
|
20
|
+
import numpy as np
|
|
21
|
+
|
|
22
|
+
class QuantilesTest(unittest.TestCase):
|
|
23
|
+
def test_quantiles_example(self):
|
|
24
|
+
k = 128
|
|
25
|
+
n = 2 ** 20
|
|
26
|
+
|
|
27
|
+
# create a sketch and inject ~1 million N(0,1) points as an array and as a single item
|
|
28
|
+
quantiles = quantiles_floats_sketch(k)
|
|
29
|
+
quantiles.update(np.random.normal(size=n-1))
|
|
30
|
+
quantiles.update(0.0)
|
|
31
|
+
|
|
32
|
+
# 0 should be near the median
|
|
33
|
+
self.assertAlmostEqual(0.5, quantiles.get_rank(0.0), delta=0.035)
|
|
34
|
+
|
|
35
|
+
# the median should be near 0
|
|
36
|
+
self.assertAlmostEqual(0.0, quantiles.get_quantile(0.5), delta=0.035)
|
|
37
|
+
|
|
38
|
+
# we also track the min/max independently from the rest of the data
|
|
39
|
+
# which lets us know the full observed data range
|
|
40
|
+
self.assertLessEqual(quantiles.get_min_value(), quantiles.get_quantile(0.01))
|
|
41
|
+
self.assertLessEqual(0.0, quantiles.get_rank(quantiles.get_min_value()))
|
|
42
|
+
self.assertGreaterEqual(quantiles.get_max_value(), quantiles.get_quantile(0.99))
|
|
43
|
+
self.assertGreaterEqual(1.0, quantiles.get_rank(quantiles.get_max_value()))
|
|
44
|
+
|
|
45
|
+
# we can also extract a list of values at a time,
|
|
46
|
+
# here the values should give us something close to [-2, -1, 0, 1, 2].
|
|
47
|
+
# then get the CDF, which will return something close to
|
|
48
|
+
# the original values used in get_quantiles()
|
|
49
|
+
# finally, can check the normalized rank error bound
|
|
50
|
+
pts = quantiles.get_quantiles([0.0228, 0.1587, 0.5, 0.8413, 0.9772])
|
|
51
|
+
cdf = quantiles.get_cdf(pts) # include 1.0 at end to account for all probability mass
|
|
52
|
+
self.assertEqual(len(cdf), len(pts)+1)
|
|
53
|
+
err = quantiles.normalized_rank_error(False)
|
|
54
|
+
self.assertEqual(err, quantiles_floats_sketch.get_normalized_rank_error(k, False))
|
|
55
|
+
|
|
56
|
+
# and a few basic queries about the sketch
|
|
57
|
+
self.assertFalse(quantiles.is_empty())
|
|
58
|
+
self.assertTrue(quantiles.is_estimation_mode())
|
|
59
|
+
self.assertEqual(quantiles.get_n(), n)
|
|
60
|
+
self.assertEqual(quantiles.get_k(), k)
|
|
61
|
+
self.assertLess(quantiles.get_num_retained(), n)
|
|
62
|
+
|
|
63
|
+
# merging itself will double the number of items the sketch has seen
|
|
64
|
+
quantiles.merge(quantiles)
|
|
65
|
+
self.assertEqual(quantiles.get_n(), 2*n)
|
|
66
|
+
|
|
67
|
+
# we can then serialize and reconstruct the sketch
|
|
68
|
+
quantiles_bytes = quantiles.serialize()
|
|
69
|
+
new_quantiles = quantiles.deserialize(quantiles_bytes)
|
|
70
|
+
self.assertEqual(quantiles.get_num_retained(), new_quantiles.get_num_retained())
|
|
71
|
+
self.assertEqual(quantiles.get_min_value(), new_quantiles.get_min_value())
|
|
72
|
+
self.assertEqual(quantiles.get_max_value(), new_quantiles.get_max_value())
|
|
73
|
+
self.assertEqual(quantiles.get_quantile(0.7), new_quantiles.get_quantile(0.7))
|
|
74
|
+
self.assertEqual(quantiles.get_rank(0.0), new_quantiles.get_rank(0.0))
|
|
75
|
+
|
|
76
|
+
# If we create a new sketch with a very different distribution, a Kolmogorov-Smirnov Test
|
|
77
|
+
# of the two should return True: we can reject the null hypothesis that the sketches
|
|
78
|
+
# come from the same distributions.
|
|
79
|
+
unif_quantiles = quantiles_floats_sketch(k)
|
|
80
|
+
unif_quantiles.update(np.random.uniform(10, 20, size=n-1))
|
|
81
|
+
self.assertTrue(ks_test(quantiles, unif_quantiles, 0.001))
|
|
82
|
+
|
|
83
|
+
def test_quantiles_ints_sketch(self):
|
|
84
|
+
k = 128
|
|
85
|
+
n = 10
|
|
86
|
+
quantiles = quantiles_ints_sketch(k)
|
|
87
|
+
for i in range(0, n):
|
|
88
|
+
quantiles.update(i)
|
|
89
|
+
|
|
90
|
+
self.assertEqual(quantiles.get_min_value(), 0)
|
|
91
|
+
self.assertEqual(quantiles.get_max_value(), n-1)
|
|
92
|
+
self.assertEqual(quantiles.get_n(), n)
|
|
93
|
+
self.assertFalse(quantiles.is_empty())
|
|
94
|
+
self.assertFalse(quantiles.is_estimation_mode()) # n < k
|
|
95
|
+
self.assertEqual(quantiles.get_k(), k)
|
|
96
|
+
|
|
97
|
+
pmf = quantiles.get_pmf([round(n/2)])
|
|
98
|
+
self.assertIsNotNone(pmf)
|
|
99
|
+
self.assertEqual(len(pmf), 2)
|
|
100
|
+
|
|
101
|
+
cdf = quantiles.get_cdf([round(n/2)])
|
|
102
|
+
self.assertIsNotNone(cdf)
|
|
103
|
+
self.assertEqual(len(cdf), 2)
|
|
104
|
+
|
|
105
|
+
self.assertEqual(quantiles.get_quantile(0.5), round(n/2))
|
|
106
|
+
quants = quantiles.get_quantiles([0.25, 0.5, 0.75])
|
|
107
|
+
self.assertIsNotNone(quants)
|
|
108
|
+
self.assertEqual(len(quants), 3)
|
|
109
|
+
|
|
110
|
+
self.assertEqual(quantiles.get_rank(round(n/2)), 0.5)
|
|
111
|
+
|
|
112
|
+
# merge self
|
|
113
|
+
quantiles.merge(quantiles)
|
|
114
|
+
self.assertEqual(quantiles.get_n(), 2 * n)
|
|
115
|
+
|
|
116
|
+
sk_bytes = quantiles.serialize()
|
|
117
|
+
self.assertTrue(isinstance(quantiles_ints_sketch.deserialize(sk_bytes), quantiles_ints_sketch))
|
|
118
|
+
|
|
119
|
+
def test_quantiles_doubles_sketch(self):
|
|
120
|
+
# already tested floats and ints and it's templatized, so just make sure it instantiates properly
|
|
121
|
+
k = 128
|
|
122
|
+
quantiles = quantiles_doubles_sketch(k)
|
|
123
|
+
self.assertTrue(quantiles.is_empty())
|
|
124
|
+
|
|
125
|
+
if __name__ == '__main__':
|
|
126
|
+
unittest.main()
|
|
@@ -30,10 +30,10 @@ class reqTest(unittest.TestCase):
|
|
|
30
30
|
req.update(0.0)
|
|
31
31
|
|
|
32
32
|
# 0 should be near the median
|
|
33
|
-
self.assertAlmostEqual(0.5, req.get_rank(0.0), delta=0.
|
|
33
|
+
self.assertAlmostEqual(0.5, req.get_rank(0.0), delta=0.045)
|
|
34
34
|
|
|
35
35
|
# the median should be near 0
|
|
36
|
-
self.assertAlmostEqual(0.0, req.get_quantile(0.5), delta=0.
|
|
36
|
+
self.assertAlmostEqual(0.0, req.get_quantile(0.5), delta=0.045)
|
|
37
37
|
|
|
38
38
|
# we also track the min/max independently from the rest of the data
|
|
39
39
|
# which lets us know the full observed data range
|
|
@@ -39,9 +39,9 @@ class VectorOfKllSketchesTest(unittest.TestCase):
|
|
|
39
39
|
kll.update(dat)
|
|
40
40
|
|
|
41
41
|
# 0 should be near the median
|
|
42
|
-
np.testing.assert_allclose(0.5, kll.get_ranks(0.0), atol=0.
|
|
42
|
+
np.testing.assert_allclose(0.5, kll.get_ranks(0.0), atol=0.035)
|
|
43
43
|
# the median should be near 0
|
|
44
|
-
np.testing.assert_allclose(0.0, kll.get_quantiles(0.5), atol=0.
|
|
44
|
+
np.testing.assert_allclose(0.0, kll.get_quantiles(0.5), atol=0.035)
|
|
45
45
|
# we also track the min/max independently from the rest of the data
|
|
46
46
|
# which lets us know the full observed data range
|
|
47
47
|
np.testing.assert_allclose(kll.get_min_values(), smin)
|
|
@@ -118,9 +118,9 @@ class VectorOfKllSketchesTest(unittest.TestCase):
|
|
|
118
118
|
kll.update(dat)
|
|
119
119
|
|
|
120
120
|
# 0 should be near the median
|
|
121
|
-
np.testing.assert_allclose(0.5, kll.get_ranks(0.0), atol=0.
|
|
121
|
+
np.testing.assert_allclose(0.5, kll.get_ranks(0.0), atol=0.035)
|
|
122
122
|
# the median should be near 0
|
|
123
|
-
np.testing.assert_allclose(0.0, kll.get_quantiles(0.5), atol=0.
|
|
123
|
+
np.testing.assert_allclose(0.0, kll.get_quantiles(0.5), atol=0.035)
|
|
124
124
|
# we also track the min/max independently from the rest of the data
|
|
125
125
|
# which lets us know the full observed data range
|
|
126
126
|
np.testing.assert_allclose(kll.get_min_values(), smin)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
# to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
|
12
|
+
# software distributed under the License is distributed on an
|
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
# KIND, either express or implied. See the License for the
|
|
15
|
+
# specific language governing permissions and limitations
|
|
16
|
+
# under the License.
|
|
17
|
+
|
|
18
|
+
add_library(quantiles INTERFACE)
|
|
19
|
+
|
|
20
|
+
add_library(${PROJECT_NAME}::QUANTILES ALIAS quantiles)
|
|
21
|
+
|
|
22
|
+
if (BUILD_TESTS)
|
|
23
|
+
add_subdirectory(test)
|
|
24
|
+
endif()
|
|
25
|
+
|
|
26
|
+
target_include_directories(quantiles
|
|
27
|
+
INTERFACE
|
|
28
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
29
|
+
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
target_link_libraries(quantiles INTERFACE common)
|
|
33
|
+
target_compile_features(quantiles INTERFACE cxx_std_11)
|
|
34
|
+
|
|
35
|
+
install(TARGETS quantiles
|
|
36
|
+
EXPORT ${PROJECT_NAME}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
install(FILES
|
|
40
|
+
include/quantiles_sketch.hpp
|
|
41
|
+
include/quantiles_sketch_impl.hpp
|
|
42
|
+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/DataSketches")
|