Ejemplo n.º 1
0
 /**
  * Helper method to support running the main() method to run from Java instead of python
  *
  * @param jep
  */
 public void runFromJava(Jep jep) {
   try {
     jep.eval("import test_numpy");
     jep.eval("v = test_numpy.TestNumpy('testArgReturn')");
     jep.eval("v.setUp()");
     for (int i = 0; i < REPEAT; i++) {
       this.testSetAndGet(jep);
     }
     for (int i = 0; i < REPEAT; i++) {
       jep.eval("v.testArgReturn()");
     }
     System.out.println("return NDArray from Java checked out ok");
     for (int i = 0; i < REPEAT; i++) {
       jep.eval("v.testMultiDimensional()");
     }
     System.out.println("multi dimensional arrays checked out ok");
     for (int i = 0; i < REPEAT; i++) {
       jep.eval("v.testArrayParams()");
     }
     System.out.println("Passing ndarrays to Java method as Java primitive[] checked out ok");
   } catch (JepException e) {
     e.printStackTrace();
   } finally {
     if (jep != null) jep.close();
   }
 }
Ejemplo n.º 2
0
 /**
  * This main() is for running the tests from Java. If running from the tests from python, use
  * python setup.py test.
  *
  * @param args
  */
 public static void main(String[] args) {
   File pwd = new File("tests");
   TestNumpy test = null;
   Jep jep = null;
   try {
     test = new TestNumpy();
     jep = new Jep(false, pwd.getPath());
     test.runFromJava(jep);
     test.testNDArraySafety();
   } catch (JepException e) {
     e.printStackTrace();
   } finally {
     if (jep != null) {
       jep.close();
     }
   }
 }