Skip to content

Commit

Permalink
resolve travis build error
Browse files Browse the repository at this point in the history
  • Loading branch information
gony-noreply committed Feb 17, 2020
1 parent c809da5 commit 735830d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/hnsw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using std::move;
using std::pair;
using std::runtime_error;
using std::string;
using std::to_string;
using std::vector;

Hnsw::Hnsw() : Hnsw(0) {}
Expand Down Expand Up @@ -126,7 +127,12 @@ bool Hnsw::SaveModel(const string& fname) const {

bool Hnsw::LoadModel(const string& fname, const bool use_mmap) {
model_ = HnswModel::LoadModelFromFile(fname, use_mmap);
data_dim_ = model_->GetDataDim();
size_t model_data_dim = model_->GetDataDim();
if (data_dim_ > 0 && data_dim_ != model_data_dim) {
throw runtime_error("[Error] index dimension(" + to_string(data_dim_)
+ ") != model dimension(" + to_string(model_data_dim) + ")");
}
data_dim_ = model_data_dim;
metric_ = model_->GetMetric();
searcher_ = HnswSearch::GenerateSearcher(model_, data_dim_, metric_);
return true;
Expand Down
4 changes: 2 additions & 2 deletions tests/python_test/test_n2.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def test_search_by_vector(self):
i.add_data([1, 0, 0])
i.build(max_m0=10, m=5)

self.assertEqual(i.search_by_vector([3, 2, 1], 3), [0, 1, 2])
self.assertEqual(i.search_by_vector([3, 2, 1], 3), [2, 1, 0])
self.assertEqual(i.search_by_vector([1, 2, 3], 3), [0, 1, 2])
self.assertEqual(i.search_by_vector([2, 0, 1], 3), [0, 1, 2])
self.assertEqual(i.search_by_vector([2, 0, 1], 3), [2, 0, 1])

def test_search_by_id(self):
f = 3
Expand Down

0 comments on commit 735830d

Please sign in to comment.