def test_one_box(box,tree,graphics=False,callback=None):#,f): print 'box',box[0],box[1],':', s = tree.search(box) print "" print "box search:", s print "len(s):", len( s ) boxes = tree.boxes() if graphics: plt.close() gfx.show_uboxes(boxes) gfx.show_uboxes(boxes, S=s, col='r') if len(s) < ((tree.dim**tree.depth)/2): # dim^depth/2 t = tree.insert(box) if graphics: boxes = tree.boxes() gfx.show_uboxes(boxes, S=t, col='c') print 'ins:',t else: t = tree.remove(s) print 'rem:',t if graphics: gfx.show_box(box,col='g',alpha=0.5) if callback: plt.gcf().canvas.mpl_connect('button_press_event', callback) plt.show()
def show_error_boxes(self, box=None, color="r", alpha=0.6, fig=None): """ """ error_boxes = izip(self.data, self.noise) for b in error_boxes: # shift center to lower left corner anchor bx = self._make_box(b) fig = gfx.show_box(bx, col=color, alpha=alpha, fig=fig) return fig
def show_error_boxes( self, box=None, color='r', alpha=0.6, fig=None ): """ """ error_boxes = izip( self.data, self.noise ) # boxes = [ self._make_box( b ) for b in error_boxes ] # gfx.show_boxes( error_boxes, S=range( len(boxes) ), col=color, # alpha=alpha, fig=fig ) for b in error_boxes: # shift center to lower left corner anchor bx = self._make_box( b ) fig = gfx.show_box( bx, col=color, alpha=alpha, fig=fig ) return fig