Skip to content

Commit

Permalink
fix:calculation of elements_added on join (#119)
Browse files Browse the repository at this point in the history
* fix:calculation of elements_added on join
  • Loading branch information
cunla committed Jan 25, 2024
1 parent bd18c23 commit 505777b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion probables/countminsketch/countminsketch.py
Expand Up @@ -391,7 +391,7 @@ def join(self, second: "CountMinSketch") -> None:
self._bins[i] = tmp_els

# handle adding and removing elements added including handling overflow
self.__elements_added += self.elements_added
self.__elements_added += second.elements_added

if self.elements_added > INT64_T_MAX:
self.__elements_added = INT64_T_MAX
Expand Down
1 change: 1 addition & 0 deletions tests/countminsketch_test.py
Expand Up @@ -322,6 +322,7 @@ def test_cms_join(self):
self.assertEqual(189 * 2, cms1.check("this is another test"))
self.assertEqual(16 * 2, cms1.check("this is also a test"))
self.assertEqual(5 * 2, cms1.check("this is something to test"))
self.assertEqual(cms1.elements_added, (255 + 189 + 16 + 5) * 2)

def test_cms_join_overflow(self):
"""test count-min sketch overflow"""
Expand Down

0 comments on commit 505777b

Please sign in to comment.