From b3d681ef165c96f0900957c8aa84827702eccbab Mon Sep 17 00:00:00 2001 From: einarr Date: Tue, 1 Aug 2006 13:22:39 +0000 Subject: [PATCH] * system/plots.py: Added NetworkPlot, which may or may not work correctly. * system/dataset.py: Removed a few lines of obsolete code. --- system/dataset.py | 15 +---- system/plots.py | 123 ++++++++++++++++++++++++++++++------- workflows/test_workflow.py | 11 +++- 3 files changed, 113 insertions(+), 36 deletions(-) diff --git a/system/dataset.py b/system/dataset.py index f9a0a80..d3dc22d 100644 --- a/system/dataset.py +++ b/system/dataset.py @@ -113,10 +113,7 @@ class Dataset: def asarray(self): """Returns the numeric array (data) of dataset""" - if not self.has_array: - raise ValueError, "Dataset is empty" - else: - return self._array + return self._array def add_array(self,array): """Adds array as an ArrayType object. @@ -199,14 +196,7 @@ class CategoryDataset(Dataset): def __init__(self): Dataset.__init__(self) - self.has_collection = False - def as_array(self): - """Returns data as binary matrix""" - if not self.has_array and self.has_collection: - #build numeric array - pass - def as_collection(self,dim): """Returns data as collection along dim""" pass @@ -236,7 +226,7 @@ class GraphDataset(Dataset): self.has_graph = False def asnetworkx(self,nx_type='graph'): - dim = self.get_dim_names()[0] + dim = self.get_dim_name()[0] ids = self.get_identifiers(dim) adj_mat = self.asarray() G = self._graph_from_adj_matrix(adj_mat,labels=ids) @@ -270,6 +260,7 @@ class GraphDataset(Dataset): tail = labels[i] G.add_edge(head,tail) return G + Dataset._all_dims=set() class Selection: diff --git a/system/plots.py b/system/plots.py index f0e360e..43c01b6 100644 --- a/system/plots.py +++ b/system/plots.py @@ -11,6 +11,7 @@ from matplotlib.figure import Figure from matplotlib.numerix import arange, sin, pi from matplotlib.widgets import RectangleSelector from matplotlib import cm +import networkx from system import logger @@ -471,54 +472,130 @@ class ScatterPlot(Plot): # find indices of selected area if x1>x2: - if y1x2) & (ydata>y1) & (ydatax2) & (ydatay2)) - else: - #logger.log('debug','Selection x_start less than x_end') - if y1x1) & (xdatay1) & (ydatax1) & (xdatay2)) + x1, x2 = x2, x1 + if y1>y2: + y1, y2 = y2, y1 + assert x1<=x2 + assert y1<=y2 + + index = scipy.nonzero((xdata>x1) & (xdatay1) & (ydata x2: + x1, x2 = x2, x1 + if y1 > y2: + y1, y2 = y2, y1 + index = nonzero((xdatax2) & (ydata>y1) & (ydata