Loading autocnet/graph/node.py +1 −2 Original line number Diff line number Diff line Loading @@ -284,8 +284,7 @@ class Node(dict, MutableMapping): keypoints = self.keypoints.loc[index][['x', 'y']] if homogeneous: keypoints['homogeneous'] = 1 keypoints = keypoints.assign(homogeneous = 1) return keypoints def get_raw_keypoint_coordinates(self, index=slice(None)): Loading autocnet/graph/tests/test_edge.py +3 −2 Original line number Diff line number Diff line import unittest from unittest.mock import Mock, MagicMock import pytest import ogr import numpy as np Loading Loading @@ -195,8 +196,6 @@ class TestEdge(unittest.TestCase): # 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 @@ -257,6 +256,7 @@ class TestEdge(unittest.TestCase): self.assertEqual(expected, e.__repr__()) @pytest.mark.filterwarnings('ignore::UserWarning') def test_ratio_check(self): """ A pretty basic test that simply tests pass through from the edge to the Loading Loading @@ -319,6 +319,7 @@ class TestEdge(unittest.TestCase): # Should fail if no src & dst mbrs on edge; Warns user & mask isn't # populated with pytest.warns(UserWarning): e.overlap_check() self.assertTrue("overlap" not in e.masks) Loading autocnet/graph/tests/test_network.py +30 −26 Original line number Diff line number Diff line Loading @@ -39,6 +39,14 @@ def geo_graph(): c:[a,b]} return network.CandidateGraph.from_adjacency(adjacency, basepath=basepath) @pytest.fixture() def reduced_geo(): basepath = get_path('Apollo15') a = 'AS15-M-0297_crop.cub' b = 'AS15-M-0298_crop.cub' adjacency = {a:[b], b:[a]} return network.CandidateGraph.from_adjacency(adjacency, basepath=basepath) @pytest.fixture() def disconnected_graph(): return network.CandidateGraph.from_adjacency(get_path('adjacency.json')) Loading Loading @@ -134,33 +142,29 @@ def test_from_adjacency(): assert isinstance(e, edge.Edge) assert isinstance(g.nodes[s]['data'], node.Node) def test_add_node(): basepath = get_path('Apollo15') a = 'AS15-M-0297_crop.cub' b = 'AS15-M-0298_crop.cub' c = 'AS15-M-0299_crop.cub' adjacency = {a:[b], b:[a]} g = network.CandidateGraph.from_adjacency(adjacency, basepath=basepath) def test_add_node(reduced_geo): # Test without "image_name" arg (networkx parent method) g.add_node(2, data=node.Node(image_name=c, c = 'AS15-M-0299_crop.cub' basepath = get_path('Apollo15') reduced_geo.add_node(2, data=node.Node(image_name=c, image_path=os.path.join(basepath, c), node_id=2)) assert len(g.nodes) == 3 assert g.node[2]["data"]["image_name"] == c assert len(reduced_geo.nodes) == 3 assert reduced_geo.node[2]["data"]["image_name"] == c def test_add_node_by_name(reduced_geo): # Test with "image_name" (cg method) g = network.CandidateGraph.from_adjacency(adjacency, basepath=basepath) g.add_node(image_name=c, basepath=basepath) assert len(g.nodes) == 3 assert g.node[2]["data"]["image_name"] == c assert g.node[0].keys() == g.node[1].keys() == g.node[2].keys() c = 'AS15-M-0299_crop.cub' basepath = get_path('Apollo15') reduced_geo.add_node(image_name=c, basepath=basepath) assert len(reduced_geo.nodes) == 3 assert reduced_geo.node[2]["data"]["image_name"] == c assert reduced_geo.node[0].keys() == reduced_geo.node[1].keys() == reduced_geo.node[2].keys() def test_add_node_nonexistent(geo_graph): # Test when "image_name" not found node_len = len(g.nodes) g.add_node(image_name="nonexistent.jpg") assert len(g.nodes) == node_len with pytest.warns(UserWarning): geo_graph.add_node(image_name="nonexistent.jpg") def test_add_edge(): basepath = get_path('Apollo15') Loading @@ -182,11 +186,11 @@ def test_add_edge(): assert g.edges[1, 2]["data"].destination == g.node[2]["data"] assert g.edges[0, 1].keys() == g.edges[0, 2].keys() == g.edges[1, 2].keys() # Test when adj img not found g = network.CandidateGraph.from_adjacency(adjacency, basepath=basepath) edge_len = len(g.edges) g.add_node(image_name=c, basepath=basepath, adjacency=["nonexistent.jpg"]) assert len(g.edges) == edge_len def test_add_edge_missing_img(reduced_geo): c = 'AS15-M-0299_crop.cub' basepath = get_path('Apollo15') with pytest.warns(UserWarning): reduced_geo.add_node(image_name=c, basepath=basepath, adjacency=["nonexistent.jpg"]) def test_equal(candidategraph): cg = copy.deepcopy(candidategraph) Loading Loading @@ -285,7 +289,7 @@ def test_minimum_spanning_tree(): assert sorted(mst_graph.nodes()) == sorted(graph.nodes()) assert len(mst_graph.edges()) == len(graph.edges())-5 @pytest.mark.filterwarnings('ignore::UserWarning') def test_fromlist(): 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'] Loading autocnet/graph/tests/test_node.py +1 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ class TestNode(object): kpc = node.get_keypoint_coordinates(index=[2,4]) assert len(kpc) == 2 kpc = node.get_keypoint_coordinates(homogeneous=True) assert (kpc.homogeneous == 1).all() assert (kpc['homogeneous'] == 1).all() def test_get_raw_keypoint_coordinates(self, node): image = node.get_array() Loading autocnet/matcher/tests/test_ciratefi.py +2 −2 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ def test_cifi_radii_too_large(template, search): ciratefi.cifi(template, search, 1.0, radii=[100], use_percentile=False) def test_cifi_bounds_error(template, search): with pytest.raises(ValueError): with pytest.raises(ValueError), pytest.warns(UserWarning): ciratefi.cifi(template, search, -1.1, use_percentile=False) def test_cifi_radii_none_error(template, search): Loading Loading @@ -99,7 +99,7 @@ def test_rafi_warning(template, search): def test_rafi_bounds_error(template, search): rafi_pixels = [(10, 10)] rafi_scales = np.ones(search.shape, dtype=float) with pytest.raises(ValueError): with pytest.raises(ValueError) as f, pytest.warns(UserWarning) as g: ciratefi.rafi(template, search, rafi_pixels, rafi_scales, -1.1, use_percentile=False) def test_rafi_radii_list_none_error(template, search): Loading Loading
autocnet/graph/node.py +1 −2 Original line number Diff line number Diff line Loading @@ -284,8 +284,7 @@ class Node(dict, MutableMapping): keypoints = self.keypoints.loc[index][['x', 'y']] if homogeneous: keypoints['homogeneous'] = 1 keypoints = keypoints.assign(homogeneous = 1) return keypoints def get_raw_keypoint_coordinates(self, index=slice(None)): Loading
autocnet/graph/tests/test_edge.py +3 −2 Original line number Diff line number Diff line import unittest from unittest.mock import Mock, MagicMock import pytest import ogr import numpy as np Loading Loading @@ -195,8 +196,6 @@ class TestEdge(unittest.TestCase): # 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 @@ -257,6 +256,7 @@ class TestEdge(unittest.TestCase): self.assertEqual(expected, e.__repr__()) @pytest.mark.filterwarnings('ignore::UserWarning') def test_ratio_check(self): """ A pretty basic test that simply tests pass through from the edge to the Loading Loading @@ -319,6 +319,7 @@ class TestEdge(unittest.TestCase): # Should fail if no src & dst mbrs on edge; Warns user & mask isn't # populated with pytest.warns(UserWarning): e.overlap_check() self.assertTrue("overlap" not in e.masks) Loading
autocnet/graph/tests/test_network.py +30 −26 Original line number Diff line number Diff line Loading @@ -39,6 +39,14 @@ def geo_graph(): c:[a,b]} return network.CandidateGraph.from_adjacency(adjacency, basepath=basepath) @pytest.fixture() def reduced_geo(): basepath = get_path('Apollo15') a = 'AS15-M-0297_crop.cub' b = 'AS15-M-0298_crop.cub' adjacency = {a:[b], b:[a]} return network.CandidateGraph.from_adjacency(adjacency, basepath=basepath) @pytest.fixture() def disconnected_graph(): return network.CandidateGraph.from_adjacency(get_path('adjacency.json')) Loading Loading @@ -134,33 +142,29 @@ def test_from_adjacency(): assert isinstance(e, edge.Edge) assert isinstance(g.nodes[s]['data'], node.Node) def test_add_node(): basepath = get_path('Apollo15') a = 'AS15-M-0297_crop.cub' b = 'AS15-M-0298_crop.cub' c = 'AS15-M-0299_crop.cub' adjacency = {a:[b], b:[a]} g = network.CandidateGraph.from_adjacency(adjacency, basepath=basepath) def test_add_node(reduced_geo): # Test without "image_name" arg (networkx parent method) g.add_node(2, data=node.Node(image_name=c, c = 'AS15-M-0299_crop.cub' basepath = get_path('Apollo15') reduced_geo.add_node(2, data=node.Node(image_name=c, image_path=os.path.join(basepath, c), node_id=2)) assert len(g.nodes) == 3 assert g.node[2]["data"]["image_name"] == c assert len(reduced_geo.nodes) == 3 assert reduced_geo.node[2]["data"]["image_name"] == c def test_add_node_by_name(reduced_geo): # Test with "image_name" (cg method) g = network.CandidateGraph.from_adjacency(adjacency, basepath=basepath) g.add_node(image_name=c, basepath=basepath) assert len(g.nodes) == 3 assert g.node[2]["data"]["image_name"] == c assert g.node[0].keys() == g.node[1].keys() == g.node[2].keys() c = 'AS15-M-0299_crop.cub' basepath = get_path('Apollo15') reduced_geo.add_node(image_name=c, basepath=basepath) assert len(reduced_geo.nodes) == 3 assert reduced_geo.node[2]["data"]["image_name"] == c assert reduced_geo.node[0].keys() == reduced_geo.node[1].keys() == reduced_geo.node[2].keys() def test_add_node_nonexistent(geo_graph): # Test when "image_name" not found node_len = len(g.nodes) g.add_node(image_name="nonexistent.jpg") assert len(g.nodes) == node_len with pytest.warns(UserWarning): geo_graph.add_node(image_name="nonexistent.jpg") def test_add_edge(): basepath = get_path('Apollo15') Loading @@ -182,11 +186,11 @@ def test_add_edge(): assert g.edges[1, 2]["data"].destination == g.node[2]["data"] assert g.edges[0, 1].keys() == g.edges[0, 2].keys() == g.edges[1, 2].keys() # Test when adj img not found g = network.CandidateGraph.from_adjacency(adjacency, basepath=basepath) edge_len = len(g.edges) g.add_node(image_name=c, basepath=basepath, adjacency=["nonexistent.jpg"]) assert len(g.edges) == edge_len def test_add_edge_missing_img(reduced_geo): c = 'AS15-M-0299_crop.cub' basepath = get_path('Apollo15') with pytest.warns(UserWarning): reduced_geo.add_node(image_name=c, basepath=basepath, adjacency=["nonexistent.jpg"]) def test_equal(candidategraph): cg = copy.deepcopy(candidategraph) Loading Loading @@ -285,7 +289,7 @@ def test_minimum_spanning_tree(): assert sorted(mst_graph.nodes()) == sorted(graph.nodes()) assert len(mst_graph.edges()) == len(graph.edges())-5 @pytest.mark.filterwarnings('ignore::UserWarning') def test_fromlist(): 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'] Loading
autocnet/graph/tests/test_node.py +1 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ class TestNode(object): kpc = node.get_keypoint_coordinates(index=[2,4]) assert len(kpc) == 2 kpc = node.get_keypoint_coordinates(homogeneous=True) assert (kpc.homogeneous == 1).all() assert (kpc['homogeneous'] == 1).all() def test_get_raw_keypoint_coordinates(self, node): image = node.get_array() Loading
autocnet/matcher/tests/test_ciratefi.py +2 −2 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ def test_cifi_radii_too_large(template, search): ciratefi.cifi(template, search, 1.0, radii=[100], use_percentile=False) def test_cifi_bounds_error(template, search): with pytest.raises(ValueError): with pytest.raises(ValueError), pytest.warns(UserWarning): ciratefi.cifi(template, search, -1.1, use_percentile=False) def test_cifi_radii_none_error(template, search): Loading Loading @@ -99,7 +99,7 @@ def test_rafi_warning(template, search): def test_rafi_bounds_error(template, search): rafi_pixels = [(10, 10)] rafi_scales = np.ones(search.shape, dtype=float) with pytest.raises(ValueError): with pytest.raises(ValueError) as f, pytest.warns(UserWarning) as g: ciratefi.rafi(template, search, rafi_pixels, rafi_scales, -1.1, use_percentile=False) def test_rafi_radii_list_none_error(template, search): Loading