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

Added test coverage.

parent 09d89d7f
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -2,9 +2,8 @@
source = autocnet
[report]
omit =
    fileio/ControlNetFileV0002_pb2.py
    utils/visualization.py
    vis/*
    autocnet/fileio/ControlNetFileV0002_pb2.py
    autocnet/vis/graph_view.py
exclude_lines =
    pragma: no cover
    def __repr__
+0 −1
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@ import os
import sys
sys.path.insert(0, os.path.abspath('..'))

import cv2
import numpy as np
import unittest

+3 −1
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@ import numpy.testing
from .. import homography



class TestHomography(unittest.TestCase):

    def setUp(self):
@@ -34,3 +33,6 @@ class TestHomography(unittest.TestCase):
        self.assertAlmostEqual(H.determinant, 0.6249999, 5)
        self.assertAlmostEqual(H.condition, 7.19064438, 5)
        numpy.testing.assert_array_almost_equal(H.rmse, np.array([0, 0, 0.0]))

    def test_Homography_fail(self):
        self.assertRaises(TypeError, homography.Homography, [1,2,3], 'a', 'b')
+0 −40
Original line number Diff line number Diff line
import functools
import numpy as np


def enum(*sequential, **named):
    """Handy way to fake an enumerated type in Python
    http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python
    """
    enums = dict(zip(sequential, range(len(sequential))), **named)
    return type('Enum', (), enums)


def getnearest(iterable, value):
    """
    Given an iterable, get the index nearest to the input value
@@ -101,26 +92,6 @@ def checkmonotonic(iterable, piecewise=False):
        return all(monotonic)


def convert_mean_pressure(elevation):
    """
    Convert from raw elevation, in km, to pressure in Pascals using
    Hugh Kieffer's algorithm.

    689.7 is the constant pressure at sea level

    Parameters
    -----------
    elevation : float or ndarray
                elevation in km

    Returns
    --------
      : float
        Pressure in Pascals
    """
    return 689.7 * np.exp(-elevation / 10.8)


def find_in_dict(obj, key):
    """
    Recursively find an entry in a dictionary
@@ -146,17 +117,6 @@ def find_in_dict(obj, key):
                return item


# note that this decorator ignores **kwargs
def memoize(obj):
    cache = obj.cache = {}
    @functools.wraps(obj)
    def memoizer(*args, **kwargs):
        if args not in cache:
            cache[args] = obj(*args, **kwargs)
        return cache[args]
    return memoizer


def make_homogeneous(points):
    """
    Convert a set of points (n x dim array) to