-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #367 from nmslib/develop
Update master to 0.6.1
- Loading branch information
Showing
9 changed files
with
228 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
from pydriller import Repository | ||
import os | ||
import datetime | ||
os.system("cp examples/speedtest.py examples/speedtest2.py") | ||
for commit in Repository('.', from_tag="v0.5.2").traverse_commits(): | ||
print(commit.hash) | ||
print(commit.msg) | ||
os.system("cp examples/speedtest.py examples/speedtest2.py") # the file has to be outside of git | ||
for idx, commit in enumerate(Repository('.', from_tag="v0.6.0").traverse_commits()): | ||
name=commit.msg.replace('\n', ' ').replace('\r', ' ') | ||
print(idx, commit.hash, name) | ||
|
||
|
||
|
||
for commit in Repository('.', from_tag="v0.6.0").traverse_commits(): | ||
|
||
name=commit.msg.replace('\n', ' ').replace('\r', ' ') | ||
print(commit.hash, name) | ||
|
||
os.system(f"git checkout {commit.hash}; rm -rf build; ") | ||
os.system("python -m pip install .") | ||
os.system(f'python examples/speedtest2.py -n "{commit.msg}" -d 4 -t 1') | ||
os.system(f'python examples/speedtest2.py -n "{commit.msg}" -d 64 -t 1') | ||
os.system(f'python examples/speedtest2.py -n "{commit.msg}" -d 128 -t 1') | ||
os.system(f'python examples/speedtest2.py -n "{commit.msg}" -d 4 -t 24') | ||
os.system(f'python examples/speedtest2.py -n "{commit.msg}" -d 128 -t 24') | ||
print("\n\n--------------------\n\n") | ||
ret=os.system("python -m pip install .") | ||
print(ret) | ||
|
||
if ret != 0: | ||
print ("build failed!!!!") | ||
print ("build failed!!!!") | ||
print ("build failed!!!!") | ||
print ("build failed!!!!") | ||
continue | ||
|
||
os.system(f'python examples/speedtest2.py -n "{name}" -d 4 -t 1') | ||
os.system(f'python examples/speedtest2.py -n "{name}" -d 64 -t 1') | ||
os.system(f'python examples/speedtest2.py -n "{name}" -d 128 -t 1') | ||
os.system(f'python examples/speedtest2.py -n "{name}" -d 4 -t 24') | ||
os.system(f'python examples/speedtest2.py -n "{name}" -d 128 -t 24') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import hnswlib | ||
""" | ||
A python wrapper for lazy indexing, preserves the same api as hnswlib.Index but initializes the index only after adding items for the first time with `add_items`. | ||
""" | ||
class LazyIndex(hnswlib.Index): | ||
def __init__(self, space, dim,max_elements=1024, ef_construction=200, M=16): | ||
super().__init__(space, dim) | ||
self.init_max_elements=max_elements | ||
self.init_ef_construction=ef_construction | ||
self.init_M=M | ||
def init_index(self, max_elements=0,M=0,ef_construction=0): | ||
if max_elements>0: | ||
self.init_max_elements=max_elements | ||
if ef_construction>0: | ||
self.init_ef_construction=ef_construction | ||
if M>0: | ||
self.init_M=M | ||
super().init_index(self.init_max_elements, self.init_M, self.init_ef_construction) | ||
def add_items(self, data, ids=None, num_threads=-1): | ||
if self.max_elements==0: | ||
self.init_index() | ||
return super().add_items(data,ids, num_threads) | ||
def get_items(self, ids=None): | ||
if self.max_elements==0: | ||
return [] | ||
return super().get_items(ids) | ||
def knn_query(self, data,k=1, num_threads=-1): | ||
if self.max_elements==0: | ||
return [], [] | ||
return super().knn_query(data, k, num_threads) | ||
def resize_index(self, size): | ||
if self.max_elements==0: | ||
return self.init_index(size) | ||
else: | ||
return super().resize_index(size) | ||
def set_ef(self, ef): | ||
if self.max_elements==0: | ||
self.init_ef_construction=ef | ||
return | ||
super().set_ef(ef) | ||
def get_max_elements(self): | ||
return self.max_elements | ||
def get_current_count(self): | ||
return self.element_count |
Oops, something went wrong.