Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added pickle tests

  • Loading branch information...
commit 46cb7bd4c7a653ad2458daf025b3c96d44a9c699 1 parent 9d74d93
@JohnEmhoff JohnEmhoff authored
Showing with 26 additions and 0 deletions.
  1. +12 −0 hyperloglog/test/test_hll.py
  2. +14 −0 hyperloglog/test/test_shll.py
View
12 hyperloglog/test/test_hll.py
@@ -5,6 +5,8 @@
from const import biasData, tresholdData, rawEstimateData
import math
import os
+import pickle
+
class HyperLogLogTestCase(TestCase):
def test_blobs(self):
@@ -92,3 +94,13 @@ def test_update_err(self):
b = HyperLogLog(0.01)
self.assertRaises(ValueError, a.update, b)
+
+ def test_pickle(self):
+ a = HyperLogLog(0.05)
+ for x in range(100):
+ a.add(str(x))
+ b = pickle.loads(pickle.dumps(a))
+ self.assertEqual(a.M, b.M)
+ self.assertEqual(a.alpha, b.alpha)
+ self.assertEqual(a.p, b.p)
+ self.assertEqual(a.m, b.m)
View
14 hyperloglog/test/test_shll.py
@@ -5,6 +5,8 @@
import time
from unittest import TestCase
from shll import SlidingHyperLogLog
+import pickle
+
class SlidingHyperLogLogTestCase(TestCase):
def test_init(self):
@@ -132,3 +134,15 @@ def test_update_err(self):
b = SlidingHyperLogLog(0.01, 100)
self.assertRaises(ValueError, a.update, b)
+
+ def test_pickle(self):
+ a = SlidingHyperLogLog(0.05, 100)
+ for i in xrange(10000):
+ a.add(i, str('k1-%d' % i))
+
+ b = pickle.loads(pickle.dumps(a))
+ self.assertEqual(a.window, b.window)
+ self.assertEqual(a.alpha, b.alpha)
+ self.assertEqual(a.p, b.p)
+ self.assertEqual(a.m, b.m)
+ self.assertEqual(a.LPFM, b.LPFM)
Please sign in to comment.
Something went wrong with that request. Please try again.