def test_init_wrong_type(): with open('test.dat', 'w') as content: content.write('olympus') database = Database().from_file('test.dat') assert len(Logger.ERRORS) == 2 Logger.purge() os.remove('test.dat')
def test_auto_init_pickle(): file_name = 'test.pickle' with open(file_name, 'wb') as content: pickle.dump({}, content) database = Database().from_file(file_name) assert database.db.kind == 'pkl' os.remove(file_name) Logger.purge()
def test_trace_plot(): # run short campaign olymp = Olympus() olymp.run(planner='BasinHopping', dataset='hplc', num_iter=3) # choose fast method to speed up testing # load database from file file_name = olymp.database.db.file_name database = Database().from_file(file_name) # plot campaign plot_file_name = 'test.png' plotter = Plotter().plot_from_db(database, plot_file_name=plot_file_name) assert os.path.isfile(plot_file_name) # remove file os.remove(plot_file_name)
def test_init_wrong_path(): database = Database().from_file('test.pkl') assert len(Logger.ERRORS) == 1 Logger.purge()
def test_init_pickle(): database = Database(kind='pickle') assert database.db.kind == 'pkl' Logger.purge()
def _load_baseline_db(self, dataset): file_name = self.baseline_db_files[dataset] db = Database().from_file(file_name) self.baseline_dbs[dataset] = db return db