Commits

Miha Stajdohar committed 0d01d94

Network view related bugs.

Comments (0)

Files changed (2)

_modelmaps/widgets/OWModelEmbedder.py

         OWWidget.__init__(self, parent, signalManager, name, noReport=True)
 
         self.inputs = [("Data", data.Table, self.setData),
-                       ("Model", modelmaps.Model, self.setModel)]
+                       ("Model", modelmaps.Model, self.setModel, Default)]
 
         self.outputs = [("Selected Data", data.Table), ("Other Data", data.Table)]
 

_modelmaps/widgets/OWModelMap.py

 #import OWToolbars
 #import OWColorPalette
 
-from Orange import classification, data, feature, misc, modelmaps, network
+from Orange import classification, data, feature, misc, modelmaps, network, utils
 from Orange.network.community import CommunityDetection
 from OWNxCanvasQt import OWNxCanvas
 
 from OWNxHist import *
 from OWDistributions import OWDistributionGraph
 
-dir = Orange.utils.environ.widget_install_dir
+dir = utils.environ.widget_install_dir
 
 ICON_PATHS = [("TREE", "Classify/icons/ClassificationTree"),
               ("SCATTERPLOT", "Visualize/icons/ScatterPlot"),
 
         tooltip_attributes = [self.items.domain[att] for att in \
                                  attributes if att in self.items.domain]
-        self.networkCurve.set_node_tooltips(dict((node, ', '.join(str(\
+        self.networkCurve.set_node_tooltips(dict((node, ', '.join(str( \
                    self.items[node][att]) for att in tooltip_attributes)) \
                                                         for node in self.graph))
 
         self._community_detection = community_detection
         self._representatives = None
         self._expanded_nodes = set()
+        self._representatives_graph = None
 
     def __del__(self):
         if self._nx_explorer is not None:
         #for key, val in clusters.items():
         #    representatives.append(max(val, key=lambda x, items=items: items[x]["CA"].value))
         # find neighbors for all representatives
-        repr_neighbors = {key: set(itertools.chain.from_iterable(self._network.adj[n].keys() for n in cluster)) for key, cluster in self._representatives.iteritems()}
+        subgraph = network.nx.Graph.subgraph(self._network, self._representatives.iterkeys())
 
-        repr_keys = repr_neighbors.keys()
-        edges = list(itertools.chain.from_iterable([(repr_keys[i], repr_keys[j]) for j in range(i) if repr_keys[i] in repr_neighbors[repr_keys[j]]] for i in range(len(repr_keys))))
-
-        # add meta-edges between representatives
-        subgraph = network.nx.Graph.subgraph(self._network, self._representatives.iterkeys())
-        subgraph.add_edges_from(edges)
+        # add meta-edges between representatives        
+        #repr_neighbors = {key: set(itertools.chain.from_iterable(self._network.adj[n].keys() for n in cluster)) for key, cluster in self._representatives.iteritems()}
+        #repr_keys = repr_neighbors.keys()
+        #edges = list(itertools.chain.from_iterable([(repr_keys[i], repr_keys[j]) for j in range(i) if repr_keys[i] in repr_neighbors[repr_keys[j]]] for i in range(len(repr_keys))))
+        #subgraph.add_edges_from(edges)
+        #self._representatives_graph = subgraph
 
         return subgraph
 
             self._expanded_nodes.add(node)
 
         subgraph = network.nx.Graph.subgraph(self._network, nodes)
-        map(lambda n: ModelItem.set_selected(n, True), self._expanded_nodes)
+        self.select_expanded()
         qApp.processEvents()
         self._nx_explorer.change_graph(subgraph)
         self.set_representatives()
 
+    def select_expanded(self):
+        map(lambda n: ModelItem.set_marked(n, True), self._expanded_nodes)
+
 class OWModelMap(OWNxExplorer, OWNxHist):
 
     settingsList = ["autoSendSelection", "spinExplicit", "spinPercentage",
     def node_selection_changed(self):
         self.warning()
 
-        if self.graph is None or self.graph.items() is None or self.graph_matrix is None:
+        graph = self.graph_base
+
+        if graph is None or graph.items() is None or self.graph_matrix is None:
             self.send("Model", None)
             self.send("Selected Models", None)
             return
 
-        if self.graph.number_of_nodes() != self.graph_matrix.dim:
+        if graph.number_of_nodes() != self.graph_matrix.dim:
             self.warning('Network items and matrix results not of equal length.')
             self.send("Model", None)
             self.send("Selected Models", None)
         selection = self.networkCanvas.selected_nodes()
 
         if len(selection) == 1:
-            model = self.graph.items()[selection[0]]['model'].value
+            model = graph.items()[selection[0]]['model'].value
             self.send('Model', model)
-            self.send('Selected Models', self.graph.items().getitems(selection))
+            self.send('Selected Models', graph.items().getitems(selection))
         elif len(selection) > 1:
             self.send('Model', None)
-            self.send('Selected Models', self.graph.items().getitems(selection))
+            self.send('Selected Models', graph.items().getitems(selection))
         else:
             self.send('Model', None)
             self.send('Selected Models', None)
 
+        if self._network_view:
+            self._network_view.select_expanded()
+
     def sendSignals(self):
         if self.graph is None or self.graph_matrix is None:
             self.set_graph_none()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.