Commit fd597beb authored by jay's avatar jay
Browse files

Updates to tests for coverage and removed errors in attribute change on cleaning

parent f469aa45
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ class CandidateGraph(nx.Graph):

        raise NotImplementedError

    def extract_features(self, band=1, *args, **kwargs):
    def extract_features(self, band=1, *args, **kwargs):  # pragma: no cover
        """
        Extracts features from each image in the graph and uses the result to assign the
        node attributes for 'handle', 'image', 'keypoints', and 'descriptors'.
@@ -226,7 +226,7 @@ class CandidateGraph(nx.Graph):
            array = node.geodata.read_array(band=band)
            node.extract_features(array, *args, **kwargs),

    def extract_features_with_downsampling(self, downsample_amount=None, *args, **kwargs):
    def extract_features_with_downsampling(self, downsample_amount=None, *args, **kwargs): # pragma: no cover
        """
        Extract interest points from a downsampled array.  The array is downsampled
        by the downsample_amount keyword using the Lanconz downsample amount.  If the
@@ -245,7 +245,7 @@ class CandidateGraph(nx.Graph):
                downsample_amount = math.ceil(total_size / self.maxsize**2)
            node.extract_features_with_downsampling(downsample_amount, *args, **kwargs)

    def extract_features_with_tiling(self, tilesize=1000, overlap=500, *args, **kwargs):
    def extract_features_with_tiling(self, tilesize=1000, overlap=500, *args, **kwargs): #pragma: no cover
        for i, node in self.nodes_iter(data=True):
            node.extract_features_with_tiling(tilesize=tilesize, overlap=overlap, *args, **kwargs)

@@ -567,7 +567,7 @@ class CandidateGraph(nx.Graph):
        """
        return plot_graph(self, ax=ax, **kwargs)

    def plot_cluster(self, ax=None, **kwargs):
    def plot_cluster(self, ax=None, **kwargs):  # pragma: no cover
        """
        Plot the graph based on the clusters generated by
        the markov clustering algorithm
+1 −21
Original line number Diff line number Diff line
@@ -510,26 +510,6 @@ class Node(dict, MutableMapping):
        columns = ['point_id', 'point_type', 'serialnumber', 'measure_type', 'x', 'y', 'node_id']
        self.point_to_correspondence_df = pd.DataFrame(data, columns=columns)

    def suppress(self, func=spf.response, **kwargs):
        if not hasattr(self, 'keypoints'):
            raise AttributeError('No keypoints extracted for this node.')

        domain = self.handle.raster_size
        self.keypoints['strength'] = self.keypoints.apply(func, axis=1)

        if not hasattr(self, 'suppression'):
            # Instantiate a suppression object and suppress keypoints
            self.suppression = od.SpatialSuppression(self.keypoints, domain, **kwargs)
            self.suppression.suppress()
        else:
            # Update the suppression object attributes and process
            for k, v in kwargs.items():
                if hasattr(self.suppression, k):
                    setattr(self.suppression, k, v)
            self.suppression.suppress()

        self.masks['suppression'] = self.suppression.mask

    def coverage_ratio(self, clean_keys=[]):
        """
        Compute the ratio $area_{convexhull} / area_{total}$
@@ -570,7 +550,7 @@ class Node(dict, MutableMapping):
        mask : series
                    A boolean series to inflate back to the full match set
        """
        if not hasattr(self, 'keypoints'):
        if self.keypoints.empty:
            raise AttributeError('Keypoints have not been extracted for this node.')
        panel = self.masks
        mask = panel[clean_keys].all(axis=1)
+9 −0
Original line number Diff line number Diff line
import os
import time
import sys

import pytest
@@ -157,3 +158,11 @@ def test_set_maxsize(graph):
    assert(graph.maxsize == maxsizes[12])
    with pytest.raises(KeyError):
        graph.maxsize = 7


def test_update_data(graph):
   ctime = graph.graph['modifieddate']
   time.sleep(1)
   graph._update_date()
   ntime = graph.graph['modifieddate']
   assert ctime != ntime
+10 −0
Original line number Diff line number Diff line
@@ -107,3 +107,13 @@ class TestNode(object):
        node.extract_features(image, extractor_method='sift', extractor_parameters={'nfeatures': 10})
        coverage_percn = node.coverage()
        assert coverage_percn == pytest.approx(38.06139557, 2)

    def test_clean(self, node):
        with pytest.raises(AttributeError):
            node._clean([])
        node.keypoints = pd.DataFrame(np.arange(5))
        node.masks = pd.DataFrame(np.array([[True, True, True, False, False],
                                   [True, False, True, True, False]]).T,
                                   columns=['a', 'b'])
        matches, mask = node._clean(clean_keys=['a'])
        assert mask.equals(pd.Series([True, True, True, False, False]))