1 > import "Simantics/Python"
\r
5 > executePythonStatement "foo = 'bar'\nd = dir()"
\r
6 > getPythonStringArrayVariable "d"
\r
7 vector ["__builtins__", "__doc__", "__loader__", "__name__", "__package__", "__spec__", "foo"]
\r
9 > setPythonDoubleVariable "foo" 1
\r
10 > executePythonStatement "foo = foo + 1"
\r
11 > getPythonDoubleVariable "foo"
\r
14 > setPythonDoubleArrayVariable "foo" (vector [1.0, 2.0, 3.0])
\r
15 > executePythonStatement "foo = foo + [4.0]"
\r
16 > getPythonDoubleArrayVariable "foo"
\r
17 vector [1.0, 2.0, 3.0, 4.0]
\r
19 > setPythonIntegerVariable "foo" 5
\r
20 > executePythonStatement "import math"
\r
21 > executePythonStatement "bar = math.factorial(foo)"
\r
22 > getPythonIntegerVariable "bar"
\r
25 > setPythonIntegerArrayVariable "foo" (vector [1, 2, 3, 4])
\r
26 > executePythonStatement "foo.append(sum(foo))"
\r
27 > getPythonIntegerArrayVariable "foo"
\r
28 vector [1, 2, 3, 4, 10]
\r
29 > ndarray (vector [1, 2, 3])
\r
30 ndarray(3) [1.0, 2.0, 3.0]
\r
31 > ndarrayM 2 2 (vector [1, 2, 3, 4])
\r
32 ndarray(2x2) [[1.0, 2.0], [3.0, 4.0]]
\r
33 > a = ndarrayN (vector [2, 2, 3]) (vector [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
\r
35 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
39 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
40 > ndarrayElement a 5
\r
42 > ndarrayElementN a (vector [0, 1, 2])
\r
45 > setPythonNDArrayVariable "foo" (ndarrayM 2 3 (vector [1, 2, 3, 4, 5, 6]))
\r
46 > executePythonStatement "bar = foo.cumsum(1)"
\r
47 > getPythonNDArrayVariable "bar"
\r
48 ndarray(2x3) [[1.0, 3.0, 6.0], [4.0, 9.0, 15.0]]
\r