Even when faiss is not installed, faiss.METRIC_L2 is always called, causing the error. This PR fixes it.
Before this PR:
$ make test
...
tests/test_pq.py:7: in <module>
import nanopq
nanopq/__init__.py:4: in <module>
from .convert_faiss import faiss_to_nanopq, nanopq_to_faiss
nanopq/convert_faiss.py:16: in <module>
"l2": faiss.METRIC_L2,
E NameError: name 'faiss' is not defined
============================================================ short test summary info =============================================================
ERROR tests/test_convert_faiss.py - NameError: name 'faiss' is not defined
ERROR tests/test_opq.py - NameError: name 'faiss' is not defined
ERROR tests/test_pq.py - NameError: name 'faiss' is not defined
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================================== 3 errors in 0.51s ================================================================
make: *** [Makefile:4: test] Error 2
With this PR:
$ make test
...
tests/test_opq.py ..... [ 41%]
tests/test_pq.py ....... [100%]
=============================================================================================== 12 passed, 1 skipped in 0.28s ===============================================================================================
Even when faiss is not installed,
faiss.METRIC_L2
is always called, causing the error. This PR fixes it.Before this PR:
With this PR: