Commit d54a3f57 authored by Jay's avatar Jay Committed by jay
Browse files

@kree Update for comments

parent 63ad7154
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -39,8 +39,8 @@ class CandidateGraph(nx.Graph):
               list of node indices
    ----------
    """
    edge_attr_dict_factory = Edge
    node_dict_factory = Node



    def __init__(self, *args, basepath=None, **kwargs):
        super(CandidateGraph, self).__init__(*args, **kwargs)
@@ -54,7 +54,7 @@ class CandidateGraph(nx.Graph):
            image_path = node_name

            # Replace the default node dict with an object
            self.node[node_name] = Node(image_name, image_path)
            self.node[node_name] = Node(image_name, image_path, self.node_counter)
            # fill the dictionary used for relabelling nodes with relative path keys
            node_labels[node_name] = self.node_counter
            # fill the dictionary used for mapping base name to node index
@@ -66,6 +66,7 @@ class CandidateGraph(nx.Graph):
        for s, d, edge in self.edges_iter(data=True):
            self.edge[s][d] = Edge(self.node[s], self.node[d])


    @classmethod
    def from_graph(cls, graph):
        """
@@ -629,7 +630,8 @@ class CandidateGraph(nx.Graph):
        if not hasattr(self, 'clusters'):
            raise AttributeError('No clusters have been computed for this graph.')
        nodes_in_cluster = self.clusters[arg]
        subgraph = self.subgraph(nodes_in_cluster)
        edges_in_cluster = [(u,v) for u,v in self.edges() if u in nodes_in_cluster and v in nodes_in_cluster]
        subgraph = self.subgraph(edges_in_cluster)
        return subgraph

    @create_subgraph.register(pd.DataFrame)
+19 −3
Original line number Diff line number Diff line
@@ -42,9 +42,10 @@ class Node(dict, MutableMapping):
                  ISIS compatible serial number
    """

    def __init__(self, image_name=None, image_path=None):
    def __init__(self, image_name=None, image_path=None, node_id=None):
        self.image_name = image_name
        self.image_path = image_path
        self.node_id = node_id
        self._mask_arrays = {}

    def __repr__(self):
@@ -55,7 +56,7 @@ class Node(dict, MutableMapping):
        Number Keypoints: {}
        Available Masks : {}
        Type: {}
        """.format(None, self.image_name, self.image_path,
        """.format(self.node_id, self.image_name, self.image_path,
                   self.nkeypoints, self.masks, self.__class__)
    @property
    def handle(self):
@@ -79,7 +80,7 @@ class Node(dict, MutableMapping):
        mask_lookup = {'suppression': 'suppression'}

        if not hasattr(self, '_keypoints'):
            warnings.warn('Keypoints have note been extracted')
            warnings.warn('Keypoints have not been extracted')
            return

        if not hasattr(self, '_masks'):
@@ -126,6 +127,21 @@ class Node(dict, MutableMapping):
        return bytescale(array)

    def get_keypoints(self, index=None):
        """
        Return the keypoints for the node.  If index is passed, return
        the appropriate subset.

        Parameters
        ----------
        index : iterable
                indices for of the keypoints to return

        Returns
        -------
         : dataframe
           A pandas dataframe of keypoints

        """
        if hasattr(self, '_keypoints'):
            try:
                return self._keypoints.iloc[index]