diff --git a/src/annoylib.h b/src/annoylib.h index 7bfaa108..7f32b22d 100644 --- a/src/annoylib.h +++ b/src/annoylib.h @@ -763,7 +763,7 @@ template _allocate_size(_n_nodes + 1); S item = _n_nodes++; Node* m = _get(item); - m->n_descendants = (S)indices.size(); + m->n_descendants = is_root ? _n_items : (S)indices.size(); // Using std::copy instead of a loop seems to resolve issues #3 and #13, // probably because gcc 4.8 goes overboard with optimizations. @@ -814,7 +814,7 @@ template int flip = (children_indices[0].size() > children_indices[1].size()); - m->n_descendants = (S)indices.size(); + m->n_descendants = is_root ? _n_items : (S)indices.size(); for (int side = 0; side < 2; side++) // run _make_tree for the smallest child first (for cache locality) m->children[side^flip] = _make_tree(children_indices[side^flip], false); diff --git a/test/index_test.py b/test/index_test.py index 074754ef..351e5f1c 100644 --- a/test/index_test.py +++ b/test/index_test.py @@ -15,7 +15,6 @@ import random from common import TestCase from annoy import AnnoyIndex -from nose.plugins.skip import SkipTest class IndexTest(TestCase): @@ -99,7 +98,6 @@ def test_metric_kwarg(self): def test_metric_f_kwargs(self): i = AnnoyIndex(f=3, metric='euclidean') - @SkipTest def test_item_vector_after_save(self): # Issue #279 a = AnnoyIndex(3)