예제 #1
0
def candidategraph(node_a, node_b, node_c):
    # TODO: Getting this fixture from the global conf is causing deepycopy
    # to fail.  Why?
    cg = CandidateGraph()

    # Create a candidategraph object - we instantiate a real CandidateGraph to
    # have access of networkx functionality we do not want to test and then
    # mock all autocnet functionality to control test behavior.
    edges = [(0, 1, {
        'data': edge.Edge(0, 1)
    }), (0, 2, {
        'data': edge.Edge(0, 2)
    }), (1, 2, {
        'data': edge.Edge(1, 2)
    })]

    cg.add_edges_from(edges)

    match_indices = [([0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]),
                     ([0, 1, 2, 3, 4, 5, 8, 9], [0, 1, 2, 3, 4, 5, 8, 9]),
                     ([0, 1, 2, 3, 4, 5, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7])]

    matches = []
    for i, e in enumerate(edges):
        c = match_indices[i]
        source_image = np.repeat(e[0], 8)
        destin_image = np.repeat(e[1], 8)
        coords = np.zeros(8)
        data = np.vstack((source_image, c[0], destin_image, c[1], coords,
                          coords, coords, coords)).T
        matches_df = pd.DataFrame(data,
                                  columns=[
                                      'source_image', 'source_idx',
                                      'destination_image', 'destination_idx',
                                      'source_x', 'source_y', 'destination_x',
                                      'destination_y'
                                  ])
        matches.append(matches_df)

    # Mock in autocnet methods
    cg.get_matches = MagicMock(return_value=matches)

    # Mock in the node objects onto the candidate graph
    cg.node[0]['data'] = node_a
    cg.node[1]['data'] = node_b
    cg.node[2]['data'] = node_c

    return cg
    def setUpClass(cls):

        cls.npts = 5
        serial_times = {
            295: '1971-07-31T01:24:11.754',
            296: '1971-07-31T01:24:36.970'
        }
        cls.serials = [
            'APOLLO15/METRIC/{}'.format(i) for i in serial_times.values()
        ]
        net = CandidateGraph({'a': ['b'], 'b': ['a']})
        for i, n in net.nodes_iter(data=True):
            n._keypoints = pd.DataFrame(np.arange(10).reshape(cls.npts, -1),
                                        columns=['x', 'y'])
            n._isis_serial = cls.serials[i]

        source = np.zeros(cls.npts)
        destination = np.ones(cls.npts)
        pid = np.arange(cls.npts)

        matches = pd.DataFrame(np.vstack((source, pid, destination, pid)).T,
                               columns=[
                                   'source_image', 'source_idx',
                                   'destination_image', 'destination_idx'
                               ])

        net.edge[0][1].matches = matches
        net.generate_cnet(clean_keys=[])

        cls.creation_date = net.creationdate
        cls.modified_date = net.modifieddate
        io_controlnetwork.to_isis('test.net',
                                  net,
                                  mode='wb',
                                  targetname='Moon')

        cls.header_message_size = 98
        cls.point_start_byte = 65634
예제 #3
0
 def new(self):
     self.cg = CandidateGraph()
     return 'success'