vicinity 0.3.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vicinity-0.3.0 → vicinity-0.3.1}/PKG-INFO +2 -3
- {vicinity-0.3.0 → vicinity-0.3.1}/README.md +1 -2
- {vicinity-0.3.0 → vicinity-0.3.1}/uv.lock +19 -1
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/backends/basic.py +12 -7
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/version.py +1 -1
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity.egg-info/PKG-INFO +2 -3
- {vicinity-0.3.0 → vicinity-0.3.1}/.github/workflows/ci.yaml +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/.gitignore +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/.pre-commit-config.yaml +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/LICENSE +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/Makefile +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/pyproject.toml +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/setup.cfg +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/tests/conftest.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/tests/test_utils.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/tests/test_vicinity.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/__init__.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/backends/__init__.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/backends/annoy.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/backends/base.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/backends/faiss.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/backends/hnsw.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/backends/pynndescent.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/backends/usearch.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/datatypes.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/py.typed +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/utils.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity/vicinity.py +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity.egg-info/SOURCES.txt +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity.egg-info/dependency_links.txt +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity.egg-info/requires.txt +0 -0
- {vicinity-0.3.0 → vicinity-0.3.1}/vicinity.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vicinity
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Lightweight Nearest Neighbors with Flexible Backends
|
|
5
5
|
Author-email: Stéphan Tulkens <stephantul@gmail.com>, Thomas van Dongen <thomas123@live.nl>
|
|
6
6
|
License: MIT License
|
|
@@ -127,8 +127,7 @@ pip install vicinity[all]
|
|
|
127
127
|
The following code snippet demonstrates how to use Vicinity for nearest neighbor search:
|
|
128
128
|
```python
|
|
129
129
|
import numpy as np
|
|
130
|
-
from vicinity import Vicinity
|
|
131
|
-
from vicinity.datatypes import Backend, Metric
|
|
130
|
+
from vicinity import Vicinity, Backend, Metric
|
|
132
131
|
|
|
133
132
|
# Create some dummy data
|
|
134
133
|
items = ["triforce", "master sword", "hylian shield", "boomerang", "hookshot"]
|
|
@@ -48,8 +48,7 @@ pip install vicinity[all]
|
|
|
48
48
|
The following code snippet demonstrates how to use Vicinity for nearest neighbor search:
|
|
49
49
|
```python
|
|
50
50
|
import numpy as np
|
|
51
|
-
from vicinity import Vicinity
|
|
52
|
-
from vicinity.datatypes import Backend, Metric
|
|
51
|
+
from vicinity import Vicinity, Backend, Metric
|
|
53
52
|
|
|
54
53
|
# Create some dummy data
|
|
55
54
|
items = ["triforce", "master sword", "hylian shield", "boomerang", "hookshot"]
|
|
@@ -1087,7 +1087,7 @@ wheels = [
|
|
|
1087
1087
|
|
|
1088
1088
|
[[package]]
|
|
1089
1089
|
name = "vicinity"
|
|
1090
|
-
version = "0.
|
|
1090
|
+
version = "0.3.0"
|
|
1091
1091
|
source = { editable = "." }
|
|
1092
1092
|
dependencies = [
|
|
1093
1093
|
{ name = "numpy" },
|
|
@@ -1096,6 +1096,16 @@ dependencies = [
|
|
|
1096
1096
|
]
|
|
1097
1097
|
|
|
1098
1098
|
[package.optional-dependencies]
|
|
1099
|
+
all = [
|
|
1100
|
+
{ name = "annoy" },
|
|
1101
|
+
{ name = "faiss-cpu" },
|
|
1102
|
+
{ name = "hnswlib" },
|
|
1103
|
+
{ name = "llvmlite" },
|
|
1104
|
+
{ name = "numba" },
|
|
1105
|
+
{ name = "numpy" },
|
|
1106
|
+
{ name = "pynndescent" },
|
|
1107
|
+
{ name = "usearch" },
|
|
1108
|
+
]
|
|
1099
1109
|
annoy = [
|
|
1100
1110
|
{ name = "annoy" },
|
|
1101
1111
|
]
|
|
@@ -1127,24 +1137,32 @@ usearch = [
|
|
|
1127
1137
|
|
|
1128
1138
|
[package.metadata]
|
|
1129
1139
|
requires-dist = [
|
|
1140
|
+
{ name = "annoy", marker = "extra == 'all'" },
|
|
1130
1141
|
{ name = "annoy", marker = "extra == 'annoy'" },
|
|
1131
1142
|
{ name = "black", marker = "extra == 'dev'" },
|
|
1143
|
+
{ name = "faiss-cpu", marker = "extra == 'all'" },
|
|
1132
1144
|
{ name = "faiss-cpu", marker = "extra == 'faiss'" },
|
|
1145
|
+
{ name = "hnswlib", marker = "extra == 'all'" },
|
|
1133
1146
|
{ name = "hnswlib", marker = "extra == 'hnsw'" },
|
|
1134
1147
|
{ name = "ipython", marker = "extra == 'dev'" },
|
|
1148
|
+
{ name = "llvmlite", marker = "extra == 'all'", specifier = ">=0.42.0" },
|
|
1135
1149
|
{ name = "llvmlite", marker = "extra == 'pynndescent'", specifier = ">=0.42.0" },
|
|
1136
1150
|
{ name = "mypy", marker = "extra == 'dev'" },
|
|
1151
|
+
{ name = "numba", marker = "extra == 'all'", specifier = ">=0.59.0" },
|
|
1137
1152
|
{ name = "numba", marker = "extra == 'pynndescent'", specifier = ">=0.59.0" },
|
|
1138
1153
|
{ name = "numpy" },
|
|
1154
|
+
{ name = "numpy", marker = "extra == 'all'", specifier = ">=1.24.0" },
|
|
1139
1155
|
{ name = "numpy", marker = "extra == 'pynndescent'", specifier = ">=1.24.0" },
|
|
1140
1156
|
{ name = "orjson" },
|
|
1141
1157
|
{ name = "pre-commit", marker = "extra == 'dev'" },
|
|
1158
|
+
{ name = "pynndescent", marker = "extra == 'all'", specifier = ">=0.5.10" },
|
|
1142
1159
|
{ name = "pynndescent", marker = "extra == 'pynndescent'", specifier = ">=0.5.10" },
|
|
1143
1160
|
{ name = "pytest", marker = "extra == 'dev'" },
|
|
1144
1161
|
{ name = "pytest-coverage", marker = "extra == 'dev'" },
|
|
1145
1162
|
{ name = "ruff", marker = "extra == 'dev'" },
|
|
1146
1163
|
{ name = "setuptools", marker = "extra == 'dev'" },
|
|
1147
1164
|
{ name = "tqdm" },
|
|
1165
|
+
{ name = "usearch", marker = "extra == 'all'" },
|
|
1148
1166
|
{ name = "usearch", marker = "extra == 'usearch'" },
|
|
1149
1167
|
]
|
|
1150
1168
|
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
4
|
from dataclasses import dataclass
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Any, Literal
|
|
6
|
+
from typing import Any, Literal, Union
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
9
|
from numpy import typing as npt
|
|
@@ -15,7 +15,7 @@ from vicinity.utils import Metric, normalize, normalize_or_copy
|
|
|
15
15
|
|
|
16
16
|
@dataclass
|
|
17
17
|
class BasicArgs(BaseArgs):
|
|
18
|
-
metric:
|
|
18
|
+
metric: str = "cosine"
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class BasicBackend(AbstractBackend[BasicArgs], ABC):
|
|
@@ -66,15 +66,20 @@ class BasicBackend(AbstractBackend[BasicArgs], ABC):
|
|
|
66
66
|
raise NotImplementedError()
|
|
67
67
|
|
|
68
68
|
@classmethod
|
|
69
|
-
def from_vectors(cls, vectors: npt.NDArray, **kwargs: Any) -> BasicBackend:
|
|
69
|
+
def from_vectors(cls, vectors: npt.NDArray, metric: Union[str, Metric] = "cosine", **kwargs: Any) -> BasicBackend:
|
|
70
70
|
"""Create a new instance from vectors."""
|
|
71
|
-
|
|
72
|
-
if
|
|
71
|
+
metric_enum = Metric.from_string(metric)
|
|
72
|
+
if metric_enum not in cls.supported_metrics:
|
|
73
|
+
raise ValueError(f"Metric '{metric_enum.value}' is not supported by BasicBackend.")
|
|
74
|
+
|
|
75
|
+
metric = metric_enum.value
|
|
76
|
+
arguments = BasicArgs(metric=metric)
|
|
77
|
+
if metric == "cosine":
|
|
73
78
|
return CosineBasicBackend(vectors, arguments)
|
|
74
|
-
elif
|
|
79
|
+
elif metric == "euclidean":
|
|
75
80
|
return EuclideanBasicBackend(vectors, arguments)
|
|
76
81
|
else:
|
|
77
|
-
raise ValueError(f"Unsupported metric: {
|
|
82
|
+
raise ValueError(f"Unsupported metric: {metric}")
|
|
78
83
|
|
|
79
84
|
@classmethod
|
|
80
85
|
def load(cls, folder: Path) -> BasicBackend:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version_triple__ = (0, 3,
|
|
1
|
+
__version_triple__ = (0, 3, 1)
|
|
2
2
|
__version__ = ".".join(map(str, __version_triple__))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vicinity
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Lightweight Nearest Neighbors with Flexible Backends
|
|
5
5
|
Author-email: Stéphan Tulkens <stephantul@gmail.com>, Thomas van Dongen <thomas123@live.nl>
|
|
6
6
|
License: MIT License
|
|
@@ -127,8 +127,7 @@ pip install vicinity[all]
|
|
|
127
127
|
The following code snippet demonstrates how to use Vicinity for nearest neighbor search:
|
|
128
128
|
```python
|
|
129
129
|
import numpy as np
|
|
130
|
-
from vicinity import Vicinity
|
|
131
|
-
from vicinity.datatypes import Backend, Metric
|
|
130
|
+
from vicinity import Vicinity, Backend, Metric
|
|
132
131
|
|
|
133
132
|
# Create some dummy data
|
|
134
133
|
items = ["triforce", "master sword", "hylian shield", "boomerang", "hookshot"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|