add stubs for "annoy" (#5319)

This change adds type stubs for the "annoy" package: https://github.com/spotify/annoy
This commit is contained in:
Christopher Dignam
2021-05-03 23:49:52 -04:00
committed by GitHub
parent dbaf4c6390
commit 30154447e7
2 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
version = "1.17"
requires = []

View File

@@ -0,0 +1,41 @@
from typing import Sequence, overload
from typing_extensions import Literal
class AnnoyIndex:
f: int
def __init__(self, f: int, metric: Literal["angular", "euclidean", "manhattan", "hamming", "dot"]) -> None: ...
def load(self, fn: str, prefault: bool = ...) -> Literal[True]: ...
def save(self, fn: str, prefault: bool = ...) -> Literal[True]: ...
@overload
def get_nns_by_item(self, i: int, n: int, search_k: int = ..., include_distances: Literal[False] = ...) -> list[int]: ...
@overload
def get_nns_by_item(
self, i: int, n: int, search_k: int, include_distances: Literal[True]
) -> tuple[list[int], list[float]]: ...
@overload
def get_nns_by_item(
self, i: int, n: int, search_k: int = ..., *, include_distances: Literal[True]
) -> tuple[list[int], list[float]]: ...
@overload
def get_nns_by_vector(
self, vector: Sequence[float], n: int, search_k: int = ..., include_distances: Literal[False] = ...
) -> list[int]: ...
@overload
def get_nns_by_vector(
self, vector: Sequence[float], n: int, search_k: int, include_distances: Literal[True]
) -> tuple[list[int], list[float]]: ...
@overload
def get_nns_by_vector(
self, vector: Sequence[float], n: int, search_k: int = ..., *, include_distances: Literal[True]
) -> tuple[list[int], list[float]]: ...
def get_item_vector(self, __i: int) -> list[float]: ...
def add_item(self, i: int, vector: Sequence[float]) -> None: ...
def on_disk_build(self, fn: str) -> Literal[True]: ...
def build(self, n_trees: int, n_jobs: int = ...) -> Literal[True]: ...
def unbuild(self) -> Literal[True]: ...
def unload(self) -> Literal[True]: ...
def get_distance(self, __i: int, __j: int) -> float: ...
def get_n_items(self) -> int: ...
def get_n_trees(self) -> int: ...
def verbose(self, __v: bool) -> Literal[True]: ...
def set_seed(self, __s: int) -> None: ...