usearch 0.16.2 → 0.17.0

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.
@@ -17,7 +17,7 @@ permissions:
17
17
 
18
18
  jobs:
19
19
 
20
- test_python:
20
+ test_python_311:
21
21
  name: Test Python
22
22
  runs-on: ${{ matrix.os }}
23
23
  strategy:
@@ -41,6 +41,36 @@ jobs:
41
41
  - name: Test with PyTest
42
42
  run: pytest python/scripts/test.py
43
43
 
44
+
45
+ test_python_36:
46
+ name: Test Python 3.6
47
+ runs-on: ${{ matrix.os }}
48
+ strategy:
49
+ matrix:
50
+ os: [ubuntu-20.04]
51
+ python-version: ["3.6"]
52
+
53
+ steps:
54
+ - uses: actions/checkout@v3
55
+ - run: git submodule update --init --recursive
56
+
57
+ - name: Set up Python ${{ matrix.python-version }}
58
+ uses: actions/setup-python@v4
59
+ with:
60
+ python-version: ${{ matrix.python-version }}
61
+
62
+ - name: Install dependencies
63
+ run: |
64
+ python -m pip install --upgrade pip
65
+ pip install pytest numpy dataclasses
66
+
67
+ - name: Build locally
68
+ run: python -m pip install .
69
+
70
+ - name: Test with PyTest
71
+ run: pytest python/scripts/test.py
72
+
73
+
44
74
  test_javascript:
45
75
  name: Test JavaScript
46
76
  runs-on: ubuntu-latest
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "usearch"
3
- version = "0.16.2"
3
+ version = "0.17.0"
4
4
  authors = ["Ashot Vardanian <1983160+ashvardanian@users.noreply.github.com>"]
5
5
  description = "Smaller & Faster Single-File Vector Search Engine from Unum"
6
6
  edition = "2021"
package/conanfile.py CHANGED
@@ -4,7 +4,7 @@ from conans import ConanFile
4
4
  class USearchConan(ConanFile):
5
5
 
6
6
  name = 'USearch'
7
- version = '0.16.2'
7
+ version = '0.17.0'
8
8
  license = 'Apache 2.0'
9
9
  url = 'https://github.com/unum-cloud/usearch'
10
10
  description = 'Smaller & Faster Single-File Vector Search Engine from Unum'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usearch",
3
- "version": "0.16.2",
3
+ "version": "0.17.0",
4
4
  "description": "Smaller & Faster Single-File Vector Search Engine from Unum",
5
5
  "author": "Ashot Vardanian",
6
6
  "license": "Apache 2.0",
@@ -1,6 +1,4 @@
1
- from time import time_ns
2
- from typing import Tuple, Any, Callable, Union, Optional, List
3
- from dataclasses import dataclass, asdict
1
+ from typing import Tuple, Any, Callable, Union, Optional, List, NamedTuple
4
2
  from collections import defaultdict
5
3
 
6
4
  import numpy as np
@@ -9,6 +7,17 @@ from usearch.io import load_matrix
9
7
  from usearch.index import Index, Matches, MetricKind, MetricKindBitwise
10
8
 
11
9
 
10
+ # For compatibility with Python 3.6
11
+ try:
12
+ from time import time_ns
13
+ except ImportError:
14
+ from datetime import datetime
15
+
16
+ def time_ns():
17
+ now = datetime.now()
18
+ return int(now.timestamp() * 1e9)
19
+
20
+
12
21
  def random_vectors(
13
22
  count: int,
14
23
  metric: MetricKind = MetricKind.IP,
@@ -80,8 +89,7 @@ def measure_seconds(f: Callable) -> Tuple[float, Any]:
80
89
  return secs, result
81
90
 
82
91
 
83
- @dataclass
84
- class Dataset:
92
+ class Dataset(NamedTuple):
85
93
 
86
94
  labels: np.ndarray
87
95
  vectors: np.ndarray
@@ -155,8 +163,7 @@ class Dataset:
155
163
  return d
156
164
 
157
165
 
158
- @dataclass
159
- class TaskResult:
166
+ class TaskResult(NamedTuple):
160
167
 
161
168
  add_operations: Optional[int] = None
162
169
  add_per_second: Optional[float] = None
@@ -183,7 +190,7 @@ class TaskResult:
183
190
  def search_seconds(self) -> float:
184
191
  return self.search_operations / self.search_per_second
185
192
 
186
- def __add__(self, other: TaskResult):
193
+ def __add__(self, other):
187
194
  result = TaskResult()
188
195
  if self.add_operations and other.add_operations:
189
196
  result.add_operations = self.add_operations + other.add_operations
@@ -210,8 +217,7 @@ class TaskResult:
210
217
  return result
211
218
 
212
219
 
213
- @dataclass
214
- class AddTask:
220
+ class AddTask(NamedTuple):
215
221
 
216
222
  labels: np.ndarray
217
223
  vectors: np.ndarray
@@ -274,8 +280,7 @@ class AddTask:
274
280
  ) for rows in partitioning.values()]
275
281
 
276
282
 
277
- @dataclass
278
- class SearchTask:
283
+ class SearchTask(NamedTuple):
279
284
 
280
285
  queries: np.ndarray
281
286
  neighbors: np.ndarray
@@ -300,8 +305,7 @@ class SearchTask:
300
305
  ) for start_row in range(0, self.queries.shape[0], batch_size)]
301
306
 
302
307
 
303
- @dataclass
304
- class Evaluation:
308
+ class Evaluation(NamedTuple):
305
309
 
306
310
  tasks: List[Union[AddTask, SearchTask]]
307
311
  count: int
@@ -352,5 +356,5 @@ class Evaluation:
352
356
  index.clear()
353
357
  return {
354
358
  **index.specs,
355
- **asdict(task_result),
359
+ **task_result._asdict(),
356
360
  }