Loading .travis.yml +2 −4 Changes for .travis.yml: 2 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -44,8 +44,8 @@ install: - conda config --add channels jlaura - conda config --set ssl_verify false - conda install python=$PYTHON_VERSION - conda install -c conda-forge numpy - conda install -c jlaura plio opencv3=3.0.0 - conda install -c conda-forge numpy opencv - conda install -c jlaura plio - conda install -c conda-forge vlfeat - conda install -c menpo cyvlfeat - pip install pillow pysal Loading @@ -66,8 +66,6 @@ install: script: - pytest --cov=autocnet # clean up any remaining processes... - if [ $TRAVIS_OS_NAME == "linux" ]; then killall5; fi after_success: # Upload to anaconda and push to coveralls Loading README.rst +1 −1 Changes for README.rst: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -37,6 +37,6 @@ We suggest using Anaconda Python to install Autocnet within a virtual environmen * ``conda create -n <your_environment_name> python=3 && source activate <your_environment_name>`` 1. Bring up a command line and add three channels to your conda config (``~/condarc``): * ``conda config --add channels conda-forge`` * ``conda condig --add channels jlaura`` * ``conda config --add channels jlaura`` * ``conda config --add channels menpo`` 1. Finally, install autocnet: ``conda install -c jlaura autocnet-dev`` autocnet/control/tests/test_control.py +20 −0 Changes for autocnet/control/tests/test_control.py: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -75,3 +75,23 @@ class TestC(unittest.TestCase): def test_to_dataframe(self): self.C.to_dataframe() def test_point_repr(self): expected = 0 p = control.Point(expected) self.assertEqual(str(expected), p.__repr__()) def test_correspondence_repr(self): expected = 0 c = control.Correspondence(expected, 1, 1) self.assertEqual(str(expected), c.__repr__()) def test_correspondence_eq(self): expected = 0 c = control.Correspondence(expected, 1, 1) self.assertTrue(c == expected) def test_correspondence_hash(self): expected = 200 c = control.Correspondence(expected, 1, 1) self.assertEqual(hash(expected), hash(c)) autocnet/graph/edge.py +5 −15 Changes for autocnet/graph/edge.py: 5 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import pandas as pd from scipy.spatial.distance import cdist import autocnet from autocnet.graph.node import Node from autocnet.utils import utils from autocnet.matcher import cpu_outlier_detector as od from autocnet.matcher import suppression_funcs as spf Loading Loading @@ -78,22 +79,11 @@ class Edge(dict, MutableMapping): def masks(self): mask_lookup = {'fundamental': 'fundamental_matrix'} if not hasattr(self, '_masks'): if self.matches is not None: if isinstance(self.matches, pd.DataFrame): self._masks = pd.DataFrame(True, columns=['symmetry'], index=self.matches.index) else: self._masks = pd.DataFrame() # If the mask is coming form another object that tracks # state, dynamically draw the mask from the object. for c in self._masks.columns: if c in mask_lookup: try: truncated_mask = getattr(self, mask_lookup[c]).mask self._masks[c] = False self._masks[c].iloc[truncated_mask.index] = truncated_mask except Exception: #TODO: Get rid of state pass return self._masks @masks.setter Loading Loading @@ -150,7 +140,6 @@ class Edge(dict, MutableMapping): def symmetry_check(self): self.masks['symmetry'] = od.mirroring_test(self.matches) def ratio_check(self, clean_keys=[], maskname='ratio', **kwargs): matches, mask = self.clean(clean_keys) self.masks[maskname] = od.distance_ratio(matches, **kwargs) Loading Loading @@ -363,7 +352,7 @@ class Edge(dict, MutableMapping): of mask keys to be used to reduce the total size of the matches dataframe. """ if not hasattr(self, 'matches'): if not isinstance(self.matches, pd.DataFrame): raise AttributeError('This edge does not yet have any matches computed.') matches, mask = self.clean(clean_keys) Loading Loading @@ -493,7 +482,7 @@ class Edge(dict, MutableMapping): Of strings used to apply masks to omit correspondences """ if self.matches is None: if not isinstance(self.matches, pd.DataFrame): raise AttributeError('Matches have not been computed for this edge') voronoi = cg.vor(self, clean_keys, **kwargs) self.matches = pd.concat([self.matches, voronoi[1]['vor_weights']], axis=1) Loading @@ -506,3 +495,4 @@ class Edge(dict, MutableMapping): pixel space """ self.overlap_latlon_coords, self["source_mbr"], self["destin_mbr"] = self.source.geodata.compute_overlap(self.destination.geodata, **kwargs) autocnet/graph/tests/test_edge.py +68 −4 Changes for autocnet/graph/tests/test_edge.py: 68 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -2,9 +2,11 @@ import unittest from unittest.mock import Mock, MagicMock import ogr import numpy as np import pandas as pd from plio.io import io_gdal from autocnet.matcher import cpu_outlier_detector as od from autocnet.examples import get_path from autocnet.graph.network import CandidateGraph from autocnet.utils.utils import array_to_poly Loading Loading @@ -38,13 +40,9 @@ class TestEdge(unittest.TestCase): 'distance']) ''' def test_properties(self): pass def test_masks(self): self.assertIsInstance(self.edge.masks, pd.DataFrame) def test_compute_fundamental_matrix(self): pass Loading Loading @@ -247,3 +245,69 @@ class TestEdge(unittest.TestCase): for i in e.matches['vor_weights']: self.assertAlmostEquals(i, weights['vor_weights'][k]) k += 1 def test_eq(self): edge1 = edge.Edge() edge2 = edge.Edge() edge3 = edge.Edge() # Test edges w/ different keys are not equal, ones with same keys are edge1.__dict__["key"] = 1 edge2.__dict__["key"] = 1 edge3.__dict__["not_key"] = 1 self.assertTrue(edge1 == edge2) self.assertFalse(edge1 == edge3) # Test edges with same keys, but diff df values edge1.__dict__["key"] = pd.DataFrame({'x': (0, 1, 2, 3, 4)}) edge2.__dict__["key"] = pd.DataFrame({'x': (0, 1, 2, 3, 4)}) edge3.__dict__["key"] = pd.DataFrame({'x': (0, 1, 2, 3, 5)}) self.assertTrue(edge1 == edge2) self.assertFalse(edge1 == edge3) # Test edges with same keys, but diff np array vals # edge.__eq__ calls ndarray.all(), which checks that # all values in an array eval to true edge1.__dict__["key"] = np.array([True, True, True], dtype=np.bool) edge2.__dict__["key"] = np.array([True, True, True], dtype=np.bool) edge3.__dict__["key"] = np.array([True, True, False], dtype=np.bool) self.assertTrue(edge1 == edge2) self.assertFalse(edge1 == edge3) def test_repr(self): src = node.Node() dst = node.Node() masks = pd.DataFrame() e = edge.Edge() e.source = src e.destination = dst expected = """ Source Image Index: {} Destination Image Index: {} Available Masks: {} """.format(src, dst, masks) self.assertEqual(expected, e.__repr__()) def test_ratio_check(self): # Matches is init to None e = edge.Edge() # If there are matches... keypoint_matches = [[0, 0, 1, 4, 5], [0, 1, 1, 3, 5], [0, 2, 1, 2, 5], [0, 3, 1, 1, 5], [0, 4, 1, 0, 5]] matches_df = pd.DataFrame(data=keypoint_matches, columns=['source_image', 'source_idx', 'destination_image', 'destination_idx', 'distance']) e.matches = matches_df expected = list(od.distance_ratio(matches_df)) e.ratio_check() self.assertEqual(expected, list(e.masks["ratio"])) Loading
.travis.yml +2 −4 Changes for .travis.yml: 2 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -44,8 +44,8 @@ install: - conda config --add channels jlaura - conda config --set ssl_verify false - conda install python=$PYTHON_VERSION - conda install -c conda-forge numpy - conda install -c jlaura plio opencv3=3.0.0 - conda install -c conda-forge numpy opencv - conda install -c jlaura plio - conda install -c conda-forge vlfeat - conda install -c menpo cyvlfeat - pip install pillow pysal Loading @@ -66,8 +66,6 @@ install: script: - pytest --cov=autocnet # clean up any remaining processes... - if [ $TRAVIS_OS_NAME == "linux" ]; then killall5; fi after_success: # Upload to anaconda and push to coveralls Loading
README.rst +1 −1 Changes for README.rst: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -37,6 +37,6 @@ We suggest using Anaconda Python to install Autocnet within a virtual environmen * ``conda create -n <your_environment_name> python=3 && source activate <your_environment_name>`` 1. Bring up a command line and add three channels to your conda config (``~/condarc``): * ``conda config --add channels conda-forge`` * ``conda condig --add channels jlaura`` * ``conda config --add channels jlaura`` * ``conda config --add channels menpo`` 1. Finally, install autocnet: ``conda install -c jlaura autocnet-dev``
autocnet/control/tests/test_control.py +20 −0 Changes for autocnet/control/tests/test_control.py: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -75,3 +75,23 @@ class TestC(unittest.TestCase): def test_to_dataframe(self): self.C.to_dataframe() def test_point_repr(self): expected = 0 p = control.Point(expected) self.assertEqual(str(expected), p.__repr__()) def test_correspondence_repr(self): expected = 0 c = control.Correspondence(expected, 1, 1) self.assertEqual(str(expected), c.__repr__()) def test_correspondence_eq(self): expected = 0 c = control.Correspondence(expected, 1, 1) self.assertTrue(c == expected) def test_correspondence_hash(self): expected = 200 c = control.Correspondence(expected, 1, 1) self.assertEqual(hash(expected), hash(c))
autocnet/graph/edge.py +5 −15 Changes for autocnet/graph/edge.py: 5 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import pandas as pd from scipy.spatial.distance import cdist import autocnet from autocnet.graph.node import Node from autocnet.utils import utils from autocnet.matcher import cpu_outlier_detector as od from autocnet.matcher import suppression_funcs as spf Loading Loading @@ -78,22 +79,11 @@ class Edge(dict, MutableMapping): def masks(self): mask_lookup = {'fundamental': 'fundamental_matrix'} if not hasattr(self, '_masks'): if self.matches is not None: if isinstance(self.matches, pd.DataFrame): self._masks = pd.DataFrame(True, columns=['symmetry'], index=self.matches.index) else: self._masks = pd.DataFrame() # If the mask is coming form another object that tracks # state, dynamically draw the mask from the object. for c in self._masks.columns: if c in mask_lookup: try: truncated_mask = getattr(self, mask_lookup[c]).mask self._masks[c] = False self._masks[c].iloc[truncated_mask.index] = truncated_mask except Exception: #TODO: Get rid of state pass return self._masks @masks.setter Loading Loading @@ -150,7 +140,6 @@ class Edge(dict, MutableMapping): def symmetry_check(self): self.masks['symmetry'] = od.mirroring_test(self.matches) def ratio_check(self, clean_keys=[], maskname='ratio', **kwargs): matches, mask = self.clean(clean_keys) self.masks[maskname] = od.distance_ratio(matches, **kwargs) Loading Loading @@ -363,7 +352,7 @@ class Edge(dict, MutableMapping): of mask keys to be used to reduce the total size of the matches dataframe. """ if not hasattr(self, 'matches'): if not isinstance(self.matches, pd.DataFrame): raise AttributeError('This edge does not yet have any matches computed.') matches, mask = self.clean(clean_keys) Loading Loading @@ -493,7 +482,7 @@ class Edge(dict, MutableMapping): Of strings used to apply masks to omit correspondences """ if self.matches is None: if not isinstance(self.matches, pd.DataFrame): raise AttributeError('Matches have not been computed for this edge') voronoi = cg.vor(self, clean_keys, **kwargs) self.matches = pd.concat([self.matches, voronoi[1]['vor_weights']], axis=1) Loading @@ -506,3 +495,4 @@ class Edge(dict, MutableMapping): pixel space """ self.overlap_latlon_coords, self["source_mbr"], self["destin_mbr"] = self.source.geodata.compute_overlap(self.destination.geodata, **kwargs)
autocnet/graph/tests/test_edge.py +68 −4 Changes for autocnet/graph/tests/test_edge.py: 68 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -2,9 +2,11 @@ import unittest from unittest.mock import Mock, MagicMock import ogr import numpy as np import pandas as pd from plio.io import io_gdal from autocnet.matcher import cpu_outlier_detector as od from autocnet.examples import get_path from autocnet.graph.network import CandidateGraph from autocnet.utils.utils import array_to_poly Loading Loading @@ -38,13 +40,9 @@ class TestEdge(unittest.TestCase): 'distance']) ''' def test_properties(self): pass def test_masks(self): self.assertIsInstance(self.edge.masks, pd.DataFrame) def test_compute_fundamental_matrix(self): pass Loading Loading @@ -247,3 +245,69 @@ class TestEdge(unittest.TestCase): for i in e.matches['vor_weights']: self.assertAlmostEquals(i, weights['vor_weights'][k]) k += 1 def test_eq(self): edge1 = edge.Edge() edge2 = edge.Edge() edge3 = edge.Edge() # Test edges w/ different keys are not equal, ones with same keys are edge1.__dict__["key"] = 1 edge2.__dict__["key"] = 1 edge3.__dict__["not_key"] = 1 self.assertTrue(edge1 == edge2) self.assertFalse(edge1 == edge3) # Test edges with same keys, but diff df values edge1.__dict__["key"] = pd.DataFrame({'x': (0, 1, 2, 3, 4)}) edge2.__dict__["key"] = pd.DataFrame({'x': (0, 1, 2, 3, 4)}) edge3.__dict__["key"] = pd.DataFrame({'x': (0, 1, 2, 3, 5)}) self.assertTrue(edge1 == edge2) self.assertFalse(edge1 == edge3) # Test edges with same keys, but diff np array vals # edge.__eq__ calls ndarray.all(), which checks that # all values in an array eval to true edge1.__dict__["key"] = np.array([True, True, True], dtype=np.bool) edge2.__dict__["key"] = np.array([True, True, True], dtype=np.bool) edge3.__dict__["key"] = np.array([True, True, False], dtype=np.bool) self.assertTrue(edge1 == edge2) self.assertFalse(edge1 == edge3) def test_repr(self): src = node.Node() dst = node.Node() masks = pd.DataFrame() e = edge.Edge() e.source = src e.destination = dst expected = """ Source Image Index: {} Destination Image Index: {} Available Masks: {} """.format(src, dst, masks) self.assertEqual(expected, e.__repr__()) def test_ratio_check(self): # Matches is init to None e = edge.Edge() # If there are matches... keypoint_matches = [[0, 0, 1, 4, 5], [0, 1, 1, 3, 5], [0, 2, 1, 2, 5], [0, 3, 1, 1, 5], [0, 4, 1, 0, 5]] matches_df = pd.DataFrame(data=keypoint_matches, columns=['source_image', 'source_idx', 'destination_image', 'destination_idx', 'distance']) e.matches = matches_df expected = list(od.distance_ratio(matches_df)) e.ratio_check() self.assertEqual(expected, list(e.masks["ratio"]))