Example #1
0
    def test7(self):
        parameter_definition1 = parameters.ModuleCachingParameterDefinition(
            "initialize_vars", "arg1", "test_par1", "a test parameter (1)",
            11.0 | units.m)

        parameter_definition2 = parameters.ModuleCachingParameterDefinition(
            "initialize_vars", "arg2", "test_par2", "a test parameter (2)",
            12.0 | units.m)

        class TestModule(BaseTestModule):
            x = 123 | units.m
            y = 456 | units.m

            def initialize_vars(self, arg1, arg2):
                self.x = arg1
                self.y = arg2

        o = TestModule()
        x = parameters.Parameters(
            [parameter_definition1, parameter_definition2], o)
        x.test_par1 = 20 | units.m
        print(x.test_par1)
        self.assertEqual(x.test_par1, 20 | units.m)
        self.assertEqual(x.test_par2, 12 | units.m)
        self.assertEqual(o.x, 123 | units.m)
        self.assertEqual(o.y, 456 | units.m)
        x.send_cached_parameters_to_code()
        self.assertEqual(o.x, 20 | units.m)
        self.assertEqual(o.y, 12 | units.m)
 def test8(self):
     parameter_definition1 = parameters.ModuleCachingParameterDefinition(
         "initialize_vars",
         "arg1",
         "test_par1",
         "a test parameter (1)",
         11.0 | units.m
     )
 
     parameter_definition2 = parameters.ModuleCachingParameterDefinition(
         "initialize_vars",
         "arg2",
         "test_par2",
         "a test parameter (2)",
         12.0 | units.m
     )
 
     parameter_definition3 = parameters.ModuleCachingParameterDefinition(
         "initialize_vars2",
         "arg1",
         "test_par3",
         "a test parameter (3)",
         14.0 | units.m
     )
 
     class TestModule(BaseTestModule):
         x = 123 | units.m
         y = 456 | units.m
         z = 100 | units.m
 
         def initialize_vars(self, arg1, arg2):
             self.x = arg1
             self.y = arg2
             return 0
 
         def initialize_vars2(self, arg1):
             self.z = arg1
             return 0
 
 
     o = TestModule()
     x = parameters.Parameters([parameter_definition1, parameter_definition2, parameter_definition3], o)
     
     x.send_cached_parameters_to_code()
     self.assertEquals(o.x, 11 | units.m)
     self.assertEquals(o.y, 12 | units.m)
     self.assertEquals(o.z, 14 | units.m)