def _update_group_data_perf_param(self, sim, sim_index=None): """ Update the dataframe with results of the simulation that ran. """ if sim_index is None: sim_index = self._search_for_sim_index(sim) # Update all performance parameters in output DF for that column if sim.output is None or sim.method.collection_criteria is None: # Simulation failed, don't try to eval the output: for perf_param_name, perf_param in self.perf_params.items(): self.group_data.loc[sim_index, perf_param_name] = np.nan else: eval_context = {"output": sim.output} for perf_param_name, perf_param in self.perf_params.items(): val = eval(perf_param, eval_context) self.group_data.loc[sim_index, perf_param_name] = float(val) # Free up disk space and memory if requested: if self.auto_delete_run_sims: attempt_remove_file(sim.cadet_filepath) self.simulations.remove(sim) # Manually trigger the event, because the modification happens below # the Traits layer. self.group_data_updated_event = True
def test_setuplogging_with_file(self): log_file = abspath(join(HERE, "temp.log")) initialize_logging(log_file=log_file) try: self.assert_log_file_found(expected_file=log_file) finally: attempt_remove_file(log_file)
def test_setuplogging_with_prefix(self): initialize_logging(prefix="TEMP") try: self.assert_log_file_found() finally: log_file = get_log_file() attempt_remove_file(log_file)
def test_save_task_no_ext(self): filename_no_ext = "testing_tempfile_kromatography3" task = self.task with temp_fname(filename_no_ext): task.save_project_as(filename_no_ext) self.assertFalse(isfile(filename_no_ext)) correct_file = filename_no_ext + KROM_EXTENSION self.assertTrue(isfile(correct_file)) attempt_remove_file(correct_file)
def test_get_log_file(self): root_logger = logging.getLogger() while root_logger.handlers: root_logger.handlers.pop(0) log_file = abspath(join(HERE, "temp.log")) try: root_logger.addHandler(logging.FileHandler(log_file)) found_log_file = get_log_file() self.assertEqual(found_log_file, log_file) finally: del root_logger attempt_remove_file(log_file)
def tearDown(self): root_logger = logging.getLogger() del root_logger attempt_remove_file(self.log_file)