def redo(self, doc): print "Undo.redo()" if len(self.redoList) > 0: redoEvent = misc.unpickle(self.redoList[-1]) self.setUndo(doc, redoEvent[0], redoEvent[1], True) doc.setBrightRange(redoEvent[0]) if redoEvent[1] != None: doc.data = redoEvent[1] self.redoList[-1].close() self.redoList = self.redoList[0:-1]
def redo(self, doc): print "UndoRGB.redo()" if len(self.redoList) > 0: redoEvent = misc.unpickle(self.redoList[-1]) self.setUndo(doc, redoEvent[0], redoEvent[1:], True) doc.setBrightRange(redoEvent[0]) for i in range(1, len(redoEvent)): if redoEvent[i] != None: doc.rgb[i - 1].data = redoEvent[i] self.redoList[-1].close() self.redoList = self.redoList[0:-1]
def undo(self, doc): print "Undo.undo()" if len(self.undoList) > 0: redoEvent = [doc.getBrightRange()] undoEvent = misc.unpickle(self.undoList[-1]) doc.setBrightRange(undoEvent[0]) if undoEvent[1] != None: redoEvent.append(doc.data) doc.data = undoEvent[1] else: redoEvent.append(None) self.undoList[-1].close() self.undoList = self.undoList[0:-1] self.redoList.append(misc.pickle(redoEvent))
def undo(self, doc): print "UndoRGB.undo()" if len(self.undoList) > 0: redoEvent = [doc.getBrightRange()] undoEvent = misc.unpickle(self.undoList[-1]) doc.setBrightRange(undoEvent[0]) for i in range(1, len(undoEvent)): if undoEvent[i] != None: redoEvent.append(doc.rgb[i - 1].data) doc.rgb[i - 1].data = undoEvent[i] else: redoEvent.append(None) self.undoList[-1].close() self.undoList = self.undoList[0:-1] self.redoList.append(misc.pickle(redoEvent))
def load_batch(self, pth): if os.path.exists(pth): loaded = misc.unpickle(pth) labels = np.asarray(loaded['labels']) pixels = np.asarray(loaded['data']) elif os.path.exists(pth + '.bin'): loaded = np.fromfile(pth + '.bin', dtype=np.uint8).reshape(-1, 3073) labels = loaded[:, 0] pixels = loaded[:, 1:] else: raise ValueError("couldn't find {}".format(pth)) idx = np.in1d(labels, self.categories) labels = labels[idx] pixels = pixels[idx].reshape(-1, 3, 32, 32) if self.format == 'NHWC': pixels = pixels.transpose(0, 2, 3, 1) return labels, pixels