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

Additional test cleanup

parent 03f97f5f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
AS15-M-0295_SML.png
AS15-M-0296_SML.png
AS15-M-0297_SML.png
AS15-M-0298_SML.png
AS15-M-0299_SML.png
AS15-M-0300_SML.png
+11 −7
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ class CandidateGraph(nx.Graph):


    @classmethod
    def from_filelist(cls, filelist):
    def from_filelist(cls, filelist, basepath=None):
        """
        Instantiate the class using a filelist as a python list.
        An adjacency structure is calculated using the lat/lon information in the
@@ -111,7 +111,9 @@ class CandidateGraph(nx.Graph):
                filelist = map(str.rstrip, filelist)

        # TODO: Reject unsupported file formats + work with more file formats

        if basepath:
            datasets = [GeoDataset(os.path.join(basepath, f)) for f in filelist]
        else:
            datasets = [GeoDataset(f) for f in filelist]

        # This is brute force for now, could swap to an RTree at some point.
@@ -126,10 +128,12 @@ class CandidateGraph(nx.Graph):
            # Grab the footprints and test for intersection
            i_fp = i.footprint
            j_fp = j.footprint
            try:
                if i_fp.Intersects(j_fp):
                    adjacency_dict[i.file_name].append(j.file_name)
                    adjacency_dict[j.file_name].append(i.file_name)

            except: # no geospatial information embedded in the images
                pass
        return cls(adjacency_dict)


+0 −1
Original line number Diff line number Diff line
@@ -43,6 +43,5 @@ class TestEdge(unittest.TestCase):
    def test_compute_fundamental_matrix(self):
        with self.assertRaises(AttributeError):
            self.edge.compute_fundamental_matrix()
        self.assertTrue(False)

+9 −35
Original line number Diff line number Diff line
@@ -78,43 +78,17 @@ class TestCandidateGraph(unittest.TestCase):

        os.remove('test_save.cg')

    def tearDown(self):
        pass

    def test_fromlist(self):
        mock_list = ['AS15-M-0295_SML.png', 'AS15-M-0296_SML.png', 'AS15-M-0297_SML.png',
                     'AS15-M-0298_SML.png', 'AS15-M-0299_SML.png', 'AS15-M-0300_SML.png']
        n = network.CandidateGraph.from_filelist(mock_list, get_path('Apollo15'))
        self.assertEqual(len(n.nodes()), 6)

class TestFromList(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        filelist = [get_path('Mars_MGS_MOLA_ClrShade_MAP2_0.0N0.0_MERC.tif'),
                    get_path('Lunar_LRO_LOLA_Shade_MAP2_90.0N20.0_LAMB.tif'),
                    get_path('Mars_MGS_MOLA_ClrShade_MAP2_90.0N0.0_POLA.tif')]
        cls.graph = network.CandidateGraph.from_filelist(filelist)
        n = network.CandidateGraph.from_filelist(get_path('adjacency.lis'), get_path('Apollo15'))
        self.assertEqual(len(n.nodes()), 6)

    def test_graph_length(self):
        self.assertEqual(self.graph.__len__(), 3)
        self.assertEqual(self.graph.number_of_nodes(), 3)

'''
class TestFromListCubes(unittest.TestCase):
    @classmethod

    def setUpClass(cls):
        filelist = [get_path('AS15-M-0297_sub4.cub'),
                    get_path('AS15-M-0298_sub4.cub'),
                    get_path('AS15-M-0299_sub4.cub')]
        cls.graph = network.CandidateGraph.from_filelist(filelist)

    def test_graph_length(self):
        self.assertEqual(self.graph.number_of_nodes(), 3)
        self.assertEqual(self.graph.number_of_edges(), 3)
'''


class TestEdge(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.graph = network.CandidateGraph.from_adjacency(get_path('adjacency.json'))
    def tearDown(self):
        pass


class TestGraphMasks(unittest.TestCase):