Loading autocnet/graph/edge.py +3 −2 Changes for autocnet/graph/edge.py: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -118,11 +118,9 @@ class Edge(dict, MutableMapping): "Cannot use overlap constraint, minimum bounding rectangles" " have not been computed for one or more Nodes") return # Get overlapping keypts s_idx = self.get_keypoints(self.source, overlap=True).index d_idx = self.get_keypoints(self.destination, overlap=True).index # Create a mask from matches whose rows have both source idx & # dest idx in the overlapping keypts mask = pd.Series(False, index=self.matches.index) Loading Loading @@ -188,11 +186,14 @@ class Edge(dict, MutableMapping): raise TypeError keypts = node.get_keypoint_coordinates(index=index, homogeneous=homogeneous) # If we only want keypoints in the overlap print('O', overlap) if overlap: if self.source == node: mbr = self['source_mbr'] print('s', mbr) else: mbr = self['destin_mbr'] print('d', mbr) # Can't use overlap if we haven't computed MBRs if mbr is None: return keypts Loading autocnet/graph/tests/test_edge.py +8 −15 Changes for autocnet/graph/tests/test_edge.py: 8 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -125,17 +125,13 @@ class TestEdge(unittest.TestCase): matches_df = pd.DataFrame(data=keypoint_matches, columns=['source_image', 'source_idx', 'destination_image', 'destination_idx']) e = edge.Edge() source_node = node.Node() destination_node = node.Node() source_node = node.Node(node_id=0) destination_node = node.Node(node_id=1) e = edge.Edge(source_node, destination_node) source_node.get_keypoint_coordinates = MagicMock(return_value=src_keypoint_df) destination_node.get_keypoint_coordinates = MagicMock(return_value=dst_keypoint_df) e.source = source_node e.destination = destination_node e.clean = MagicMock(return_value=(matches_df, None)) e.matches = matches_df Loading Loading @@ -194,13 +190,13 @@ class TestEdge(unittest.TestCase): # Assert masked src keypts coords are equal s_expected = pd.DataFrame({'x': (0, 1, 2), 'y': (5, 6, 7)}) print(s_expected['y']) print(s_overlap['y']) self.assertTrue(np.array_equal(s_expected['x'], s_overlap['x'].values)) self.assertTrue(np.array_equal(s_expected['y'], s_overlap['y'].values)) # Assert masked dst keypt coords are equal d_expected = pd.DataFrame({'x': (33, 32, 31), 'y': (28, 27, 26)}) print(d_expected['x']) print(d_overlap['x'].values) self.assertTrue(np.array_equal(d_expected['x'], d_overlap['x'].values)) self.assertTrue(np.array_equal(d_expected['y'], d_overlap['y'].values)) Loading Loading @@ -284,12 +280,10 @@ class TestEdge(unittest.TestCase): assert expected.equals(e.masks["ratio"]) def test_overlap_check(self): s = node.Node() d = node.Node() s = node.Node(node_id=0) d = node.Node(node_id=1) e = edge.Edge() e.source = s e.destination = d e = edge.Edge(s, d) src_keypoint_df = pd.DataFrame({'x': (0, 1, 2, 3, 4), 'y': (5, 6, 7, 8, 9)}) dst_keypoint_df = pd.DataFrame({'x': (34, 33, 32, 31, 30), 'y': (29, 28, 27, 26, 25)}) Loading Loading @@ -333,6 +327,5 @@ class TestEdge(unittest.TestCase): e["destin_mbr"] = (1, 1, 1, 1) e.overlap_check() overlap_matches, overlap_mask = e.clean(clean_keys=['overlap']) self.assertTrue(expected_mask.equals(overlap_mask)) self.assertTrue(overlap_matches.equals(e.matches[overlap_mask])) pytest.ini +2 −0 Changes for pytest.ini: 2 added lines, 0 removed lines. Original line number Diff line number Diff line [pytest] addopts = --doctest-modules --cov-report term-missing --cov=autocnet filterwarnings = ignore::UserWarning Loading
autocnet/graph/edge.py +3 −2 Changes for autocnet/graph/edge.py: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -118,11 +118,9 @@ class Edge(dict, MutableMapping): "Cannot use overlap constraint, minimum bounding rectangles" " have not been computed for one or more Nodes") return # Get overlapping keypts s_idx = self.get_keypoints(self.source, overlap=True).index d_idx = self.get_keypoints(self.destination, overlap=True).index # Create a mask from matches whose rows have both source idx & # dest idx in the overlapping keypts mask = pd.Series(False, index=self.matches.index) Loading Loading @@ -188,11 +186,14 @@ class Edge(dict, MutableMapping): raise TypeError keypts = node.get_keypoint_coordinates(index=index, homogeneous=homogeneous) # If we only want keypoints in the overlap print('O', overlap) if overlap: if self.source == node: mbr = self['source_mbr'] print('s', mbr) else: mbr = self['destin_mbr'] print('d', mbr) # Can't use overlap if we haven't computed MBRs if mbr is None: return keypts Loading
autocnet/graph/tests/test_edge.py +8 −15 Changes for autocnet/graph/tests/test_edge.py: 8 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -125,17 +125,13 @@ class TestEdge(unittest.TestCase): matches_df = pd.DataFrame(data=keypoint_matches, columns=['source_image', 'source_idx', 'destination_image', 'destination_idx']) e = edge.Edge() source_node = node.Node() destination_node = node.Node() source_node = node.Node(node_id=0) destination_node = node.Node(node_id=1) e = edge.Edge(source_node, destination_node) source_node.get_keypoint_coordinates = MagicMock(return_value=src_keypoint_df) destination_node.get_keypoint_coordinates = MagicMock(return_value=dst_keypoint_df) e.source = source_node e.destination = destination_node e.clean = MagicMock(return_value=(matches_df, None)) e.matches = matches_df Loading Loading @@ -194,13 +190,13 @@ class TestEdge(unittest.TestCase): # Assert masked src keypts coords are equal s_expected = pd.DataFrame({'x': (0, 1, 2), 'y': (5, 6, 7)}) print(s_expected['y']) print(s_overlap['y']) self.assertTrue(np.array_equal(s_expected['x'], s_overlap['x'].values)) self.assertTrue(np.array_equal(s_expected['y'], s_overlap['y'].values)) # Assert masked dst keypt coords are equal d_expected = pd.DataFrame({'x': (33, 32, 31), 'y': (28, 27, 26)}) print(d_expected['x']) print(d_overlap['x'].values) self.assertTrue(np.array_equal(d_expected['x'], d_overlap['x'].values)) self.assertTrue(np.array_equal(d_expected['y'], d_overlap['y'].values)) Loading Loading @@ -284,12 +280,10 @@ class TestEdge(unittest.TestCase): assert expected.equals(e.masks["ratio"]) def test_overlap_check(self): s = node.Node() d = node.Node() s = node.Node(node_id=0) d = node.Node(node_id=1) e = edge.Edge() e.source = s e.destination = d e = edge.Edge(s, d) src_keypoint_df = pd.DataFrame({'x': (0, 1, 2, 3, 4), 'y': (5, 6, 7, 8, 9)}) dst_keypoint_df = pd.DataFrame({'x': (34, 33, 32, 31, 30), 'y': (29, 28, 27, 26, 25)}) Loading Loading @@ -333,6 +327,5 @@ class TestEdge(unittest.TestCase): e["destin_mbr"] = (1, 1, 1, 1) e.overlap_check() overlap_matches, overlap_mask = e.clean(clean_keys=['overlap']) self.assertTrue(expected_mask.equals(overlap_mask)) self.assertTrue(overlap_matches.equals(e.matches[overlap_mask]))
pytest.ini +2 −0 Changes for pytest.ini: 2 added lines, 0 removed lines. Original line number Diff line number Diff line [pytest] addopts = --doctest-modules --cov-report term-missing --cov=autocnet filterwarnings = ignore::UserWarning