Skip to content

Commit

Permalink
fuck scipy
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Bernhardsson committed Aug 27, 2016
1 parent 992f2e6 commit 2838032
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 6 additions & 4 deletions test/annoy_test.py
Expand Up @@ -20,7 +20,9 @@
import numpy
import multiprocessing.pool
from annoy import AnnoyIndex
from scipy.spatial.distance import cosine, euclidean
# Travis craps out on Scipy sadly
# from scipy.spatial.distance import cosine, euclidean


try:
xrange
Expand Down Expand Up @@ -209,9 +211,9 @@ def test_distance_consistency(self):
v = i.get_item_vector(b)
u_norm = numpy.array(u) * numpy.dot(u, u)**-0.5
v_norm = numpy.array(v) * numpy.dot(v, v)**-0.5
cos = numpy.clip(1 - cosine(u, v), -1, 1) # scipy returns 1 - cos
# cos = numpy.clip(1 - cosine(u, v), -1, 1) # scipy returns 1 - cos
self.assertAlmostEqual(dist, numpy.dot(u_norm - v_norm, u_norm - v_norm) ** 0.5)
self.assertAlmostEqual(dist, (2*(1 - cos))**0.5)
# self.assertAlmostEqual(dist, (2*(1 - cos))**0.5)
self.assertAlmostEqual(dist, sum([(x-y)**2 for x, y in zip(u_norm, v_norm)])**0.5)


Expand Down Expand Up @@ -343,7 +345,7 @@ def test_distance_consistency(self):
self.assertAlmostEqual(dist, i.get_distance(a, b))
u = numpy.array(i.get_item_vector(a))
v = numpy.array(i.get_item_vector(b))
self.assertAlmostEqual(dist, euclidean(u, v))
# self.assertAlmostEqual(dist, euclidean(u, v))
self.assertAlmostEqual(dist, numpy.dot(u - v, u - v) ** 0.5)
self.assertAlmostEqual(dist, sum([(x-y)**2 for x, y in zip(u, v)])**0.5)

Expand Down
1 change: 0 additions & 1 deletion tox.ini
Expand Up @@ -6,7 +6,6 @@ setenv =
TRAVIS = {env:TRAVIS:}
commands =
pip install numpy
sudo apt-get install python-scipy
pip install .
python setup.py nosetests

Expand Down

0 comments on commit 2838032

Please sign in to comment.