spotify/annoy — pull request #19 by ogrisel (2014-11-07 17:14:18+00:00)
Title: FIX various python 3 compat fixes

Here are some fixes to make annoy run under Python 3 (note `libboost_python.so` needs to be build against the matching version of Python).

I have the following test failures though:

```
======================================================================
FAIL: test_get_nns_by_item (_annoy_test.AngularIndexTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/code/annoy/test/_annoy_test.py", line 48, in test_get_nns_by_item
self.assertEqual(i.get_nns_by_item(0, 3), [0,1,2])
AssertionError: Lists differ: [0, 1] != [0, 1, 2]

Second list contains 1 additional elements.
First extra element 2:
2

- [0, 1]
+ [0, 1, 2]
? +++

======================================================================
FAIL: test_get_nns_by_vector (_annoy_test.AngularIndexTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/code/annoy/test/_annoy_test.py", line 38, in test_get_nns_by_vector
self.assertEqual(i.get_nns_by_vector([3,2,1], 3), [0,1,2])
AssertionError: Lists differ: [0, 1] != [0, 1, 2]

Second list contains 1 additional elements.
First extra element 2:
2

- [0, 1]
+ [0, 1, 2]
? +++

======================================================================
FAIL: test_large_index (_annoy_test.AngularIndexTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/code/annoy/test/_annoy_test.py", line 100, in test_large_index
self.assertEqual(i.get_nns_by_item(j, 2), [j, j+1])
AssertionError: Lists differ: [39, 38] != [144, 145]

First differing element 0:
39
144

- [39, 38]
+ [144, 145]

======================================================================
FAIL: test_large_index (_annoy_test.EuclideanIndexTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/code/annoy/test/_annoy_test.py", line 136, in test_large_index
self.assertEqual(i.get_nns_by_item(j, 2), [j, j+1])
AssertionError: Lists differ: [27, 26] != [154, 155]

First differing element 0:
27
154

- [27, 26]
+ [154, 155]

======================================================================
FAIL: test_precision_10 (_annoy_test.EuclideanIndexTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/code/annoy/test/_annoy_test.py", line 161, in test_precision_10
self.assertEqual(self.precision(10), 1.0)
AssertionError: 0.3 != 1.0

======================================================================
FAIL: test_precision_100 (_annoy_test.EuclideanIndexTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/code/annoy/test/_annoy_test.py", line 164, in test_precision_100
self.assertGreaterEqual(self.precision(100), 0.99)
AssertionError: 0.83 not greater than or equal to 0.99

======================================================================
FAIL: test_precision_1000 (_annoy_test.EuclideanIndexTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/code/annoy/test/_annoy_test.py", line 167, in test_precision_1000
self.assertGreaterEqual(self.precision(1000), 0.99)
AssertionError: 0.892 not greater than or equal to 0.99

----------------------------------------------------------------------
Ran 15 tests in 3.827s
```

I will try to rebuilt everything under Python 2.7 to check if I reproduce those failures there. It might not be related to the python version but to the gcc / libboost version. In my case I built it with:

- gcc / g++ 4.9.1
- libboost-python-dev 1.55.0.2

under Debian Jessie.