예제 #1
0
 def test_run_plugin_multi_datasets(self):
     """Verify run_plugin convenience function correctly handles datafiles with
     multiple datasets"""
     sample_data_folder = os.path.join(pathfinder.app_path(), 'models',
                                       'tests', 'support_files')
     sample_utwin_file = os.path.join(sample_data_folder, 'CScanData.csc')
     utwin_data = dataio.get_utwin_data(sample_utwin_file)
     expected_utwin_data = {}
     for data_type in utwin_data.keys():
         for idx in range(len(utwin_data[data_type])):
             expected_utwin_data[data_type +
                                 str(idx)] = utwin_data[data_type][idx]
     output_fnames = []
     root, ext = os.path.splitext(os.path.basename(sample_utwin_file))
     for dataset in expected_utwin_data:
         output_fnames.append(
             os.path.join(pathfinder.batchoutput_path(),
                          root + "_" + dataset + ".hdf5"))
     # Verify no output saved
     batchui_ctrl.run_plugin(self.toolkit_class,
                             sample_utwin_file,
                             save_data=False)
     for fname in output_fnames:
         self.assertFalse(os.path.exists(fname))
     # Verify output saved
     batchui_ctrl.run_plugin(self.toolkit_class,
                             sample_utwin_file,
                             save_data=True)
     for dataset in expected_utwin_data:
         if expected_utwin_data[dataset] is not None:
             fname = os.path.join(pathfinder.batchoutput_path(),
                                  root + "_" + dataset + ".hdf5")
             self.assertTrue(os.path.exists(fname))
             plugin_names, plugin_classes = self.get_available_plugins()
             for idx in range(len(plugin_names)):
                 if plugin_names[idx] == self.toolkit_class:
                     plugin_instance = plugin_classes[idx]()
                     plugin_instance.data = expected_utwin_data[dataset]
                     plugin_instance.run()
                     expected_data = plugin_instance.data
                     returned_data = dataio.get_data(fname)
                     self.assertTrue(
                         np.array_equal(expected_data, returned_data))
                     break
     for fname in output_fnames:
         try:
             if os.path.exists(fname):
                 os.remove(fname)
         except WindowsError:  # file in use (Windows)
             pass
         except OSError:  # other OS error
             pass
예제 #2
0
 def test_run_plugin(self):
     """Verify run_plugin convenience function correctly executes"""
     root, ext = os.path.splitext(os.path.basename(self.datafile))
     output_fname = os.path.join(pathfinder.batchoutput_path(), root + ".hdf5")
     batchui_ctrl.run_plugin(self.toolkit_class, self.datafile, save_data=False)
     self.assertFalse(os.path.exists(output_fname))
     batchui_ctrl.run_plugin(self.toolkit_class, self.datafile, save_data=True)
     self.assertTrue(os.path.exists(output_fname))
     plugin_names, plugin_classes = self.get_available_plugins()
     for idx in range(len(plugin_names)):
         if plugin_names[idx] == self.toolkit_class:
             plugin_instance = plugin_classes[idx]()
             plugin_instance.data = dataio.get_data(self.datafile)
             plugin_instance.run()
             expected_data = plugin_instance.data
             stored_data = dataio.get_data(output_fname)
             self.assertTrue(np.array_equal(expected_data, stored_data))
             break
     if os.path.exists(output_fname):
         try:
             os.remove(output_fname)
         except WindowsError: # file in use (Windows)
             pass
         except OSError: # other OS error
             pass
예제 #3
0
 def test_run_plugin(self):
     """Verify run_plugin convenience function correctly executes"""
     root, ext = os.path.splitext(os.path.basename(self.datafile))
     output_fname = os.path.join(pathfinder.batchoutput_path(),
                                 root + ".hdf5")
     batchui_ctrl.run_plugin(self.toolkit_class,
                             self.datafile,
                             save_data=False)
     self.assertFalse(os.path.exists(output_fname))
     batchui_ctrl.run_plugin(self.toolkit_class,
                             self.datafile,
                             save_data=True)
     self.assertTrue(os.path.exists(output_fname))
     plugin_names, plugin_classes = self.get_available_plugins()
     for idx in range(len(plugin_names)):
         if plugin_names[idx] == self.toolkit_class:
             plugin_instance = plugin_classes[idx]()
             plugin_instance.data = dataio.get_data(self.datafile)
             plugin_instance.run()
             expected_data = plugin_instance.data
             stored_data = dataio.get_data(output_fname)
             self.assertTrue(np.array_equal(expected_data, stored_data))
             break
     if os.path.exists(output_fname):
         try:
             os.remove(output_fname)
         except WindowsError:  # file in use (Windows)
             pass
         except OSError:  # other OS error
             pass
예제 #4
0
 def check_user_path(self):
     """Verify user data folders were created"""
     data_folders = [pathfinder.user_path(), pathfinder.data_path(),
                     pathfinder.thumbnails_path(), pathfinder.gates_path(),
                     pathfinder.plugins_path(), pathfinder.podmodels_path(),
                     pathfinder.colormaps_path(), pathfinder.batchoutput_path()]
     self.model.check_user_path()
     for folder in data_folders:
         self.assertTrue(os.path.exists(folder))
예제 #5
0
 def check_user_path(self):
     """Verify user data folders were created"""
     data_folders = [pathfinder.user_path(), pathfinder.data_path(),
                     pathfinder.thumbnails_path(), pathfinder.gates_path(),
                     pathfinder.plugins_path(), pathfinder.podmodels_path(),
                     pathfinder.adamodels_path(), pathfinder.colormaps_path(),
                     pathfinder.batchoutput_path()]
     self.model.check_user_path()
     for folder in data_folders:
         self.assertTrue(os.path.exists(folder))
예제 #6
0
 def test_run_plugin_multi_datasets(self):
     """Verify run_plugin convenience function correctly handles datafiles with
     multiple datasets"""
     sample_data_folder = os.path.join(pathfinder.app_path(), 'models', 'tests', 'support_files')
     sample_utwin_file = os.path.join(sample_data_folder, 'CScanData.csc')
     utwin_data = dataio.get_utwin_data(sample_utwin_file)
     expected_utwin_data = {}
     for data_type in utwin_data.keys():
         for idx in range(len(utwin_data[data_type])):
             expected_utwin_data[data_type + str(idx)] = utwin_data[data_type][idx]
     output_fnames = []
     root, ext = os.path.splitext(os.path.basename(sample_utwin_file))
     for dataset in expected_utwin_data:
         output_fnames.append(os.path.join(pathfinder.batchoutput_path(), root + "_" + dataset + ".hdf5"))
     # Verify no output saved
     batchui_ctrl.run_plugin(self.toolkit_class, sample_utwin_file, save_data=False)
     for fname in output_fnames:
         self.assertFalse(os.path.exists(fname))
     # Verify output saved
     batchui_ctrl.run_plugin(self.toolkit_class, sample_utwin_file, save_data=True)
     for dataset in expected_utwin_data:
         if expected_utwin_data[dataset] is not None:
             fname = os.path.join(pathfinder.batchoutput_path(), root + "_" + dataset + ".hdf5")
             self.assertTrue(os.path.exists(fname))
             plugin_names, plugin_classes = self.get_available_plugins()
             for idx in range(len(plugin_names)):
                 if plugin_names[idx] == self.toolkit_class:
                     plugin_instance = plugin_classes[idx]()
                     plugin_instance.data = expected_utwin_data[dataset]
                     plugin_instance.run()
                     expected_data = plugin_instance.data
                     returned_data = dataio.get_data(fname)
                     self.assertTrue(np.array_equal(expected_data, returned_data))
                     break
     for fname in output_fnames:
         try:
             if os.path.exists(fname):
                 os.remove(fname)
         except WindowsError: # file in use (Windows)
             pass
         except OSError: # other OS error
             pass
예제 #7
0
 def check_user_path(cls):
     """Verify that user data folders exist.  Creates
     any missing folders."""
     user_folder = pathfinder.user_path()
     data_folder = pathfinder.data_path()
     thumbnail_folder = pathfinder.thumbnails_path()
     plugins_folder = pathfinder.plugins_path()
     podmodels_folder = pathfinder.podmodels_path()
     adamodels_folder = pathfinder.adamodels_path()
     gates_folder = pathfinder.gates_path()
     colormaps_folder = pathfinder.colormaps_path()
     batch_folder = pathfinder.batchoutput_path()
     for fldr in (user_folder, data_folder, thumbnail_folder, plugins_folder, podmodels_folder, gates_folder,
         adamodels_folder, colormaps_folder, batch_folder):
         if not os.path.exists(fldr):
             os.makedirs(fldr)
예제 #8
0
 def check_user_path(cls):
     """Verify that user data folders exist.  Creates
     any missing folders."""
     user_folder = pathfinder.user_path()
     data_folder = pathfinder.data_path()
     thumbnail_folder = pathfinder.thumbnails_path()
     plugins_folder = pathfinder.plugins_path()
     podmodels_folder = pathfinder.podmodels_path()
     gates_folder = pathfinder.gates_path()
     colormaps_folder = pathfinder.colormaps_path()
     batch_folder = pathfinder.batchoutput_path()
     for fldr in (user_folder, data_folder, thumbnail_folder,
                  plugins_folder, podmodels_folder, gates_folder,
                  colormaps_folder, batch_folder):
         if not os.path.exists(fldr):
             os.makedirs(fldr)
예제 #9
0
 def test_batchoutput_path(self):
     """Verify returning correct path to batch processing output"""
     batchoutput_path = os.path.join(self.user_path, "data", "batch_output")
     self.assertEqual(batchoutput_path, pathfinder.batchoutput_path())
예제 #10
0
 def test_batchoutput_path(self):
     """Verify returning correct path to batch processing output"""
     batchoutput_path = os.path.join(self.user_path, "data", "batch_output")
     self.assertEqual(batchoutput_path, pathfinder.batchoutput_path())