def test_ordering(self):
    hash_a = HashFunction(1, 3)
    hash_b = HashFunction(1, 5)
    hash_c = HashFunction(1, 5)
    hash_d = HashFunction(2, 5)

    self.assertLess(hash_a, hash_b)
    self.assertLess(hash_c, hash_d)
  def __init__(self, num_buckets, random_seed):
    """Creates a vector of counts sketch.

    Args:
      num_buckets: the number of buckets of the VectorOfCounts.
      random_seed: a random seed for the hash function.
    """
    SketchBase.__init__(self)
    self._num_buckets = num_buckets
    self.stats = np.zeros(num_buckets)
    self.hash_function = HashFunction(random_seed, num_buckets)
    self._vectorized_hash_function = np.vectorize(self.hash_function)
    self._ids_added = False
 def test_modulus_too_big(self):
   self.assertRaises(ValueError, lambda: HashFunction(42, 2**65))
 def test_hashing(self):
   hash_a = HashFunction(1, 3)
   hash_b = HashFunction(1, 3)
   x = 137
   self.assertEqual(hash_a(x), hash_b(x))
  def test_equality(self):
    hash_a = HashFunction(1, 3)
    hash_b = HashFunction(1, 3)

    self.assertEqual(hash_a, hash_b)
  def test_inequality_mod(self):
    hash_a = HashFunction(1, 5)
    hash_b = HashFunction(1, 3)

    self.assertNotEqual(hash_a, hash_b)