Search in sources :

Example 26 with Connection

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

the class JMLCInputOutputTest method testScalarInputBoolean.

@Test
public void testScalarInputBoolean() 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);
    boolean inScalar1 = true;
    boolean inScalar2 = true;
    script.setScalar("inScalar1", inScalar1);
    script.setScalar("inScalar2", inScalar2);
    setExpectedStdOut("total:2.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)

Example 27 with Connection

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

the class JMLCInputOutputTest method testScalarOutputLong.

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

Example 28 with Connection

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

the class JMLCInputOutputTest method testScalarOutputString.

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

Example 29 with Connection

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

Example 30 with Connection

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

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