use of org.apache.sysml.api.mlcontext.MLResults in project incubator-systemml by apache.
the class MLContextTest method testOutputListStringCSVDenseDML.
@Test
public void testOutputListStringCSVDenseDML() {
System.out.println("MLContextTest - output List String CSV Dense DML");
String s = "M = matrix('1 2 3 4', rows=2, cols=2); print(toString(M));";
Script script = dml(s).out("M");
MLResults results = ml.execute(script);
MatrixObject mo = results.getMatrixObject("M");
List<String> lines = MLContextConversionUtil.matrixObjectToListStringCSV(mo);
Assert.assertEquals("1.0,2.0", lines.get(0));
Assert.assertEquals("3.0,4.0", lines.get(1));
}
use of org.apache.sysml.api.mlcontext.MLResults in project incubator-systemml by apache.
the class MLContextTest method testOutputJavaRDDStringIJVFromMatrixDML.
@Test
public void testOutputJavaRDDStringIJVFromMatrixDML() {
System.out.println("MLContextTest - output Java RDD String IJV from matrix DML");
String s = "M = matrix('1 2 3 4', rows=2, cols=2);";
Script script = dml(s).out("M");
MLResults results = ml.execute(script);
JavaRDD<String> javaRDDStringIJV = results.getJavaRDDStringIJV("M");
List<String> lines = javaRDDStringIJV.sortBy(row -> row, true, 1).collect();
Assert.assertEquals("1 1 1.0", lines.get(0));
Assert.assertEquals("1 2 2.0", lines.get(1));
Assert.assertEquals("2 1 3.0", lines.get(2));
Assert.assertEquals("2 2 4.0", lines.get(3));
}
use of org.apache.sysml.api.mlcontext.MLResults in project incubator-systemml by apache.
the class MLContextTest method testOutputJavaRDDStringIJVDML.
@Test
public void testOutputJavaRDDStringIJVDML() {
System.out.println("MLContextTest - output Java RDD String IJV DML");
String s = "M = matrix('1 2 3 4', rows=2, cols=2);";
Script script = dml(s).out("M");
MLResults results = ml.execute(script);
JavaRDD<String> javaRDDStringIJV = results.getJavaRDDStringIJV("M");
List<String> lines = javaRDDStringIJV.collect();
Assert.assertEquals("1 1 1.0", lines.get(0));
Assert.assertEquals("1 2 2.0", lines.get(1));
Assert.assertEquals("2 1 3.0", lines.get(2));
Assert.assertEquals("2 2 4.0", lines.get(3));
}
use of org.apache.sysml.api.mlcontext.MLResults in project incubator-systemml by apache.
the class MLContextTest method testOutputListStringIJVDensePYDML.
@Test
public void testOutputListStringIJVDensePYDML() {
System.out.println("MLContextTest - output List String IJV Dense PYDML");
String s = "M = full('1 2 3 4', rows=2, cols=2)\nprint(toString(M))";
Script script = pydml(s).out("M");
MLResults results = ml.execute(script);
MatrixObject mo = results.getMatrixObject("M");
List<String> lines = MLContextConversionUtil.matrixObjectToListStringIJV(mo);
Assert.assertEquals("1 1 1.0", lines.get(0));
Assert.assertEquals("1 2 2.0", lines.get(1));
Assert.assertEquals("2 1 3.0", lines.get(2));
Assert.assertEquals("2 2 4.0", lines.get(3));
}
use of org.apache.sysml.api.mlcontext.MLResults in project incubator-systemml by apache.
the class MLContextTest method testOutputScalaSeqPYDML.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testOutputScalaSeqPYDML() {
System.out.println("MLContextTest - output specified as Scala Seq PYDML");
List outputs = Arrays.asList("x", "y");
Seq seq = JavaConversions.asScalaBuffer(outputs).toSeq();
Script script = pydml("a=1\nx=a+1\ny=x+1").out(seq);
MLResults results = ml.execute(script);
Assert.assertEquals(2, results.getLong("x"));
Assert.assertEquals(3, results.getLong("y"));
}
Aggregations