Commit c691dac9 authored by Jay's avatar Jay Committed by jay
Browse files

Additional coverage updates for transformations

parent b3fa8451
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -79,11 +79,6 @@ class TestCandidateGraph(unittest.TestCase):
        os.remove('test_save.cg')

    def test_save_load_features(self):
        for i in ['all_out.hdf', 'one_out.hdf']:
            try:
                os.remove(i)
            except: pass

        graph = self.graph.copy()
        graph.extract_features(extractor_parameters={'nfeatures': 10})
        graph.save_features('all_out.hdf')
+8 −2
Original line number Diff line number Diff line
@@ -37,9 +37,15 @@ class TestHomography(unittest.TestCase):
        self.assertAlmostEqual(error.x_rms, 0.0, 1)
        self.assertAlmostEqual(error.y_rms, 0.0, 1)

    def test_Homography_fail(self):
        self.assertRaises(TypeError, transformations.Homography, [1, 2, 3], 'a', 'b')
        description = H.describe_error
        self.assertIsInstance(description, pd.DataFrame)

    def test_Homography_fail(self):
        with self.assertRaises(TypeError):
            h = transformations.Homography([1,2,3], np.arange(3), np.arange(3), None)
        with self.assertRaises(ValueError):
            h = transformations.Homography(np.arange(4).reshape(2,2),
                                           np.arange(3), np.arange(3), None)

class TestFundamentalMatrix(unittest.TestCase):

+1 −6
Original line number Diff line number Diff line
@@ -19,13 +19,12 @@ class TransformationMatrix(np.ndarray):

    @abc.abstractmethod
    def __new__(cls, inputarr, x1, x2, mask):
        obj = np.asarray(inputarr).view(cls)

        if not isinstance(inputarr, np.ndarray):
            raise TypeError('The homography must be an ndarray')
        if not inputarr.shape[0] == 3 and not inputarr.shape[1] == 3:
            raise ValueError('The homography must be a 3x3 matrix.')

        obj = np.asarray(inputarr).view(cls)
        obj.x1 = x1
        obj.x2 = x2
        obj.mask = mask
@@ -77,10 +76,6 @@ class TransformationMatrix(np.ndarray):

    @abc.abstractproperty
    def describe_error(self):
        if not getattr(self, '_error', None):
            self._error = self.compute_error(self.x1,
                                             self.x2,
                                             self.mask)
        return self.error.describe()

    @abc.abstractmethod