Posted to tcl by arjen at Fri Oct 16 11:46:13 GMT 2020view pretty

# testje.tcl --
#     Simple test to see if it works ...
set auto_path [concat . $auto_path]
package require tclpy

py eval {import numpy as np}
py eval {def xx(x,y): return x+y}
puts [py call xx string1 string2]

set a [list 4 2 3]
puts [py eval "a = np.array(\[[join $a ,]\])"]
py eval {def sort(a): return np.sort(a)}
puts [py eval print(np.sort(a))]
#puts [py call np.sort a.array]
puts 1
#py eval {def b(): global a; return a.tolist()}
py eval {def b(array): aa = globals().get(array); return aa.tolist()}
puts 2
puts [py call b a]
#puts [py call b z]

set a {[[4,2,3],[1,2,3]]}
py eval "z = np.array($a)"
puts [py call b z]


Posted by dbohdan at Fri Oct 16 12:30:32 GMT 2020 [text] [code]

Don't mind this comment. It is only a test.