def test_save_cache_remove_from_index(self) -> None: # Test that the cache is updated appropriately on a removal. cache_element = DataMemoryElement() self.assertTrue(cache_element.is_empty()) i = LinearHashIndex(cache_element) # noinspection PyTypeChecker i.build_index([ [0, 1, 0], # 2 [0, 1, 1], # 3 [1, 0, 0], # 4 [1, 1, 0] ]) # 6 self.assertFalse(cache_element.is_empty()) self.assertSetEqual( set(numpy.load(BytesIO(cache_element.get_bytes()))), {2, 3, 4, 6}) # noinspection PyTypeChecker i.remove_from_index([ [0, 1, 1], # 3 [1, 0, 0] ]) # 4 self.assertFalse(cache_element.is_empty()) self.assertSetEqual( set(numpy.load(BytesIO(cache_element.get_bytes()))), {2, 6})
def test_remove_from_index(self) -> None: # Test that actual removal occurs. i = LinearHashIndex() i.index = {0, 1, 2} # noinspection PyTypeChecker i.remove_from_index([[0, 0], [1, 0]]) self.assertSetEqual(i.index, {1})