Search in sources :

Example 11 with PreparedScript

use of org.apache.sysml.api.jmlc.PreparedScript in project incubator-systemml by apache.

the class JMLCInputOutputTest method testScalarInputLong.

@Test
public void testScalarInputLong() throws IOException, DMLException {
    Connection conn = new Connection();
    String str = conn.readScript(baseDirectory + File.separator + "scalar-input.dml");
    PreparedScript script = conn.prepareScript(str, new String[] { "inScalar1", "inScalar2" }, new String[] {}, false);
    long inScalar1 = 4;
    long inScalar2 = 5;
    script.setScalar("inScalar1", inScalar1);
    script.setScalar("inScalar2", inScalar2);
    setExpectedStdOut("total:9");
    script.executeScript();
    conn.close();
}
Also used : PreparedScript(org.apache.sysml.api.jmlc.PreparedScript) Connection(org.apache.sysml.api.jmlc.Connection) Test(org.junit.Test)

Example 12 with PreparedScript

use of org.apache.sysml.api.jmlc.PreparedScript in project incubator-systemml by apache.

the class JMLCInputOutputTest method testScalarOutputDouble.

@Test
public void testScalarOutputDouble() throws DMLException {
    Connection conn = new Connection();
    String str = "outDouble = 1.23;\nwrite(outDouble, './tmp/outDouble');";
    PreparedScript script = conn.prepareScript(str, new String[] {}, new String[] { "outDouble" }, false);
    double result = script.executeScript().getDouble("outDouble");
    Assert.assertEquals(1.23, result, 0);
    conn.close();
}
Also used : PreparedScript(org.apache.sysml.api.jmlc.PreparedScript) Connection(org.apache.sysml.api.jmlc.Connection) Test(org.junit.Test)

Example 13 with PreparedScript

use of org.apache.sysml.api.jmlc.PreparedScript in project incubator-systemml by apache.

the class JMLCInputOutputTest method testScalarOutputScalarObject.

@Test
public void testScalarOutputScalarObject() throws DMLException {
    Connection conn = new Connection();
    String str = "outDouble = 1.23;\nwrite(outDouble, './tmp/outDouble');";
    PreparedScript script = conn.prepareScript(str, new String[] {}, new String[] { "outDouble" }, false);
    ScalarObject so = script.executeScript().getScalarObject("outDouble");
    double result = so.getDoubleValue();
    Assert.assertEquals(1.23, result, 0);
    conn.close();
}
Also used : ScalarObject(org.apache.sysml.runtime.instructions.cp.ScalarObject) PreparedScript(org.apache.sysml.api.jmlc.PreparedScript) Connection(org.apache.sysml.api.jmlc.Connection) Test(org.junit.Test)

Example 14 with PreparedScript

use of org.apache.sysml.api.jmlc.PreparedScript in project incubator-systemml by apache.

the class JMLCInputOutputTest method testScalarInputString.

@Test
public void testScalarInputString() throws IOException, DMLException {
    Connection conn = new Connection();
    String str = conn.readScript(baseDirectory + File.separator + "scalar-input.dml");
    PreparedScript script = conn.prepareScript(str, new String[] { "inScalar1", "inScalar2" }, new String[] {}, false);
    String inScalar1 = "Plant";
    String inScalar2 = " Trees";
    script.setScalar("inScalar1", inScalar1);
    script.setScalar("inScalar2", inScalar2);
    setExpectedStdOut("total:Plant Trees");
    script.executeScript();
    conn.close();
}
Also used : PreparedScript(org.apache.sysml.api.jmlc.PreparedScript) Connection(org.apache.sysml.api.jmlc.Connection) Test(org.junit.Test)

Example 15 with PreparedScript

use of org.apache.sysml.api.jmlc.PreparedScript in project incubator-systemml by apache.

the class JMLCInputOutputTest method testScalarInputDouble.

@Test
public void testScalarInputDouble() throws IOException, DMLException {
    Connection conn = new Connection();
    String str = conn.readScript(baseDirectory + File.separator + "scalar-input.dml");
    PreparedScript script = conn.prepareScript(str, new String[] { "inScalar1", "inScalar2" }, new String[] {}, false);
    double inScalar1 = 3.5;
    double inScalar2 = 4.5;
    script.setScalar("inScalar1", inScalar1);
    script.setScalar("inScalar2", inScalar2);
    setExpectedStdOut("total:8.0");
    script.executeScript();
    conn.close();
}
Also used : PreparedScript(org.apache.sysml.api.jmlc.PreparedScript) Connection(org.apache.sysml.api.jmlc.Connection) Test(org.junit.Test)

Aggregations

Connection (org.apache.sysml.api.jmlc.Connection)37 PreparedScript (org.apache.sysml.api.jmlc.PreparedScript)37 ResultVariables (org.apache.sysml.api.jmlc.ResultVariables)14 Test (org.junit.Test)14 IOException (java.io.IOException)12 HashMap (java.util.HashMap)11 ArrayList (java.util.ArrayList)10 Timing (org.apache.sysml.runtime.controlprogram.parfor.stat.Timing)9 DMLException (org.apache.sysml.api.DMLException)2 File (java.io.File)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 SparkConf (org.apache.spark.SparkConf)1 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)1 DMLScript (org.apache.sysml.api.DMLScript)1 MLContext (org.apache.sysml.api.mlcontext.MLContext)1 Script (org.apache.sysml.api.mlcontext.Script)1 ScalarObject (org.apache.sysml.runtime.instructions.cp.ScalarObject)1 FrameBlock (org.apache.sysml.runtime.matrix.data.FrameBlock)1 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)1