def testBasic(self): data = numpy.random.random((100, 100)).astype(numpy.float32) data = vigra.taggedView(data, vigra.defaultAxistags('xy')) graph = Graph() opPiper = OpArrayPiper(graph=graph) opPiper.Input.setValue(data) opWriter = OpNpyWriter(graph=graph) opWriter.Input.connect(opPiper.Output) opWriter.Filepath.setValue(self._tmpdir + '/npy_writer_test_output.npy') # Write it... opWriter.write() opRead = OpInputDataReader(graph=graph) try: opRead.FilePath.setValue(opWriter.Filepath.value) expected_data = data.view(numpy.ndarray) read_data = opRead.Output[:].wait() assert (read_data == expected_data ).all(), "Read data didn't match exported data!" finally: opRead.cleanUp()
def _export_npy(self): self.progressSignal(0) export_path = self.ExportPath.value try: opWriter = OpNpyWriter( parent=self ) opWriter.Filepath.setValue( export_path ) opWriter.Input.connect( self.Input ) # Run the export in this thread opWriter.write() finally: opWriter.cleanUp() self.progressSignal(100)
def testBasic(self): data = numpy.random.random((100, 100)).astype(numpy.float32) data = vigra.taggedView(data, vigra.defaultAxistags("xy")) graph = Graph() opWriter = OpNpyWriter(graph=graph) opWriter.Input.setValue(data) opWriter.Filepath.setValue(self._tmpdir + "/npy_writer_test_output.npy") # Write it... opWriter.write() opRead = OpInputDataReader(graph=graph) opRead.FilePath.setValue(opWriter.Filepath.value) expected_data = data.view(numpy.ndarray) read_data = opRead.Output[:].wait() assert (read_data == expected_data).all(), "Read data didn't match exported data!"
def _export_npy(self): self.progressSignal(0) export_path = self.ExportPath.value try: opWriter = OpNpyWriter(parent=self) opWriter.Filepath.setValue(export_path) opWriter.Input.connect(self.Input) # Run the export in this thread opWriter.write() finally: opWriter.cleanUp() self.progressSignal(100)
def _browseForFilepath(self): starting_dir = os.path.expanduser("~") if self._filepathSlot.ready(): starting_dir = os.path.split(self._filepathSlot.value)[-1] dlg = QFileDialog(self, "Export Location", starting_dir, self._file_filter) dlg.setAcceptMode(QFileDialog.AcceptSave) if not dlg.exec_(): return exportPath = encode_from_qstring(dlg.selectedFiles()[0]) self._filepathSlot.setValue(exportPath) self.filepathEdit.setText(decode_to_qstring(exportPath)) if __name__ == "__main__": from PyQt4.QtGui import QApplication from lazyflow.graph import Graph from lazyflow.operators.ioOperators import OpNpyWriter op = OpNpyWriter(graph=Graph()) app = QApplication([]) w = FileExportOptionsWidget(None) w.initSlot(op.Filepath) w.show() app.exec_() print "Selected Filepath: {}".format(op.Filepath.value)