Search in sources :

Example 66 with Connection

use of org.apache.sysml.api.jmlc.Connection in project systemml by apache.

the class JMLCInputOutputTest method testScalarInputInt.

@Test
public void testScalarInputInt() 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);
    int inScalar1 = 2;
    int inScalar2 = 3;
    script.setScalar("inScalar1", inScalar1);
    script.setScalar("inScalar2", inScalar2);
    setExpectedStdOut("total:5");
    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 67 with Connection

use of org.apache.sysml.api.jmlc.Connection in project systemml by apache.

the class JMLCInputOutputTest method testScalarOutputBoolean.

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

Example 68 with Connection

use of org.apache.sysml.api.jmlc.Connection in project 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 69 with Connection

use of org.apache.sysml.api.jmlc.Connection in project 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 70 with Connection

use of org.apache.sysml.api.jmlc.Connection in project systemml by apache.

the class JMLCInputOutputTest method testScalarInputStringExplicitValueType.

@Test
public void testScalarInputStringExplicitValueType() throws IOException, DMLException {
    Connection conn = new Connection();
    String str = conn.readScript(baseDirectory + File.separator + "scalar-input-string.dml");
    PreparedScript script = conn.prepareScript(str, new String[] { "inScalar1", "inScalar2" }, new String[] {}, false);
    String inScalar1 = "hello";
    String inScalar2 = "goodbye";
    script.setScalar("inScalar1", inScalar1);
    script.setScalar("inScalar2", inScalar2);
    setExpectedStdOut("result:hellogoodbye");
    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)75 PreparedScript (org.apache.sysml.api.jmlc.PreparedScript)73 Test (org.junit.Test)28 ResultVariables (org.apache.sysml.api.jmlc.ResultVariables)27 IOException (java.io.IOException)25 HashMap (java.util.HashMap)22 ArrayList (java.util.ArrayList)19 Timing (org.apache.sysml.runtime.controlprogram.parfor.stat.Timing)17 FrameBlock (org.apache.sysml.runtime.matrix.data.FrameBlock)4 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)4 TestConfiguration (org.apache.sysml.test.integration.TestConfiguration)4 DMLException (org.apache.sysml.api.DMLException)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 ExecutorService (java.util.concurrent.ExecutorService)2 Future (java.util.concurrent.Future)2 SparkConf (org.apache.spark.SparkConf)2 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)2 DMLScript (org.apache.sysml.api.DMLScript)2 MLContext (org.apache.sysml.api.mlcontext.MLContext)2