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

  1. # testje.tcl --
  2. # Simple test to see if it works ...
  3. #
  4. set auto_path [concat . $auto_path]
  5. package require tclpy
  6.  
  7. py eval {import numpy as np}
  8. py eval {def xx(x,y): return x+y}
  9. puts [py call xx string1 string2]
  10.  
  11. set a [list 4 2 3]
  12. puts [py eval "a = np.array(\[[join $a ,]\])"]
  13. py eval {def sort(a): return np.sort(a)}
  14. puts [py eval print(np.sort(a))]
  15. #puts [py call np.sort a.array]
  16. puts 1
  17. #py eval {def b(): global a; return a.tolist()}
  18. py eval {def b(array): aa = globals().get(array); return aa.tolist()}
  19. puts 2
  20. puts [py call b a]
  21. #puts [py call b z]
  22.  
  23. set a {[[4,2,3],[1,2,3]]}
  24. py eval "z = np.array($a)"
  25. puts [py call b z]

Comments

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

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