Exemplo n.º 1
0
import unittest.mock as mock
import random
import unittest

import numpy
import pytest

from smqtk.algorithms import NearestNeighborsIndex
from smqtk.algorithms.nn_index.flann import FlannNearestNeighborsIndex
from smqtk.representation.descriptor_element.local_elements import \
    DescriptorMemoryElement
from smqtk.utils.configuration import configuration_test_helper


# Don't bother running tests of the class is not usable
@pytest.mark.skipif(not FlannNearestNeighborsIndex.is_usable(),
                    reason="FlannNearestNeighborsIndex does not report as "
                    "usable.")
class TestFlannIndex(unittest.TestCase):

    RAND_SEED = 42

    def _make_inst(self, dist_method):
        """
        Make an instance of FlannNearestNeighborsIndex
        """
        return FlannNearestNeighborsIndex(distance_method=dist_method,
                                          random_seed=self.RAND_SEED)

    def test_impl_findable(self):
        # Already here because the implementation is reporting itself as
Exemplo n.º 2
0
import random
import unittest

import nose.tools as ntools
import numpy

from smqtk.representation.descriptor_element.local_elements import \
    DescriptorMemoryElement
from smqtk.algorithms.nn_index.flann import FlannNearestNeighborsIndex
from smqtk.utils.file_utils import make_tempfile

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


# Don't bother running tests of the class is not usable
if FlannNearestNeighborsIndex.is_usable():

    class TestFlannIndex (unittest.TestCase):

        FLANN_INDEX_CACHE = None
        FLANN_PARAMETER_CACHE = None
        FLANN_DESCR_CACHE = None

        RAND_SEED = 42

        @classmethod
        def _make_cache_files(cls):
            cls.FLANN_INDEX_CACHE = make_tempfile('.flann')
            cls.FLANN_PARAMETER_CACHE = make_tempfile('.pickle')
            cls.FLANN_DESCR_CACHE = make_tempfile('.pickle')
Exemplo n.º 3
0
import os
import random
import unittest

import nose.tools as ntools
import numpy

from smqtk.representation.descriptor_element.local_elements import \
    DescriptorMemoryElement
from smqtk.algorithms.nn_index.flann import FlannNearestNeighborsIndex

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

# Don't bother running tests of the class is not usable
if FlannNearestNeighborsIndex.is_usable():

    class TestFlannIndex(unittest.TestCase):

        RAND_SEED = 42

        def _make_inst(self, dist_method):
            """
            Make an instance of FlannNearestNeighborsIndex
            """
            return FlannNearestNeighborsIndex(distance_method=dist_method,
                                              random_seed=self.RAND_SEED)

        def test_known_descriptors_euclidean_unit(self):
            dim = 5

            ###