import os
import tempfile
import unittest

import mock
import nose.tools
import numpy

from smqtk.algorithms.nn_index.hash_index.sklearn_balltree import \
    SkLearnBallTreeHashIndex


__author__ = "*****@*****.**"


if SkLearnBallTreeHashIndex.is_usable():

    class TestBallTreeHashIndex (unittest.TestCase):

        def test_file_cache_type(self):
            # Requites .npz file
            nose.tools.assert_raises(
                ValueError,
                SkLearnBallTreeHashIndex,
                file_cache='some_file.txt'
            )

            SkLearnBallTreeHashIndex(file_cache='some_file.npz')

        @mock.patch('smqtk.algorithms.nn_index.hash_index.sklearn_balltree.numpy.savez')
        def test_save_model_no_cache(self, m_savez):
Exemple #2
0
 def test_is_usable(self):
     # Should always be true because major dependency (sklearn) is a package
     # requirement.
     self.assertTrue(SkLearnBallTreeHashIndex.is_usable())