def test_analysis_replace_results_false(self): """Test running analysis with replace_results=False""" analysis = FakeAnalysis() expdata1 = analysis.run(ExperimentData(), seed=54321) self.assertExperimentDone(expdata1) expdata2 = analysis.run(expdata1, replace_results=False, seed=12345) self.assertExperimentDone(expdata2) self.assertNotEqual(expdata1, expdata2) self.assertNotEqual(expdata1.experiment_id, expdata2.experiment_id) self.assertNotEqual(expdata1.analysis_results(), expdata2.analysis_results())
def test_analysis_replace_results_true(self): """Test running analysis with replace_results=True""" analysis = FakeAnalysis() expdata1 = analysis.run(ExperimentData(), seed=54321) self.assertExperimentDone(expdata1) result_ids = [res.result_id for res in expdata1.analysis_results()] expdata2 = analysis.run(expdata1, replace_results=True, seed=12345) self.assertExperimentDone(expdata2) self.assertEqual(expdata1, expdata2) self.assertEqual(expdata1.analysis_results(), expdata2.analysis_results()) self.assertEqual(result_ids, list(expdata2._deleted_analysis_results))
def test_analysis_from_config(self): """Test analysis config dataclass""" analysis = FakeAnalysis(arg1=10, arg2=20) analysis.set_options(option1=False, option2=True) config = analysis.config() loaded = FakeAnalysis.from_config(config) self.assertEqual(config, loaded.config())
def test_analysis_config(self): """Test analysis config dataclass""" analysis = FakeAnalysis(arg1=10, arg2=20) analysis.set_options(option1=False, option2=True) config = analysis.config() loaded = config.analysis() self.assertEqual(analysis.config(), loaded.config()) self.assertEqual(analysis.options, loaded.options)
def test_analysis_runtime_opts(self): """Test runtime options don't modify instance""" opts = {"opt1": False, "opt2": False} run_opts = {"opt1": True, "opt2": True, "opt3": True} analysis = FakeAnalysis() analysis.set_options(**opts) analysis.run(ExperimentData(), **run_opts) self.assertEqual(analysis.options.__dict__, opts)
def test_analysis_from_dict_config(self): """Test analysis config dataclass for dict type.""" analysis = FakeAnalysis(arg1=10, arg2=20) analysis.set_options(option1=False, option2=True) config = analysis.config() loaded = FakeAnalysis.from_config({ "kwargs": config.kwargs, "options": config.options }) self.assertEqual(config, loaded.config())
def test_analysis_runtime_opts(self): """Test runtime options don't modify instance""" opts = {"opt1": False, "opt2": False} run_opts = {"opt1": True, "opt2": True, "opt3": True} analysis = FakeAnalysis() analysis.set_options(**opts) analysis.run(ExperimentData(), **run_opts) # add also the default 'figure_names' option target_opts = opts.copy() target_opts["figure_names"] = None self.assertEqual(analysis.options.__dict__, target_opts)