def test_1_importFromM4(self): # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4)) doc = filedata.MisuraDocument() imp.do(doc) # autoload self.assertGreater(len(doc.data['0:hsm/sample0/h']), 10) # no load: ds present but empty self.assertIn('0:hsm/sample0/e', doc.available_data) self.assertNotIn('0:hsm/sample0/e', doc.data) hidden_data = set([ '0:hsm/sample0/iC', '0:hsm/sample0/iB', '0:hsm/sample0/iA', '0:hsm/sample0/iD' ]) self.assertSetEqual( set(m4names) - set(imp.outnames) - set(doc.available_data.keys()), hidden_data) self.check_doc(doc, nativem4) # Test single dataset name import imp = filedata.OperationMisuraImport.from_dataset_in_file( '0:hsm/sample0/e', nativem4) imp.do(doc) self.assertIn('0:hsm/sample0/e', doc.data) self.assertNotIn('0:hsm/sample0/e', doc.available_data)
def test_update(self): # Reduce elapsed time by a half elapsed_time = self.original_elapsed_time / 2. f = indexer.SharedFile(nativem4) f.set_node_attr('/conf', 'elapsed', elapsed_time) doc = filedata.MisuraDocument(proxy=f) doc.reloadData() doc.root = f.conf # # This will import only a half of the points # imp=filedata.OperationMisuraImport(filedata.ImportParamsMisura(filename=nativem4)) # imp.do(doc) nt = len(doc.data['0:t'].data) nh = len(doc.data['0:hsm/sample0/h'].data) lastt = doc.data['0:t'].data[-1] f.set_node_attr('/conf', 'elapsed', self.original_elapsed_time) r = doc.update() nt1 = len(doc.data['0:t'].data) nh1 = len(doc.data['0:hsm/sample0/h'].data) lastt1 = doc.data['0:t'].data[-1] self.assertEqual([nt1, nh1], [nt, nh]) # self.assertLess(abs(2*lastt-lastt1),doc.interval) # # Empty update r = doc.update() self.assertEqual(r, []) f.close()
def test_import(self): imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4)) doc = filedata.MisuraDocument() imp.do(doc) root = filedata.NodeEntry() root.set_doc(doc) for path, ds in doc.data.iteritems(): dataset_entry = root.traverse(path) self.assertEqual(ds, dataset_entry.ds)
def test(self): doc = filedata.MisuraDocument(nativem4) doc.reloadData() self.p.set_doc(doc) self.nav.set_doc(doc) self.p.updateCurvesMenu() self.p.updateCurveActions() self.p.hide_show('0:hsm/sample0/Vol') iutils_testing.show(self.p, __name__)
def test_0_importFromM3(self): """Test the operation from a Misura3 file""" # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=from3)) doc = filedata.MisuraDocument() imp.do(doc) m3names = [ 't', 'kiln_T', 'smp0_Sint', 'smp0_Ang', 'smp0_Ratio', 'smp0_Area', 'kiln_S', 'kiln_P', 'smp0_Width' ] self.assertEqual(imp.outnames, m3names) self.check_doc(doc, from3)
def test_2_multiImport(self): # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4)) doc = filedata.MisuraDocument() imp.do(doc) # autoload self.assertGreater(len(doc.data['0:hsm/sample0/h']), 10) # no load: ds present but empty self.assertIn('0:hsm/sample0/e', doc.available_data) self.assertNotIn('0:hsm/sample0/e', doc.data) imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4b)) imp.do(doc) self.assertIn('0:t', imp.outnames) self.assertIn('0:t', doc.data.keys())
def check_import(self, op, names=False): """Simulate a data import operation""" logging.debug('check_import', op) fp = indexer.SharedFile(op) fp.load_conf() rm = devtree.recursiveModel(fp.conf) fp.close() # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=op)) doc = filedata.MisuraDocument() imp.do(doc) # if names is not False: # self.assertEqual(set(imp.outdatasets), names) for ds in doc.data.itervalues(): self.assertFalse(np.isnan(ds.data).any()) return doc
def test(self): """Double import a file and subtract the same datasets.""" nativem4 = os.path.join(iut.data_dir, 'test_video.h5') # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4)) misuraDocument = filedata.MisuraDocument() self.cmd = document.CommandInterface(misuraDocument) plugin.makeDefaultDoc(self.cmd) imp.do(misuraDocument) # Import again imp.do(misuraDocument) misuraDocument.model.refresh() tree = misuraDocument.model.tree entry = tree.traverse('0:hsm/sample0') self.assertTrue(entry != False) self.do(misuraDocument, entry)
def test(self): # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4)) doc = filedata.MisuraDocument() self.cmd = document.CommandInterface(doc) plugin.makeDefaultDoc(self.cmd) imp.do(doc) fields = { 'd': 'summary/vertical/sample0/d', 'T': 'summary/kiln/T', 'std': 'NIST SRM738', 'start': 50, 'end': 50, 'label': 1, 'add': 1, 'currentwidget': '/' } p = plugin.CalibrationFactorPlugin() p.apply(self.cmd, fields) self.assertIn(fields['d'] + '_NIST_SRM738', doc.data) doc.model.refresh(force=True)
def test_init(self): fpath = os.path.join(iutils_testing.data_dir, 'test_video.h5') # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=fpath)) doc = filedata.MisuraDocument() imp.do(doc) fp = indexer.SharedFile(fpath) decoder = filedata.DataDecoder() profile = '/hsm/sample0/profile' decoder.reset(fp, profile) self.sync(decoder) doc.decoders[fpath+':'+profile] = decoder mini = fileui.MiniImage(doc, '/hsm/sample0/profile') mini.saveDir = iutils_testing.data_dir mini.set_idx(0) self.saved_file = mini.save_frame() self.assertTrue(os.path.exists(self.saved_file))
def test_openfile(self): doc = filedata.MisuraDocument(test_file_name) w = browser.TestWindow(doc) w.close()
def setUpClass(cls): f = indexer.SharedFile(nativem4) cls.doc = filedata.MisuraDocument(proxy=f) cls.doc.reloadData() f.close()
def test_get_row(self): doc = filedata.MisuraDocument(filename=nativem4) doc.reloadData() row = doc.get_row(5)
def test(self): doc = filedata.MisuraDocument(nativem4) doc.reloadData() self.s.set_doc(doc) iutils_testing.show(self.s, __name__)