コード例 #1
0
 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())
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 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())
コード例 #5
0
    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)