use of org.apache.sysml.api.mlcontext.Script in project incubator-systemml by apache.
the class MLContextTest method testCreatePYDMLScriptBasedOnStringAndExecute.
@Test
public void testCreatePYDMLScriptBasedOnStringAndExecute() {
System.out.println("MLContextTest - create PYDML script based on string and execute");
String testString = "Create PYDML script based on string and execute";
setExpectedStdOut(testString);
Script script = pydml("print('" + testString + "')");
ml.execute(script);
}
use of org.apache.sysml.api.mlcontext.Script in project incubator-systemml by apache.
the class MLContextTest method testOutputListStringIJVSparsePYDML.
@Test
public void testOutputListStringIJVSparsePYDML() {
System.out.println("MLContextTest - output List String IJV Sparse PYDML");
String s = "M = full(0, rows=10, cols=10)\nM[0,0]=1\nM[0,1]=2\nM[1,0]=3\nM[1,1]=4\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.Script in project incubator-systemml by apache.
the class MLContextTest method testCreateDMLScriptBasedOnURL.
@Test
public void testCreateDMLScriptBasedOnURL() throws MalformedURLException {
System.out.println("MLContextTest - create DML script based on URL");
String urlString = "https://raw.githubusercontent.com/apache/systemml/master/src/test/scripts/applications/hits/HITS.dml";
URL url = new URL(urlString);
Script script = dmlFromUrl(url);
String expectedContent = "Licensed to the Apache Software Foundation";
String s = script.getScriptString();
assertTrue("Script string doesn't contain expected content: " + expectedContent, s.contains(expectedContent));
}
use of org.apache.sysml.api.mlcontext.Script in project incubator-systemml by apache.
the class MLContextTest method testPrintFormattingBooleanSubstitution.
@Test
public void testPrintFormattingBooleanSubstitution() {
System.out.println("MLContextTest - print formatting boolean substitution");
Script script = dml("print('boolean %b', TRUE);");
setExpectedStdOut("boolean true");
ml.execute(script);
}
use of org.apache.sysml.api.mlcontext.Script in project incubator-systemml by apache.
the class MLContextTest method testOutputJavaRDDStringCSVSparsePYDML.
/**
* Reading from dense and sparse matrices is handled differently, so we have
* tests for both dense and sparse matrices.
*/
@Test
public void testOutputJavaRDDStringCSVSparsePYDML() {
System.out.println("MLContextTest - output Java RDD String CSV Sparse PYDML");
String s = "M = full(0, rows=10, cols=10)\nM[0,0]=1\nM[0,1]=2\nM[1,0]=3\nM[1,1]=4\nprint(toString(M))";
Script script = pydml(s).out("M");
MLResults results = ml.execute(script);
JavaRDD<String> javaRDDStringCSV = results.getJavaRDDStringCSV("M");
List<String> lines = javaRDDStringCSV.collect();
Assert.assertEquals("1.0,2.0", lines.get(0));
Assert.assertEquals("3.0,4.0", lines.get(1));
}
Aggregations