Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ jobs:
working-directory: ${{ runner.temp }}
run: python -m unittest discover -s ${GITHUB_WORKSPACE}/bindings/python

- name: Run examples
env:
PYTHONPATH: ${{ runner.temp }}/usr
CTEST_OUTPUT_ON_FAILURE: 1
working-directory: ${{ runner.temp }}
run: python -m unittest discover -p "example*.py" -s ${GITHUB_WORKSPACE}/examples/python
10 changes: 5 additions & 5 deletions examples/python/example_vamana.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
# [imports]

DEBUG_MODE = False
def assert_equal(lhs, rhs, message: str = ""):
def assert_equal(lhs, rhs, message: str = "", epsilon = 0.05):
if DEBUG_MODE:
print(f"{message}: {lhs} == {rhs}")
else:
assert lhs == rhs, message
assert lhs < rhs + epsilon, message
assert lhs > rhs - epsilon, message

def run_test_float(index, queries, groundtruth):
expected = {
Expand Down Expand Up @@ -79,7 +80,6 @@ def run_test_build_two_level4_8(index, queries, groundtruth):
test_data_dir = None

def run():

# ###
# Generating test data
# ###
Expand Down Expand Up @@ -159,7 +159,7 @@ def run():
# Compare with the groundtruth.
recall = svs.k_recall_at(groundtruth, I, 10, 10)
print(f"Recall = {recall}")
assert(recall == 0.8288)
assert_equal(recall, 0.8288)
# [perform-queries]

# [search-window-size]
Expand Down Expand Up @@ -213,7 +213,7 @@ def run():
# Compare with the groundtruth.
recall = svs.k_recall_at(groundtruth, I, 10, 10)
print(f"Recall = {recall}")
assert(recall == 0.8288)
assert_equal(recall, 0.8288)
# [loading]

##### Begin Test
Expand Down
10 changes: 5 additions & 5 deletions examples/python/example_vamana_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
# [imports]

DEBUG_MODE = False
def assert_equal(lhs, rhs, message: str = ""):
def assert_equal(lhs, rhs, message: str = "", epsilon = 0.05):
if DEBUG_MODE:
print(f"{message}: {lhs} == {rhs}")
else:
assert lhs == rhs, message
assert lhs < rhs + epsilon, message
assert lhs > rhs - epsilon, message

def run_test_float(index, queries, groundtruth):
expected = {
Expand Down Expand Up @@ -118,7 +119,7 @@ def run():
# Compare with the groundtruth.
recall = svs.k_recall_at(groundtruth, I, 10, 10)
print(f"Recall = {recall}")
assert(recall == 0.8202)
assert_equal(recall, 0.8202)
# [perform-queries]

##### Begin Test
Expand Down Expand Up @@ -158,8 +159,7 @@ def run():
# Compare with the groundtruth.
recall = svs.k_recall_at(groundtruth, I, 10, 10)
print(f"Recall = {recall}")
assert(recall == 0.8202)

assert_equal(recall, 0.8202)

##### Begin Test
run_test_float(index, queries, groundtruth)
Expand Down
Loading