Exemplo n.º 1
0
    def test2_get_config_simulation(self):
        _cfg = Configuration()
        _cfg.read(self.tempf)
        self.assertRaises(ValueError, _cfg.get_config, "simulation")

        self.string2 = re.sub(r"= mode", r"= simulation", self.string2)
        self.write(self.string2, self.tempf)
        _cfg.clear()
        _cfg.read(self.tempf)
        self.assertTrue("path" in _cfg.get_config("simulation"))
Exemplo n.º 2
0
    def test0_read(self):
        self.write(self.string1, self.tempf)
        _cfg = Configuration()
        self.assertRaises(ValueError, _cfg.read, self.tempf)

        self.write(self.string2, self.tempf)
        _cfg.clear()
        self.assertEqual(None, _cfg.read(self.tempf))
Exemplo n.º 3
0
    def test3_get_config_properties(self):
        _cfg = Configuration()
        _cfg.read(self.tempf)
        # totalProperties
        self.assertRaises(ValueError, _cfg.get_config, "properties")

        self.string2 = re.sub(r"= total.*", r"= 0", self.string2)
        self.write(self.string2, self.tempf)
        _cfg.clear()
        _cfg.read(self.tempf)
        self.assertRaises(ValueError, _cfg.get_config, "properties")

        more_configs = (r"= 1\n"
                            r"property1Name = \n"
                            r"property1Ref = 1\n")
        self.string2 = re.sub(r"= 0", more_configs, self.string2)
        self.write(self.string2, self.tempf)
        _cfg.clear()
        _cfg.read(self.tempf)
        self.assertEqual([1.0], _cfg.get_config("properties")[2])
Exemplo n.º 4
0
        yn.update_property_list()

    print("\nCalculating Target Value...:")
    targetValue = sum([yn.target_function() for yn in y])
    print("Current targeted value:", targetValue)

    return targetValue


if __name__ == "__main__":

    welcome()

    confFile = get_cmd_arg()
    cfg = Configuration()
    cfg.read(confFile)
    #TODO no need a class.

    (optMethod, ) = cfg.get_config("optimization")
    (
        initParaTableFile,
        paraTableFile,
        ffForSimulation,
        ffTemplate,
    ) = cfg.get_config('parameters')
    (
        mode,
        execute,
        path,
        processScript,
    ) = cfg.get_config('simulation')
Exemplo n.º 5
0
 def test1_get_config(self):
     _cfg = Configuration()
     _cfg.read(self.tempf)
     self.assertEqual(["optmethod"], _cfg.get_config("optimization"))
     self.assertTrue("fftemplate" in _cfg.get_config("parameters"))