X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.pythonlink%2Ftest%2Forg%2Fsimantics%2Fpythonlink%2Ftest%2Fscripts%2FPython.sts;h=83b221219291a2c81dea4dc1c4f6986b58b36f88;hb=15304b7c3168ef89c47dcfcfb4cf34c72000a75f;hp=50c0423ab0763d465e15c965070179d3773221b0;hpb=35382d886800c915bbdcfd595cf7b8401413377f;p=simantics%2Fpython.git diff --git a/org.simantics.pythonlink/test/org/simantics/pythonlink/test/scripts/Python.sts b/org.simantics.pythonlink/test/org/simantics/pythonlink/test/scripts/Python.sts index 50c0423..83b2212 100644 --- a/org.simantics.pythonlink/test/org/simantics/pythonlink/test/scripts/Python.sts +++ b/org.simantics.pythonlink/test/org/simantics/pythonlink/test/scripts/Python.sts @@ -5,6 +5,9 @@ > getPythonStringArrayVariable "d" vector ["__builtins__", "__doc__", "__loader__", "__name__", "__package__", "__spec__", "foo"] > runPython do +> getPythonStringVariable "__name__" +"SCL_2" +> runPython do > setPythonDoubleVariable "foo" 1 > executePythonStatement "foo = foo + 1" > getPythonDoubleVariable "foo" @@ -25,28 +28,21 @@ vector [1.0, 2.0, 3.0, 4.0] > executePythonStatement "foo.append(sum(foo))" > getPythonIntegerArrayVariable "foo" vector [1, 2, 3, 4, 10] -> ndarray (vector [1, 2, 3]) -ndarray(3) [1.0, 2.0, 3.0] -> ndarrayM 2 2 (vector [1, 2, 3, 4]) -ndarray(2x2) [[1.0, 2.0], [3.0, 4.0]] -> a = ndarrayN (vector [2, 2, 3]) (vector [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) -> a -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]]] -> ndarrayDims a -vector [2, 2, 3] -> ndarrayValues a -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] -> ndarrayElement a 5 -6.0 -> ndarrayElementN a (vector [0, 1, 2]) -6.0 -> runPython do -> setPythonNDArrayVariable "foo" (ndarrayM 2 3 (vector [1, 2, 3, 4, 5, 6])) -> executePythonStatement "bar = foo.cumsum(1)" -> getPythonNDArrayVariable "bar" -ndarray(2x3) [[1.0, 3.0, 6.0], [4.0, 9.0, 15.0]] +> runPython do +> setPythonBooleanVariable "foo" False +> executePythonStatement "foo = not(foo)" +> getPythonBooleanVariable "foo" +True > runPython do > setPythonVariable "foo" ([1.0, 2.0, 3.0, 4.0] :: [Double]) > executePythonStatement "foo.append(sum(foo))" > getPythonVariable "foo" :: [Double] [1.0, 2.0, 3.0, 4.0, 10.0] +> py = openPythonContext +> runWithPythonContext py $ setPythonIntegerVariable "foo" 4 +> runWithPythonContext py $ setPythonDoubleArrayVariable "bar" (vector [1.0, 2.0, 3.0]) +> runWithPythonContext py $ executePythonStatement "bar.append(float(foo))" +> bar = runWithPythonContext py $ getPythonDoubleArrayVariable "bar" +> closePythonContext py +> bar +vector [1.0, 2.0, 3.0, 4.0]