Repository: systemml
Updated Branches:
  refs/heads/master bc097fcd7 -> cf556f207


[SYSTEMML-1444] Additional tests for external UDFs in expressions

Closes #727.


Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/cf556f20
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/cf556f20
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/cf556f20

Branch: refs/heads/master
Commit: cf556f2070b81625c928a9540a9cd10e924df714
Parents: bc097fc
Author: Janardhan Pulivarthi <[email protected]>
Authored: Sun Mar 4 22:51:29 2018 -0800
Committer: Matthias Boehm <[email protected]>
Committed: Sun Mar 4 22:51:30 2018 -0800

----------------------------------------------------------------------
 .../misc/FunctionInExpressionTest.java          | 18 ++++++++--
 .../scripts/functions/misc/FunInExpression5.dml | 36 ++++++++++++++++++++
 .../scripts/functions/misc/FunInExpression6.dml | 30 ++++++++++++++++
 3 files changed, 82 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/cf556f20/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionInExpressionTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionInExpressionTest.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionInExpressionTest.java
index eefbf52..ad7aecc 100644
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionInExpressionTest.java
+++ 
b/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionInExpressionTest.java
@@ -32,7 +32,9 @@ public class FunctionInExpressionTest extends 
AutomatedTestBase
        private final static String TEST_NAME1 = "FunInExpression1"; 
        private final static String TEST_NAME2 = "FunInExpression2"; 
        private final static String TEST_NAME3 = "FunInExpression3"; 
-       private final static String TEST_NAME4 = "FunInExpression4"; 
+       private final static String TEST_NAME4 = "FunInExpression4";
+       private final static String TEST_NAME5 = "FunInExpression5";
+       private final static String TEST_NAME6 = "FunInExpression6";
        
        private final static String TEST_DIR = "functions/misc/";
        private final static String TEST_CLASS_DIR = TEST_DIR + 
FunctionInExpressionTest.class.getSimpleName() + "/";
@@ -44,6 +46,8 @@ public class FunctionInExpressionTest extends 
AutomatedTestBase
                addTestConfiguration( TEST_NAME2, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME2, new String[] { "R" }) );
                addTestConfiguration( TEST_NAME3, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME3, new String[] { "R" }) );
                addTestConfiguration( TEST_NAME4, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME4, new String[] { "R" }) );
+               addTestConfiguration( TEST_NAME5, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME5, new String[] { "R" }) );
+               addTestConfiguration( TEST_NAME6, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME6, new String[] { "R" }) );
        }
 
        @Test
@@ -65,6 +69,16 @@ public class FunctionInExpressionTest extends 
AutomatedTestBase
        public void testFunInExpression4() {
                runFunInExpressionTest( TEST_NAME4 );
        }
+
+       @Test
+       public void testFunInExpression5() {
+               runFunInExpressionTest( TEST_NAME5 );
+       }
+
+       @Test
+       public void testFunInExpression6() {
+               runFunInExpressionTest( TEST_NAME6 );
+       }
        
        private void runFunInExpressionTest( String testName )
        {
@@ -83,6 +97,6 @@ public class FunctionInExpressionTest extends 
AutomatedTestBase
                
                //compare results
                double val = readDMLMatrixFromHDFS("R").get(new CellIndex(1,1));
-               Assert.assertTrue("Wrong result: 7 vs "+val, 
Math.abs(val-7)<Math.pow(10, -14));
+               Assert.assertTrue("Wrong result: 7 vs "+val, 
Math.abs(val-7)<Math.pow(10, -13));
        }
 }

http://git-wip-us.apache.org/repos/asf/systemml/blob/cf556f20/src/test/scripts/functions/misc/FunInExpression5.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/misc/FunInExpression5.dml 
b/src/test/scripts/functions/misc/FunInExpression5.dml
new file mode 100644
index 0000000..567da6d
--- /dev/null
+++ b/src/test/scripts/functions/misc/FunInExpression5.dml
@@ -0,0 +1,36 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+
+orderExternal = externalFunction(Matrix[Double] A, Integer col, Boolean desc) 
return (Matrix[Double] B)
+                           implemented in 
(classname="org.apache.sysml.udf.lib.OrderWrapper",exectype="mem")
+
+foo = function( Matrix[Double] A ) return (Matrix[Double] B) {
+   for( i in 1:ncol(A) ) {
+      B = orderExternal(A, i, TRUE);
+   }
+}
+
+A = matrix( 0.07, rows=10, cols=10 );
+R = foo(A) * foo(A) + 7;
+R = as.matrix( sum( sqrt(R-7) ) );
+
+write( R, $1 ); #ordered input
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/systemml/blob/cf556f20/src/test/scripts/functions/misc/FunInExpression6.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/misc/FunInExpression6.dml 
b/src/test/scripts/functions/misc/FunInExpression6.dml
new file mode 100644
index 0000000..46f7bc0
--- /dev/null
+++ b/src/test/scripts/functions/misc/FunInExpression6.dml
@@ -0,0 +1,30 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+
+orderExternal = externalFunction(Matrix[Double] A, Integer col, Boolean desc) 
return (Matrix[Double] B)
+                           implemented in 
(classname="org.apache.sysml.udf.lib.OrderWrapper",exectype="mem")
+
+A = matrix( 0.07, rows=10, cols=10 );
+R = orderExternal(A*A, 7, TRUE) + 7;
+R = as.matrix( sum( sqrt(R-7) ) );
+
+write( R, $1 ); #ordered input
\ No newline at end of file

Reply via email to