]> gerrit.simantics Code Review - simantics/python.git/blob - org.simantics.pythonlink/test/org/simantics/pythonlink/test/scripts/Variant.sts
745b3c3aea056a3a7b28aac64df5b3a15bd131c4
[simantics/python.git] / org.simantics.pythonlink / test / org / simantics / pythonlink / test / scripts / Variant.sts
1 > import "Python"\r
2 > a = variant ([1.0, 2.0, 3.0])\r
3 > b = runPython do\r
4 >     setPythonVariantVariable "foo" a\r
5 >     executePythonStatement "foo.append(4.0)"\r
6 >     getPythonVariantVariable "foo"\r
7 > b\r
8 [1.0 : Double, 2.0 : Double, 3.0 : Double, 4.0 : Double] : Variant[]\r
9 > variantValue b :: [Double]\r
10 [1.0, 2.0, 3.0, 4.0]\r
11 > import "MMap" as MMap\r
12 > runPython do\r
13 >     foo = MMap.create () :: MMap.T String Dynamic\r
14 >     MMap.put foo "c1" (toDynamic (vector [True, True, False, True]))\r
15 >     MMap.put foo "c2" (toDynamic ["foo", "bar", "baz"])\r
16 >     MMap.put foo "c3" (toDynamic 25.0)\r
17 >     setPythonVariantVariable "foo" (variant foo)\r
18 >     executePythonStatement "c1 = foo['c1']"\r
19 >     executePythonStatement "c2 = foo['c2']"\r
20 >     executePythonStatement "c3 = foo['c3']"\r
21 >     (getPythonBooleanArrayVariable "c1", getPythonStringArrayVariable "c2", getPythonDoubleVariable "c3")\r
22 (vector [True, True, False, True], vector ["foo", "bar", "baz"], 25.0)\r