From e8d1cfa077f377928c066944598ed4ad03c0a99e Mon Sep 17 00:00:00 2001 From: Eric Zhu Date: Wed, 6 Sep 2023 02:02:00 -0700 Subject: [PATCH] HNSW Doc (#222) --- datasketch/hnsw.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/datasketch/hnsw.py b/datasketch/hnsw.py index f1e28e9f..a1c2e298 100644 --- a/datasketch/hnsw.py +++ b/datasketch/hnsw.py @@ -117,10 +117,10 @@ def __init__( def __len__(self) -> int: return len(self._data) - def __contains__(self, key) -> bool: + def __contains__(self, key: Any) -> bool: return key in self._data - def __getitem__(self, key) -> np.ndarray: + def __getitem__(self, key: Any) -> np.ndarray: """Get the point associated with the key.""" return self._data[key] @@ -152,7 +152,8 @@ def insert( """Add a new point to the index. Args: - key (Any): The key of the new point. + key (Any): The key of the new point. If the key already exists in the + index, the point will be updated and the index will be repaired. new_point (np.ndarray): The new point to add to the index. ef (Optional[int]): The number of neighbors to consider during insertion. level (Optional[int]): The level at which to insert the new point.