Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: anas-899/lopq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: pixolution/lopq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 2 commits
  • 9 files changed
  • 1 contributor

Commits on Oct 4, 2022

  1. Fix setup.py to be installable. All requirements are in setup.py. req…

    …uirerments links to setup.py.
    pxl_gpu_lab committed Oct 4, 2022
    Copy the full SHA
    5e4262f View commit details
  2. Migrate code to python3.7 to fix example.py

    pxl_gpu_lab committed Oct 4, 2022
    Copy the full SHA
    123c650 View commit details
Showing with 71 additions and 248 deletions.
  1. +4 −0 .gitignore
  2. +1 −4 python/lopqpy3/__init__.py
  3. +6 −6 python/lopqpy3/eval.py
  4. +20 −199 python/lopqpy3/lopq_model_pb2.py
  5. +13 −18 python/lopqpy3/model.py
  6. +3 −1 python/lopqpy3/utils.py
  7. +9 −6 python/requirements.txt
  8. +4 −4 python/setup.py
  9. +11 −10 scripts/example.py
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# IDE
.idea/
venv/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
5 changes: 1 addition & 4 deletions python/lopqpy3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Copyright 2015, Yahoo Inc.
# Licensed under the terms of the Apache License, Version 2.0. See the LICENSE file associated with the project for terms.
import model
import search
import utils
from .model import LOPQModel
from .search import LOPQSearcher, multisequence

__all__ = [LOPQModel, LOPQSearcher, multisequence, model, search, utils]
__all__ = [LOPQModel, LOPQSearcher, multisequence]
12 changes: 6 additions & 6 deletions python/lopqpy3/eval.py
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ def compute_all_neighbors(data1, data2=None, just_nn=True):
else:
nns = np.zeros(dists.shape, dtype=int)

for i in xrange(dists.shape[0]):
for i in range(dists.shape[0]):
if just_nn:
nns[i] = np.argmin(dists[i])
else:
@@ -55,7 +55,7 @@ def get_proportion_nns_with_same_coarse_codes(data, model, nns=None):

# Count the number of NNs that share the same coarse codes
count = 0
for i in xrange(N):
for i in range(N):
nn = nns[i]
if coarse_codes[i] == coarse_codes[nn]:
count += 1
@@ -111,7 +111,7 @@ def get_recall(searcher, queries, nns, thresholds=[1, 10, 100, 1000], normalize=
:return list:
a list of recalls for each specified threshold level
:return float:
the elapsed query time
the elapsed query time in ns
"""

recall = np.zeros(len(thresholds))
@@ -120,12 +120,12 @@ def get_recall(searcher, queries, nns, thresholds=[1, 10, 100, 1000], normalize=

nn = nns[i]

start = time.clock()
start = time.clock_gettime_ns(time.CLOCK_MONOTONIC)
results, cells_visited = searcher.search(d, thresholds[-1])
query_time += time.clock() - start
query_time += time.clock_gettime_ns(time.CLOCK_MONOTONIC) - start

if verbose and i % 50 == 0:
print '%d cells visitied for query %d' % (cells_visited, i)
print('%d cells visited for query %d' % (cells_visited, i))

for j, res in enumerate(results):
rid, code = res
219 changes: 20 additions & 199 deletions python/lopqpy3/lopq_model_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading