Skip to content

Commit 06618d3

Browse files
committed
fix(bloomfilter): use dynamic tolerance for prop_calc_size_fpr_bits
1 parent 9cea689 commit 06618d3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bloomfilter/tests/bloomfilter-tests.hs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,20 @@ prop_calc_size_fpr_fpr proxy (FPR fpr) (NumEntries numEntries) =
172172
-- | Compare @sizeForBits@ against @falsePositiveRate@ with some tolerance for deviations
173173
prop_calc_size_fpr_bits :: BloomFilter bloom => Proxy bloom
174174
-> BitsPerEntry -> NumEntries -> Property
175-
prop_calc_size_fpr_bits proxy (BitsPerEntry c) (NumEntries numEntries) =
176-
let policy = policyForBits proxy c
175+
prop_calc_size_fpr_bits proxy (BitsPerEntry bpe) (NumEntries numEntries) =
176+
let policy = policyForBits proxy bpe
177177
bsize = sizeForPolicy proxy policy numEntries
178178
in falsePositiveRate (fromIntegral (B.sizeBits bsize))
179179
(fromIntegral numEntries)
180180
(fromIntegral (B.sizeHashes bsize))
181181
~~~ policyFPR proxy policy
182182
where
183-
(~~~) = withinTolerance 1e-6
183+
(~~~) = withinTolerance tolerance
184+
tolerance | bpe >= 18 = 1e-7
185+
| bpe >= 13 = 1e-6
186+
| bpe >= 8 = 1e-5
187+
| bpe >= 4 = 1e-4
188+
| otherwise = 1e-3
184189

185190
-- reference implementations used for sanity checks
186191

0 commit comments

Comments
 (0)