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_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_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)
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))