Esempio n. 1
0
    def test_set_value_LHS(self):
        seed(1)
        normdist = norm([1, 3, 4], [0.1, 0.5, 1])
        mg = LatinHyperCubeMacroGenerator(number_of_macros=4)
        mg.add_set_value_LHS('Main.myvar1', normdist)
        mg.add_set_value_LHS('Main.myvar2', normdist)
        macros = mg.generate_macros()

        assert len(macros) == 4

        assert macros[0][
            0] == 'classoperation Main.myvar1 "Set Value" --value="{1,3,4}"'
        assert macros[0][
            1] == 'classoperation Main.myvar2 "Set Value" --value="{1,3,4}"'
        assert macros[1][
            0] == 'classoperation Main.myvar1 "Set Value" --value="{0.973478019766,2.64702266602,0.0441088571967}"'
        assert macros[1][
            1] == 'classoperation Main.myvar2 "Set Value" --value="{1.12273573036,2.17228489089,4.15538179788}"'
    def test_set_value_LHS(self):
        seed(1)
        normdist = norm( [1,3,4], [0.1,0.5,1] )
        mg = LatinHyperCubeMacroGenerator(number_of_macros=4)
        mg.add_set_value_LHS('Main.myvar1',normdist)
        mg.add_set_value_LHS('Main.myvar2', normdist)
        macros =  mg.generate_macros() 
        
        assert len(macros) == 4

        assert macros[0][0] == 'classoperation Main.myvar1 "Set Value" --value="{1,3,4}"'
        assert macros[0][1] == 'classoperation Main.myvar2 "Set Value" --value="{1,3,4}"'
        assert macros[1][0] == 'classoperation Main.myvar1 "Set Value" --value="{0.973478019766,2.64702266602,0.0441088571967}"'
        assert macros[1][1] == 'classoperation Main.myvar2 "Set Value" --value="{1.12273573036,2.17228489089,4.15538179788}"'
Esempio n. 3
0
    def test_set_value(self):
        mg = LatinHyperCubeMacroGenerator()
        mg.add_set_value('val0', 23.1)
        mg.add_set_value('val1', -0.123010929395)
        mg.add_set_value('val2', "hallo world")
        mg.add_set_value(['val3', 'val4'], [3.0, 4])
        mg.add_set_value('val5', np.array([1, 2, 3, 4]))
        mg.add_set_value('val6', np.array([[1, 0], [0, 1]]))
        macros = mg.generate_macros()

        assert len(macros) == 1

        assert macros[0][0] == 'classoperation val0 "Set Value" --value="23.1"'
        assert macros[0][
            1] == 'classoperation val1 "Set Value" --value="-0.123010929395"'
        assert macros[0][
            2] == 'classoperation val2 "Set Value" --value="hallo world"'
        assert macros[0][3] == 'classoperation val3 "Set Value" --value="3"'
        assert macros[0][4] == 'classoperation val4 "Set Value" --value="4"'
        assert macros[0][
            5] == 'classoperation val5 "Set Value" --value="{1,2,3,4}"'
        assert macros[0][
            6] == 'classoperation val6 "Set Value" --value="{{1,0},{0,1}}"'
Esempio n. 4
0
 def test_add_macro(self):
     mg = LatinHyperCubeMacroGenerator()
     mg.add_macro(['load "main.any"', 'operation Main.RunApplication'])
     macro = mg.generate_macros()
     assert macro[0] == ['load "main.any"', 'operation Main.RunApplication']
    def test_set_value(self):
        mg = LatinHyperCubeMacroGenerator()
        mg.add_set_value('val0', 23.1)
        mg.add_set_value('val1', -0.123010929395)
        mg.add_set_value('val2', "hallo world")
        mg.add_set_value(['val3','val4'], [3.0,4])
        mg.add_set_value('val5', np.array([1,2,3,4]) )
        mg.add_set_value('val6', np.array([[1,0],[0,1]]) )
        macros = mg.generate_macros()
        
        assert len(macros) == 1

        assert macros[0][0] == 'classoperation val0 "Set Value" --value="23.1"'
        assert macros[0][1] == 'classoperation val1 "Set Value" --value="-0.123010929395"'
        assert macros[0][2] == 'classoperation val2 "Set Value" --value="hallo world"'
        assert macros[0][3] == 'classoperation val3 "Set Value" --value="3"'
        assert macros[0][4] == 'classoperation val4 "Set Value" --value="4"'
        assert macros[0][5] == 'classoperation val5 "Set Value" --value="{1,2,3,4}"'
        assert macros[0][6] == 'classoperation val6 "Set Value" --value="{{1,0},{0,1}}"'
 def test_add_macro(self):
     mg = LatinHyperCubeMacroGenerator()
     mg.add_macro(['load "main.any"', 'operation Main.RunApplication'])
     macro = mg.generate_macros()
     assert macro[0] == ['load "main.any"', 'operation Main.RunApplication']