]> gerrit.simantics Code Review - simantics/python.git/blobdiff - org.simantics.pythonlink/test/org/simantics/pythonlink/test/scripts/Python.sts
Added support for dynamically typed data access and a Variable interface.
[simantics/python.git] / org.simantics.pythonlink / test / org / simantics / pythonlink / test / scripts / Python.sts
index 50c0423ab0763d465e15c965070179d3773221b0..83b221219291a2c81dea4dc1c4f6986b58b36f88 100644 (file)
@@ -5,6 +5,9 @@
 >     getPythonStringArrayVariable "d"\r
 vector ["__builtins__", "__doc__", "__loader__", "__name__", "__package__", "__spec__", "foo"]\r
 > runPython do\r
+>     getPythonStringVariable "__name__"\r
+"SCL_2"\r
+> runPython do\r
 >     setPythonDoubleVariable "foo" 1\r
 >     executePythonStatement "foo = foo + 1"\r
 >     getPythonDoubleVariable "foo"\r
@@ -25,28 +28,21 @@ vector [1.0, 2.0, 3.0, 4.0]
 >     executePythonStatement "foo.append(sum(foo))"\r
 >     getPythonIntegerArrayVariable "foo"\r
 vector [1, 2, 3, 4, 10]\r
-> ndarray (vector [1, 2, 3])\r
-ndarray(3) [1.0, 2.0, 3.0]\r
-> ndarrayM 2 2 (vector [1, 2, 3, 4])\r
-ndarray(2x2) [[1.0, 2.0], [3.0, 4.0]]\r
-> a = ndarrayN (vector [2, 2, 3]) (vector [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])\r
-> a\r
-ndarray(2x2x3) [[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]]]\r
-> ndarrayDims a\r
-vector [2, 2, 3]\r
-> ndarrayValues a\r
-vector [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]\r
-> ndarrayElement a 5\r
-6.0\r
-> ndarrayElementN a (vector [0, 1, 2])\r
-6.0\r
-> runPython do\r
->     setPythonNDArrayVariable "foo" (ndarrayM 2 3 (vector [1, 2, 3,  4, 5, 6]))\r
->     executePythonStatement "bar = foo.cumsum(1)"\r
->     getPythonNDArrayVariable "bar"\r
-ndarray(2x3) [[1.0, 3.0, 6.0], [4.0, 9.0, 15.0]]\r
+> runPython do\r
+>     setPythonBooleanVariable "foo" False\r
+>     executePythonStatement "foo = not(foo)"\r
+>     getPythonBooleanVariable "foo"\r
+True\r
 > runPython do\r
 >     setPythonVariable "foo" ([1.0, 2.0, 3.0, 4.0] :: [Double])\r
 >     executePythonStatement "foo.append(sum(foo))"\r
 >     getPythonVariable "foo" :: [Double]\r
 [1.0, 2.0, 3.0, 4.0, 10.0]\r
+> py = openPythonContext\r
+> runWithPythonContext py $ setPythonIntegerVariable "foo" 4\r
+> runWithPythonContext py $ setPythonDoubleArrayVariable "bar" (vector [1.0, 2.0, 3.0])\r
+> runWithPythonContext py $ executePythonStatement "bar.append(float(foo))"\r
+> bar = runWithPythonContext py $ getPythonDoubleArrayVariable "bar"\r
+> closePythonContext py\r
+> bar\r
+vector [1.0, 2.0, 3.0, 4.0]\r