def save_results(self): """ Saves results in save_file_full_name. """ self.reporter.write('Saving results (trial-iter:%d) to %s ... ' % (self.trial_iter, \ self.save_file_full_name)) try: if self.save_file_extension == 'mat': dict_to_be_saved = vars(self.to_be_saved) dict_to_be_mat_saved = {key: val for key, val in dict_to_be_saved.items() if key not in self.data_not_to_be_mat_saved} # Fix for crash in single fidelity case -- replacing None with 'xx'. for i in range(dict_to_be_mat_saved['query_eval_times'].shape[0]): if isinstance(dict_to_be_mat_saved['query_eval_times'][i, -1], str): continue query_eval_times = [val if val is not None else 'xx' for val in \ dict_to_be_mat_saved['query_eval_times'][i, -1]] dict_to_be_mat_saved['query_eval_times'][i, -1] = query_eval_times sio_savemat(self.save_file_full_name, mdict=dict_to_be_mat_saved) else: raise NotImplementedError('Only implemented saving mat files so far.') save_successful = True except IOError: save_successful = False # Report saving status if save_successful: self.reporter.writeln('successful.') else: self.reporter.writeln('unsuccessful!!')
def save_results(self): """ Saves results in save_file_full_name. """ self.reporter.write('Saving results (exp-iter:%d) to %s ... ' % (self.experiment_iter, self.save_file_full_name)) try: if self.save_file_extension == 'mat': dict_to_be_saved = vars(self.to_be_saved) dict_to_be_mat_saved = { key: val for key, val in six.iteritems(dict_to_be_saved) if key not in self.data_not_to_be_mat_saved } sio_savemat(self.save_file_full_name, mdict=dict_to_be_mat_saved) else: raise NotImplementedError( 'Only implemented saving mat files so far.') save_successful = True except IOError: save_successful = False # Report saving status if save_successful: self.reporter.writeln('successful.') else: self.reporter.writeln('unsuccessful!!')
def save_results(self): """ Saves results in save_file_name. """ self.reporter.write('Saving results (exp-iter:%d) to %s ... '%(self.experiment_iter, self.save_file_name)) try: if self.save_file_extension == 'mat': sio_savemat(self.save_file_name, mdict=vars(self.to_be_saved)) else: raise NotImplementedError('Only implemented saving mat files so far.') save_successful = True except IOError: save_successful = False # Report saving status if save_successful: self.reporter.writeln('successful.') else: self.reporter.writeln('unsuccessful!!')