[SYSTEMML-1799] Remove ppred from test scripts Replace ppred functions with relational operators in test scripts since ppred() is deprecated. Rename ppred test class names and script names.
Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/d30e1888 Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/d30e1888 Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/d30e1888 Branch: refs/heads/master Commit: d30e188807af767df7ca46c2980c0f7110ad912d Parents: 11b689d Author: Deron Eriksson <de...@apache.org> Authored: Mon Jul 24 11:34:31 2017 -0700 Committer: Deron Eriksson <de...@apache.org> Committed: Mon Jul 24 15:07:55 2017 -0700 ---------------------------------------------------------------------- .../FullLogicalMatrixTest.java | 590 +++++++++++++++++++ .../FullLogicalScalarLeftTest.java | 437 ++++++++++++++ .../FullLogicalScalarRightTest.java | 436 ++++++++++++++ .../matrix_full_other/FullPPredMatrixTest.java | 590 ------------------- .../FullPPredScalarLeftTest.java | 437 -------------- .../FullPPredScalarRightTest.java | 436 -------------- .../ternary/CTableMatrixIgnoreZerosTest.java | 2 +- .../apply-transform/apply-transform.dml | 4 +- .../apply-transform/apply-transform.pydml | 4 +- .../applications/arima_box-jenkins/arima.dml | 2 +- .../applications/arima_box-jenkins/arima.pydml | 2 +- .../scripts/applications/cspline/CsplineCG.dml | 2 +- .../applications/cspline/CsplineCG.pydml | 2 +- .../scripts/applications/cspline/CsplineDS.dml | 2 +- .../applications/cspline/CsplineDS.pydml | 2 +- .../applications/ctableStats/Binomial.dml | 18 +- .../applications/ctableStats/ctci_odds.dml | 2 +- .../applications/ctableStats/zipftest.dml | 2 +- .../descriptivestats/Categorical.dml | 4 +- .../applications/descriptivestats/Scale.R | 1 - .../applications/descriptivestats/Scale.dml | 5 +- .../WeightedCategoricalTest.dml | 4 +- .../descriptivestats/WeightedScaleTest.R | 1 - .../descriptivestats/WeightedScaleTest.dml | 5 +- src/test/scripts/applications/glm/GLM.dml | 86 +-- src/test/scripts/applications/glm/GLM.pydml | 86 +-- src/test/scripts/applications/id3/id3.dml | 14 +- src/test/scripts/applications/id3/id3.pydml | 14 +- src/test/scripts/applications/impute/tmp.dml | 8 +- src/test/scripts/applications/kmeans/Kmeans.dml | 4 +- src/test/scripts/applications/l2svm/L2SVM.dml | 8 +- src/test/scripts/applications/l2svm/L2SVM.pydml | 8 +- .../applications/linearLogReg/LinearLogReg.dml | 2 +- .../linearLogReg/LinearLogReg.pydml | 2 +- src/test/scripts/applications/m-svm/m-svm.dml | 8 +- src/test/scripts/applications/m-svm/m-svm.pydml | 8 +- .../applications/mdabivar/MDABivariateStats.dml | 4 +- .../mdabivar/MDABivariateStats.pydml | 4 +- .../naive-bayes-parfor/naive-bayes.dml | 2 +- .../naive-bayes-parfor/naive-bayes.pydml | 2 +- .../parfor/parfor_cv_multiclasssvm0.dml | 22 +- .../parfor/parfor_cv_multiclasssvm1.dml | 22 +- .../parfor/parfor_cv_multiclasssvm4.dml | 22 +- .../applications/parfor/parfor_sample.dml | 4 +- .../applications/parfor/parfor_univariate0.dml | 2 +- .../applications/parfor/parfor_univariate1.dml | 2 +- .../applications/parfor/parfor_univariate4.dml | 2 +- .../validation/CV_LogisticRegression.dml | 10 +- .../validation/CV_MultiClassSVM.dml | 22 +- .../validation/CV_MultiClassSVM.sasha.dml | 24 +- .../validation/LinearLogisticRegression.dml | 2 +- .../applications/validation/MultiClassSVM.dml | 16 +- .../validation/MultiClassSVMScore.dml | 2 +- .../genRandData4LogisticRegression.dml | 2 +- .../validation/genRandData4MultiClassSVM.dml | 2 +- .../matrix/UltraSparseMatrixMultiplication.dml | 2 +- .../matrix/UltraSparseMatrixMultiplication2.dml | 2 +- .../matrix_full_other/LogicalMatrixTest.R | 59 ++ .../matrix_full_other/LogicalMatrixTest.dml | 50 ++ .../matrix_full_other/LogicalScalarLeftTest.R | 60 ++ .../matrix_full_other/LogicalScalarLeftTest.dml | 49 ++ .../matrix_full_other/LogicalScalarRightTest.R | 60 ++ .../LogicalScalarRightTest.dml | 49 ++ .../binary/matrix_full_other/PPredMatrixTest.R | 59 -- .../matrix_full_other/PPredMatrixTest.dml | 50 -- .../matrix_full_other/PPredScalarLeftTest.R | 60 -- .../matrix_full_other/PPredScalarLeftTest.dml | 49 -- .../matrix_full_other/PPredScalarRightTest.R | 60 -- .../matrix_full_other/PPredScalarRightTest.dml | 49 -- .../functions/misc/ValueTypePredLeftScalar.dml | 2 +- .../functions/misc/ValueTypePredRightScalar.dml | 2 +- .../quaternary/WeightedDivMMMultMinusLeft.dml | 2 +- .../quaternary/WeightedDivMMMultMinusRight.dml | 2 +- .../quaternary/WeightedSquaredLossPostNz.dml | 2 +- .../scripts/functions/ternary/CTableRowHist.dml | 2 +- .../scripts/functions/unary/matrix/SelPos.dml | 2 +- .../scripts/functions/unary/matrix/Sign2.dml | 2 +- .../binary/matrix_full_other/ZPackageSuite.java | 6 +- 78 files changed, 2041 insertions(+), 2045 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalMatrixTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalMatrixTest.java b/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalMatrixTest.java new file mode 100644 index 0000000..9563283 --- /dev/null +++ b/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalMatrixTest.java @@ -0,0 +1,590 @@ +/* + * 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. + */ + +package org.apache.sysml.test.integration.functions.binary.matrix_full_other; + +import java.util.HashMap; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.apache.sysml.api.DMLScript; +import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM; +import org.apache.sysml.lops.LopProperties.ExecType; +import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex; +import org.apache.sysml.test.integration.AutomatedTestBase; +import org.apache.sysml.test.integration.TestConfiguration; +import org.apache.sysml.test.utils.TestUtils; + +/** + * The main purpose of this test is to verify various input combinations for + * matrix-matrix ppred operations that internally translate to binary operations. + * + */ +public class FullLogicalMatrixTest extends AutomatedTestBase +{ + + private final static String TEST_NAME1 = "LogicalMatrixTest"; + private final static String TEST_DIR = "functions/binary/matrix_full_other/"; + private final static String TEST_CLASS_DIR = TEST_DIR + FullLogicalMatrixTest.class.getSimpleName() + "/"; + private final static double eps = 1e-10; + + private final static int rows1 = 1383; + private final static int cols1 = 1432; + + private final static double sparsity1 = 0.7; + private final static double sparsity2 = 0.01; + + public enum Type{ + GREATER, + LESS, + EQUALS, + NOT_EQUALS, + GREATER_EQUALS, + LESS_EQUALS, + } + + @Override + public void setUp() + { + addTestConfiguration( TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "C" }) ); + TestUtils.clearAssertionInformation(); + if (TEST_CACHE_ENABLED) { + setOutAndExpectedDeletionDisabled(true); + } + } + + @BeforeClass + public static void init() + { + TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); + } + + @AfterClass + public static void cleanUp() + { + if (TEST_CACHE_ENABLED) { + TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); + } + } + + @Test + public void testPPredGreaterDenseDenseCP() + { + runPPredTest(Type.GREATER, false, false, ExecType.CP); + } + + @Test + public void testPPredGreaterDenseSparseCP() + { + runPPredTest(Type.GREATER, false, true, ExecType.CP); + } + + @Test + public void testPPredGreaterSparseDenseCP() + { + runPPredTest(Type.GREATER, true, false, ExecType.CP); + } + + @Test + public void testPPredGreaterSparseSparseCP() + { + runPPredTest(Type.GREATER, true, true, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsDenseDenseCP() + { + runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsDenseSparseCP() + { + runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsSparseDenseCP() + { + runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsSparseSparseCP() + { + runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredEqualsDenseDenseCP() + { + runPPredTest(Type.EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredEqualsDenseSparseCP() + { + runPPredTest(Type.EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredEqualsSparseDenseCP() + { + runPPredTest(Type.EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredEqualsSparseSparseCP() + { + runPPredTest(Type.EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredNotEqualsDenseDenseCP() + { + runPPredTest(Type.NOT_EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredNotEqualsDenseSparseCP() + { + runPPredTest(Type.NOT_EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredNotEqualsSparseDenseCP() + { + runPPredTest(Type.NOT_EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredNotEqualsSparseSparseCP() + { + runPPredTest(Type.NOT_EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredLessDenseDenseCP() + { + runPPredTest(Type.LESS, false, false, ExecType.CP); + } + + @Test + public void testPPredLessDenseSparseCP() + { + runPPredTest(Type.LESS, false, true, ExecType.CP); + } + + @Test + public void testPPredLessSparseDenseCP() + { + runPPredTest(Type.LESS, true, false, ExecType.CP); + } + + @Test + public void testPPredLessSparseSparseCP() + { + runPPredTest(Type.LESS, true, true, ExecType.CP); + } + + @Test + public void testPPredLessEqualsDenseDenseCP() + { + runPPredTest(Type.LESS_EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredLessEqualsDenseSparseCP() + { + runPPredTest(Type.LESS_EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredLessEqualsSparseDenseCP() + { + runPPredTest(Type.LESS_EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredLessEqualsSparseSparseCP() + { + runPPredTest(Type.LESS_EQUALS, true, true, ExecType.CP); + } + + + // ------------------------ + @Test + public void testPPredGreaterDenseDenseSP() + { + runPPredTest(Type.GREATER, false, false, ExecType.SPARK); + } + + @Test + public void testPPredGreaterDenseSparseSP() + { + runPPredTest(Type.GREATER, false, true, ExecType.SPARK); + } + + @Test + public void testPPredGreaterSparseDenseSP() + { + runPPredTest(Type.GREATER, true, false, ExecType.SPARK); + } + + @Test + public void testPPredGreaterSparseSparseSP() + { + runPPredTest(Type.GREATER, true, true, ExecType.SPARK); + } + + @Test + public void testPPredGreaterEqualsDenseDenseSP() + { + runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.SPARK); + } + + @Test + public void testPPredGreaterEqualsDenseSparseSP() + { + runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.SPARK); + } + + @Test + public void testPPredGreaterEqualsSparseDenseSP() + { + runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.SPARK); + } + + @Test + public void testPPredGreaterEqualsSparseSparseSP() + { + runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.SPARK); + } + + @Test + public void testPPredEqualsDenseDenseSP() + { + runPPredTest(Type.EQUALS, false, false, ExecType.SPARK); + } + + @Test + public void testPPredEqualsDenseSparseSP() + { + runPPredTest(Type.EQUALS, false, true, ExecType.SPARK); + } + + @Test + public void testPPredEqualsSparseDenseSP() + { + runPPredTest(Type.EQUALS, true, false, ExecType.SPARK); + } + + @Test + public void testPPredEqualsSparseSparseSP() + { + runPPredTest(Type.EQUALS, true, true, ExecType.SPARK); + } + + @Test + public void testPPredNotEqualsDenseDenseSP() + { + runPPredTest(Type.NOT_EQUALS, false, false, ExecType.SPARK); + } + + @Test + public void testPPredNotEqualsDenseSparseSP() + { + runPPredTest(Type.NOT_EQUALS, false, true, ExecType.SPARK); + } + + @Test + public void testPPredNotEqualsSparseDenseSP() + { + runPPredTest(Type.NOT_EQUALS, true, false, ExecType.SPARK); + } + + @Test + public void testPPredNotEqualsSparseSparseSP() + { + runPPredTest(Type.NOT_EQUALS, true, true, ExecType.SPARK); + } + + @Test + public void testPPredLessDenseDenseSP() + { + runPPredTest(Type.LESS, false, false, ExecType.SPARK); + } + + @Test + public void testPPredLessDenseSparseSP() + { + runPPredTest(Type.LESS, false, true, ExecType.SPARK); + } + + @Test + public void testPPredLessSparseDenseSP() + { + runPPredTest(Type.LESS, true, false, ExecType.SPARK); + } + + @Test + public void testPPredLessSparseSparseSP() + { + runPPredTest(Type.LESS, true, true, ExecType.SPARK); + } + + @Test + public void testPPredLessEqualsDenseDenseSP() + { + runPPredTest(Type.LESS_EQUALS, false, false, ExecType.SPARK); + } + + @Test + public void testPPredLessEqualsDenseSparseSP() + { + runPPredTest(Type.LESS_EQUALS, false, true, ExecType.SPARK); + } + + @Test + public void testPPredLessEqualsSparseDenseSP() + { + runPPredTest(Type.LESS_EQUALS, true, false, ExecType.SPARK); + } + + @Test + public void testPPredLessEqualsSparseSparseSP() + { + runPPredTest(Type.LESS_EQUALS, true, true, ExecType.SPARK); + } + // ---------------------- + + @Test + public void testPPredGreaterDenseDenseMR() + { + runPPredTest(Type.GREATER, false, false, ExecType.MR); + } + + @Test + public void testPPredGreaterDenseSparseMR() + { + runPPredTest(Type.GREATER, false, true, ExecType.MR); + } + + @Test + public void testPPredGreaterSparseDenseMR() + { + runPPredTest(Type.GREATER, true, false, ExecType.MR); + } + + @Test + public void testPPredGreaterSparseSparseMR() + { + runPPredTest(Type.GREATER, true, true, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsDenseDenseMR() + { + runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsDenseSparseMR() + { + runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsSparseDenseMR() + { + runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsSparseSparseMR() + { + runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredEqualsDenseDenseMR() + { + runPPredTest(Type.EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredEqualsDenseSparseMR() + { + runPPredTest(Type.EQUALS, false, true, ExecType.MR); + } + + @Test + public void testPPredEqualsSparseDenseMR() + { + runPPredTest(Type.EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredEqualsSparseSparseMR() + { + runPPredTest(Type.EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredNotEqualsDenseDenseMR() + { + runPPredTest(Type.NOT_EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredNotEqualsDenseSparseMR() + { + runPPredTest(Type.NOT_EQUALS, false, true, ExecType.MR); + } + + @Test + public void testPPredNotEqualsSparseDenseMR() + { + runPPredTest(Type.NOT_EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredNotEqualsSparseSparseMR() + { + runPPredTest(Type.NOT_EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredLessDenseDenseMR() + { + runPPredTest(Type.LESS, false, false, ExecType.MR); + } + + @Test + public void testPPredLessDenseSparseMR() + { + runPPredTest(Type.LESS, false, true, ExecType.MR); + } + + @Test + public void testPPredLessSparseDenseMR() + { + runPPredTest(Type.LESS, true, false, ExecType.MR); + } + + @Test + public void testPPredLessSparseSparseMR() + { + runPPredTest(Type.LESS, true, true, ExecType.MR); + } + + @Test + public void testPPredLessEqualsDenseDenseMR() + { + runPPredTest(Type.LESS_EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredLessEqualsDenseSparseMR() + { + runPPredTest(Type.LESS_EQUALS, false, true, ExecType.MR); + } + + @Test + public void testPPredLessEqualsSparseDenseMR() + { + runPPredTest(Type.LESS_EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredLessEqualsSparseSparseMR() + { + runPPredTest(Type.LESS_EQUALS, true, true, ExecType.MR); + } + + + /** + * + * @param type + * @param instType + * @param sparse + */ + private void runPPredTest( Type type, boolean sp1, boolean sp2, ExecType et ) + { + String TEST_NAME = TEST_NAME1; + int rows = rows1; + int cols = cols1; + + RUNTIME_PLATFORM platformOld = rtplatform; + switch( et ){ + case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break; + case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break; + default: rtplatform = RUNTIME_PLATFORM.HYBRID; break; + } + + boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG; + if( rtplatform == RUNTIME_PLATFORM.SPARK ) + DMLScript.USE_LOCAL_SPARK_CONFIG = true; + + double sparsityLeft = sp1 ? sparsity2 : sparsity1; + double sparsityRight = sp2 ? sparsity2 : sparsity1; + + String TEST_CACHE_DIR = ""; + if (TEST_CACHE_ENABLED) { + TEST_CACHE_DIR = type.ordinal() + "_" + rows + "_" + cols + "_" + sparsityLeft + "_" + sparsityRight + "/"; + } + + try + { + TestConfiguration config = getTestConfiguration(TEST_NAME); + loadTestConfiguration(config, TEST_CACHE_DIR); + + /* This is for running the junit test the new way, i.e., construct the arguments directly */ + String HOME = SCRIPT_DIR + TEST_DIR; + fullDMLScriptName = HOME + TEST_NAME + ".dml"; + programArgs = new String[]{"-args", input("A"), input("B"), + Integer.toString(type.ordinal()), output("C") }; + + fullRScriptName = HOME + TEST_NAME + ".R"; + rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + type.ordinal() + " " + expectedDir(); + + //generate actual dataset + double[][] A = getRandomMatrix(rows, cols, -10, 10, sparsityLeft, 7); + writeInputMatrixWithMTD("A", A, true); + double[][] B = getRandomMatrix(rows, cols, -15, 15, sparsityRight, 3); + writeInputMatrixWithMTD("B", B, true); + + //run tests + runTest(true, false, null, -1); + runRScript(true); + + //compare matrices + HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("C"); + HashMap<CellIndex, Double> rfile = readRMatrixFromFS("C"); + TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R"); + } + finally + { + rtplatform = platformOld; + DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalScalarLeftTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalScalarLeftTest.java b/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalScalarLeftTest.java new file mode 100644 index 0000000..c23943b --- /dev/null +++ b/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalScalarLeftTest.java @@ -0,0 +1,437 @@ +/* + * 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. + */ + +package org.apache.sysml.test.integration.functions.binary.matrix_full_other; + +import java.util.HashMap; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM; +import org.apache.sysml.lops.LopProperties.ExecType; +import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex; +import org.apache.sysml.test.integration.AutomatedTestBase; +import org.apache.sysml.test.integration.TestConfiguration; +import org.apache.sysml.test.utils.TestUtils; + +/** + * The main purpose of this test is to verify the internal optimization regarding + * sparse-safeness of ppred for various input combinations. (ppred is not sparse-safe + * in general, but for certain instance involving 0 scalar it is). + * + * Furthermore, it is used to test all combinations of matrix-scalar, scalar-matrix + * ppred operations in all execution types. + * + */ +public class FullLogicalScalarLeftTest extends AutomatedTestBase +{ + + private final static String TEST_NAME1 = "LogicalScalarLeftTest"; + private final static String TEST_DIR = "functions/binary/matrix_full_other/"; + private final static String TEST_CLASS_DIR = TEST_DIR + FullLogicalScalarLeftTest.class.getSimpleName() + "/"; + private final static double eps = 1e-10; + + private final static int rows1 = 1072; + private final static int cols1 = 1009; + + private final static double sparsity1 = 0.7; + private final static double sparsity2 = 0.1; + + public enum Type{ + GREATER, + LESS, + EQUALS, + NOT_EQUALS, + GREATER_EQUALS, + LESS_EQUALS, + } + + @BeforeClass + public static void init() + { + TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); + } + + @AfterClass + public static void cleanUp() + { + if (TEST_CACHE_ENABLED) { + TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); + } + } + + @Override + public void setUp() + { + addTestConfiguration( TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "B" }) ); + if (TEST_CACHE_ENABLED) { + setOutAndExpectedDeletionDisabled(true); + } + } + + + @Test + public void testPPredGreaterZeroDenseCP() + { + runPPredTest(Type.GREATER, true, false, ExecType.CP); + } + + @Test + public void testPPredLessZeroDenseCP() + { + runPPredTest(Type.LESS, true, false, ExecType.CP); + } + + @Test + public void testPPredEqualsZeroDenseCP() + { + runPPredTest(Type.EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredNotEqualsZeroDenseCP() + { + runPPredTest(Type.NOT_EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsZeroDenseCP() + { + runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredLessEqualsZeroDenseCP() + { + runPPredTest(Type.LESS_EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredGreaterNonZeroDenseCP() + { + runPPredTest(Type.GREATER, false, false, ExecType.CP); + } + + @Test + public void testPPredLessNonZeroDenseCP() + { + runPPredTest(Type.LESS, false, false, ExecType.CP); + } + + @Test + public void testPPredEqualsNonZeroDenseCP() + { + runPPredTest(Type.EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredNotEqualsNonZeroDenseCP() + { + runPPredTest(Type.NOT_EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsNonZeroDenseCP() + { + runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredLessEqualsNonZeroDenseCP() + { + runPPredTest(Type.LESS_EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredGreaterZeroSparseCP() + { + runPPredTest(Type.GREATER, true, true, ExecType.CP); + } + + @Test + public void testPPredLessZeroSparseCP() + { + runPPredTest(Type.LESS, true, true, ExecType.CP); + } + + @Test + public void testPPredEqualsZeroSparseCP() + { + runPPredTest(Type.EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredNotEqualsZeroSparseCP() + { + runPPredTest(Type.NOT_EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsZeroSparseCP() + { + runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredLessEqualsZeroSparseCP() + { + runPPredTest(Type.LESS_EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredGreaterNonZeroSparseCP() + { + runPPredTest(Type.GREATER, false, true, ExecType.CP); + } + + @Test + public void testPPredLessNonZeroSparseCP() + { + runPPredTest(Type.LESS, false, true, ExecType.CP); + } + + @Test + public void testPPredEqualsNonZeroSparseCP() + { + runPPredTest(Type.EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredNotEqualsNonZeroSparseCP() + { + runPPredTest(Type.NOT_EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsNonZeroSparseCP() + { + runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredLessEqualsNonZeroSparseCP() + { + runPPredTest(Type.LESS_EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredGreaterZeroDenseMR() + { + runPPredTest(Type.GREATER, true, false, ExecType.MR); + } + + @Test + public void testPPredLessZeroDenseMR() + { + runPPredTest(Type.LESS, true, false, ExecType.MR); + } + + @Test + public void testPPredEqualsZeroDenseMR() + { + runPPredTest(Type.EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredNotEqualsZeroDenseMR() + { + runPPredTest(Type.NOT_EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsZeroDenseMR() + { + runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredLessEqualsZeroDenseMR() + { + runPPredTest(Type.LESS_EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredGreaterNonZeroDenseMR() + { + runPPredTest(Type.GREATER, false, false, ExecType.MR); + } + + @Test + public void testPPredLessNonZeroDenseMR() + { + runPPredTest(Type.LESS, false, false, ExecType.MR); + } + + @Test + public void testPPredEqualsNonZeroDenseMR() + { + runPPredTest(Type.EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredNotEqualsNonZeroDenseMR() + { + runPPredTest(Type.NOT_EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsNonZeroDenseMR() + { + runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredLessEqualsNonZeroDenseMR() + { + runPPredTest(Type.LESS_EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredGreaterZeroSparseMR() + { + runPPredTest(Type.GREATER, true, true, ExecType.MR); + } + + @Test + public void testPPredLessZeroSparseMR() + { + runPPredTest(Type.LESS, true, true, ExecType.MR); + } + + @Test + public void testPPredEqualsZeroSparseMR() + { + runPPredTest(Type.EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredNotEqualsZeroSparseMR() + { + runPPredTest(Type.NOT_EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsZeroSparseMR() + { + runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredLessEqualsZeroSparseMR() + { + runPPredTest(Type.LESS_EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredGreaterNonZeroSparseMR() + { + runPPredTest(Type.GREATER, false, true, ExecType.MR); + } + + @Test + public void testPPredLessNonZeroSparseMR() + { + runPPredTest(Type.LESS, false, true, ExecType.MR); + } + + @Test + public void testPPredEqualsNonZeroSparseMR() + { + runPPredTest(Type.EQUALS, false, true, ExecType.MR); + } + + @Test + public void testPPredNotEqualsNonZeroSparseMR() + { + runPPredTest(Type.NOT_EQUALS, false, true, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsNonZeroSparseMR() + { + runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.MR); + } + + @Test + public void testPPredLessEqualsNonZeroSparseMR() + { + runPPredTest(Type.LESS_EQUALS, false, true, ExecType.MR); + } + + + /** + * + * @param type + * @param instType + * @param sparse + */ + private void runPPredTest( Type type, boolean zero, boolean sparse, ExecType et ) + { + String TEST_NAME = TEST_NAME1; + int rows = rows1; + int cols = cols1; + double sparsity = sparse ? sparsity2 : sparsity1; + double constant = zero ? 0 : 0.5; + + String TEST_CACHE_DIR = ""; + if (TEST_CACHE_ENABLED) { + TEST_CACHE_DIR = type.ordinal() + "_" + constant + "_" + sparsity + "/"; + } + + //rtplatform for MR + RUNTIME_PLATFORM platformOld = rtplatform; + rtplatform = (et==ExecType.MR) ? RUNTIME_PLATFORM.HADOOP : RUNTIME_PLATFORM.HYBRID; + + try + { + TestConfiguration config = getTestConfiguration(TEST_NAME); + + loadTestConfiguration(config, TEST_CACHE_DIR); + + /* This is for running the junit test the new way, i.e., construct the arguments directly */ + String HOME = SCRIPT_DIR + TEST_DIR; + fullDMLScriptName = HOME + TEST_NAME + ".dml"; + programArgs = new String[]{"-explain","-args", input("A"), + Integer.toString(type.ordinal()), Double.toString(constant), output("B") }; + + fullRScriptName = HOME + TEST_NAME + ".R"; + rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + + type.ordinal() + " " + constant + " " + expectedDir(); + + //generate actual dataset + double[][] A = getRandomMatrix(rows, cols, -1, 1, sparsity, 7); + writeInputMatrixWithMTD("A", A, true); + + //run tests + runTest(true, false, null, -1); + runRScript(true); + + //compare matrices + HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("B"); + HashMap<CellIndex, Double> rfile = readRMatrixFromFS("B"); + TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R"); + } + finally + { + rtplatform = platformOld; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalScalarRightTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalScalarRightTest.java b/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalScalarRightTest.java new file mode 100644 index 0000000..30fcdac --- /dev/null +++ b/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullLogicalScalarRightTest.java @@ -0,0 +1,436 @@ +/* + * 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. + */ + +package org.apache.sysml.test.integration.functions.binary.matrix_full_other; + +import java.util.HashMap; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM; +import org.apache.sysml.lops.LopProperties.ExecType; +import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex; +import org.apache.sysml.test.integration.AutomatedTestBase; +import org.apache.sysml.test.integration.TestConfiguration; +import org.apache.sysml.test.utils.TestUtils; + +/** + * The main purpose of this test is to verify the internal optimization regarding + * sparse-safeness of ppred for various input combinations. (ppred is not sparse-safe + * in general, but for certain instance involving 0 scalar it is). + * + * Furthermore, it is used to test all combinations of matrix-scalar, scalar-matrix + * ppred operations in all execution types. + * + */ +public class FullLogicalScalarRightTest extends AutomatedTestBase +{ + + private final static String TEST_NAME1 = "LogicalScalarRightTest"; + private final static String TEST_DIR = "functions/binary/matrix_full_other/"; + private final static String TEST_CLASS_DIR = TEST_DIR + FullLogicalScalarRightTest.class.getSimpleName() + "/"; + private final static double eps = 1e-10; + + private final static int rows1 = 1072; + private final static int cols1 = 1009; + + private final static double sparsity1 = 0.7; + private final static double sparsity2 = 0.1; + + public enum Type{ + GREATER, + LESS, + EQUALS, + NOT_EQUALS, + GREATER_EQUALS, + LESS_EQUALS, + } + + + @Override + public void setUp() + { + addTestConfiguration( TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "B" }) ); + if (TEST_CACHE_ENABLED) { + setOutAndExpectedDeletionDisabled(true); + } + } + + @BeforeClass + public static void init() + { + TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); + } + + @AfterClass + public static void cleanUp() + { + if (TEST_CACHE_ENABLED) { + TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); + } + } + + @Test + public void testPPredGreaterZeroDenseCP() + { + runPPredTest(Type.GREATER, true, false, ExecType.CP); + } + + @Test + public void testPPredLessZeroDenseCP() + { + runPPredTest(Type.LESS, true, false, ExecType.CP); + } + + @Test + public void testPPredEqualsZeroDenseCP() + { + runPPredTest(Type.EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredNotEqualsZeroDenseCP() + { + runPPredTest(Type.NOT_EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsZeroDenseCP() + { + runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredLessEqualsZeroDenseCP() + { + runPPredTest(Type.LESS_EQUALS, true, false, ExecType.CP); + } + + @Test + public void testPPredGreaterNonZeroDenseCP() + { + runPPredTest(Type.GREATER, false, false, ExecType.CP); + } + + @Test + public void testPPredLessNonZeroDenseCP() + { + runPPredTest(Type.LESS, false, false, ExecType.CP); + } + + @Test + public void testPPredEqualsNonZeroDenseCP() + { + runPPredTest(Type.EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredNotEqualsNonZeroDenseCP() + { + runPPredTest(Type.NOT_EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsNonZeroDenseCP() + { + runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredLessEqualsNonZeroDenseCP() + { + runPPredTest(Type.LESS_EQUALS, false, false, ExecType.CP); + } + + @Test + public void testPPredGreaterZeroSparseCP() + { + runPPredTest(Type.GREATER, true, true, ExecType.CP); + } + + @Test + public void testPPredLessZeroSparseCP() + { + runPPredTest(Type.LESS, true, true, ExecType.CP); + } + + @Test + public void testPPredEqualsZeroSparseCP() + { + runPPredTest(Type.EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredNotEqualsZeroSparseCP() + { + runPPredTest(Type.NOT_EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsZeroSparseCP() + { + runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredLessEqualsZeroSparseCP() + { + runPPredTest(Type.LESS_EQUALS, true, true, ExecType.CP); + } + + @Test + public void testPPredGreaterNonZeroSparseCP() + { + runPPredTest(Type.GREATER, false, true, ExecType.CP); + } + + @Test + public void testPPredLessNonZeroSparseCP() + { + runPPredTest(Type.LESS, false, true, ExecType.CP); + } + + @Test + public void testPPredEqualsNonZeroSparseCP() + { + runPPredTest(Type.EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredNotEqualsNonZeroSparseCP() + { + runPPredTest(Type.NOT_EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredGreaterEqualsNonZeroSparseCP() + { + runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredLessEqualsNonZeroSparseCP() + { + runPPredTest(Type.LESS_EQUALS, false, true, ExecType.CP); + } + + @Test + public void testPPredGreaterZeroDenseMR() + { + runPPredTest(Type.GREATER, true, false, ExecType.MR); + } + + @Test + public void testPPredLessZeroDenseMR() + { + runPPredTest(Type.LESS, true, false, ExecType.MR); + } + + @Test + public void testPPredEqualsZeroDenseMR() + { + runPPredTest(Type.EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredNotEqualsZeroDenseMR() + { + runPPredTest(Type.NOT_EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsZeroDenseMR() + { + runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredLessEqualsZeroDenseMR() + { + runPPredTest(Type.LESS_EQUALS, true, false, ExecType.MR); + } + + @Test + public void testPPredGreaterNonZeroDenseMR() + { + runPPredTest(Type.GREATER, false, false, ExecType.MR); + } + + @Test + public void testPPredLessNonZeroDenseMR() + { + runPPredTest(Type.LESS, false, false, ExecType.MR); + } + + @Test + public void testPPredEqualsNonZeroDenseMR() + { + runPPredTest(Type.EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredNotEqualsNonZeroDenseMR() + { + runPPredTest(Type.NOT_EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsNonZeroDenseMR() + { + runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredLessEqualsNonZeroDenseMR() + { + runPPredTest(Type.LESS_EQUALS, false, false, ExecType.MR); + } + + @Test + public void testPPredGreaterZeroSparseMR() + { + runPPredTest(Type.GREATER, true, true, ExecType.MR); + } + + @Test + public void testPPredLessZeroSparseMR() + { + runPPredTest(Type.LESS, true, true, ExecType.MR); + } + + @Test + public void testPPredEqualsZeroSparseMR() + { + runPPredTest(Type.EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredNotEqualsZeroSparseMR() + { + runPPredTest(Type.NOT_EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsZeroSparseMR() + { + runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredLessEqualsZeroSparseMR() + { + runPPredTest(Type.LESS_EQUALS, true, true, ExecType.MR); + } + + @Test + public void testPPredGreaterNonZeroSparseMR() + { + runPPredTest(Type.GREATER, false, true, ExecType.MR); + } + + @Test + public void testPPredLessNonZeroSparseMR() + { + runPPredTest(Type.LESS, false, true, ExecType.MR); + } + + @Test + public void testPPredEqualsNonZeroSparseMR() + { + runPPredTest(Type.EQUALS, false, true, ExecType.MR); + } + + @Test + public void testPPredNotEqualsNonZeroSparseMR() + { + runPPredTest(Type.NOT_EQUALS, false, true, ExecType.MR); + } + + @Test + public void testPPredGreaterEqualsNonZeroSparseMR() + { + runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.MR); + } + + @Test + public void testPPredLessEqualsNonZeroSparseMR() + { + runPPredTest(Type.LESS_EQUALS, false, true, ExecType.MR); + } + + + /** + * + * @param type + * @param instType + * @param sparse + */ + private void runPPredTest( Type type, boolean zero, boolean sparse, ExecType et ) + { + String TEST_NAME = TEST_NAME1; + int rows = rows1; + int cols = cols1; + double sparsity = sparse ? sparsity2 : sparsity1; + double constant = zero ? 0 : 0.5; + + String TEST_CACHE_DIR = ""; + if (TEST_CACHE_ENABLED) { + TEST_CACHE_DIR = type.ordinal() + "_" + constant + "_" + sparsity + "/"; + } + + //rtplatform for MR + RUNTIME_PLATFORM platformOld = rtplatform; + rtplatform = (et==ExecType.MR) ? RUNTIME_PLATFORM.HADOOP : RUNTIME_PLATFORM.HYBRID; + + try + { + TestConfiguration config = getTestConfiguration(TEST_NAME); + loadTestConfiguration(config, TEST_CACHE_DIR); + + /* This is for running the junit test the new way, i.e., construct the arguments directly */ + String HOME = SCRIPT_DIR + TEST_DIR; + fullDMLScriptName = HOME + TEST_NAME + ".dml"; + programArgs = new String[]{"-args", input("A"), + Integer.toString(type.ordinal()), Double.toString(constant), output("B") }; + + fullRScriptName = HOME + TEST_NAME + ".R"; + rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + + type.ordinal() + " " + constant + " " + expectedDir(); + + //generate actual dataset + double[][] A = getRandomMatrix(rows, cols, -1, 1, sparsity, 7); + writeInputMatrixWithMTD("A", A, true); + + //run tests + runTest(true, false, null, -1); + runRScript(true); + + //compare matrices + HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("B"); + HashMap<CellIndex, Double> rfile = readRMatrixFromFS("B"); + TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R"); + } + finally + { + rtplatform = platformOld; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredMatrixTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredMatrixTest.java b/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredMatrixTest.java deleted file mode 100644 index 5f2161e..0000000 --- a/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredMatrixTest.java +++ /dev/null @@ -1,590 +0,0 @@ -/* - * 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. - */ - -package org.apache.sysml.test.integration.functions.binary.matrix_full_other; - -import java.util.HashMap; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.apache.sysml.api.DMLScript; -import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM; -import org.apache.sysml.lops.LopProperties.ExecType; -import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex; -import org.apache.sysml.test.integration.AutomatedTestBase; -import org.apache.sysml.test.integration.TestConfiguration; -import org.apache.sysml.test.utils.TestUtils; - -/** - * The main purpose of this test is to verify various input combinations for - * matrix-matrix ppred operations that internally translate to binary operations. - * - */ -public class FullPPredMatrixTest extends AutomatedTestBase -{ - - private final static String TEST_NAME1 = "PPredMatrixTest"; - private final static String TEST_DIR = "functions/binary/matrix_full_other/"; - private final static String TEST_CLASS_DIR = TEST_DIR + FullPPredMatrixTest.class.getSimpleName() + "/"; - private final static double eps = 1e-10; - - private final static int rows1 = 1383; - private final static int cols1 = 1432; - - private final static double sparsity1 = 0.7; - private final static double sparsity2 = 0.01; - - public enum Type{ - GREATER, - LESS, - EQUALS, - NOT_EQUALS, - GREATER_EQUALS, - LESS_EQUALS, - } - - @Override - public void setUp() - { - addTestConfiguration( TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "C" }) ); - TestUtils.clearAssertionInformation(); - if (TEST_CACHE_ENABLED) { - setOutAndExpectedDeletionDisabled(true); - } - } - - @BeforeClass - public static void init() - { - TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); - } - - @AfterClass - public static void cleanUp() - { - if (TEST_CACHE_ENABLED) { - TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); - } - } - - @Test - public void testPPredGreaterDenseDenseCP() - { - runPPredTest(Type.GREATER, false, false, ExecType.CP); - } - - @Test - public void testPPredGreaterDenseSparseCP() - { - runPPredTest(Type.GREATER, false, true, ExecType.CP); - } - - @Test - public void testPPredGreaterSparseDenseCP() - { - runPPredTest(Type.GREATER, true, false, ExecType.CP); - } - - @Test - public void testPPredGreaterSparseSparseCP() - { - runPPredTest(Type.GREATER, true, true, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsDenseDenseCP() - { - runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsDenseSparseCP() - { - runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsSparseDenseCP() - { - runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsSparseSparseCP() - { - runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredEqualsDenseDenseCP() - { - runPPredTest(Type.EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredEqualsDenseSparseCP() - { - runPPredTest(Type.EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredEqualsSparseDenseCP() - { - runPPredTest(Type.EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredEqualsSparseSparseCP() - { - runPPredTest(Type.EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredNotEqualsDenseDenseCP() - { - runPPredTest(Type.NOT_EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredNotEqualsDenseSparseCP() - { - runPPredTest(Type.NOT_EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredNotEqualsSparseDenseCP() - { - runPPredTest(Type.NOT_EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredNotEqualsSparseSparseCP() - { - runPPredTest(Type.NOT_EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredLessDenseDenseCP() - { - runPPredTest(Type.LESS, false, false, ExecType.CP); - } - - @Test - public void testPPredLessDenseSparseCP() - { - runPPredTest(Type.LESS, false, true, ExecType.CP); - } - - @Test - public void testPPredLessSparseDenseCP() - { - runPPredTest(Type.LESS, true, false, ExecType.CP); - } - - @Test - public void testPPredLessSparseSparseCP() - { - runPPredTest(Type.LESS, true, true, ExecType.CP); - } - - @Test - public void testPPredLessEqualsDenseDenseCP() - { - runPPredTest(Type.LESS_EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredLessEqualsDenseSparseCP() - { - runPPredTest(Type.LESS_EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredLessEqualsSparseDenseCP() - { - runPPredTest(Type.LESS_EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredLessEqualsSparseSparseCP() - { - runPPredTest(Type.LESS_EQUALS, true, true, ExecType.CP); - } - - - // ------------------------ - @Test - public void testPPredGreaterDenseDenseSP() - { - runPPredTest(Type.GREATER, false, false, ExecType.SPARK); - } - - @Test - public void testPPredGreaterDenseSparseSP() - { - runPPredTest(Type.GREATER, false, true, ExecType.SPARK); - } - - @Test - public void testPPredGreaterSparseDenseSP() - { - runPPredTest(Type.GREATER, true, false, ExecType.SPARK); - } - - @Test - public void testPPredGreaterSparseSparseSP() - { - runPPredTest(Type.GREATER, true, true, ExecType.SPARK); - } - - @Test - public void testPPredGreaterEqualsDenseDenseSP() - { - runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.SPARK); - } - - @Test - public void testPPredGreaterEqualsDenseSparseSP() - { - runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.SPARK); - } - - @Test - public void testPPredGreaterEqualsSparseDenseSP() - { - runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.SPARK); - } - - @Test - public void testPPredGreaterEqualsSparseSparseSP() - { - runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.SPARK); - } - - @Test - public void testPPredEqualsDenseDenseSP() - { - runPPredTest(Type.EQUALS, false, false, ExecType.SPARK); - } - - @Test - public void testPPredEqualsDenseSparseSP() - { - runPPredTest(Type.EQUALS, false, true, ExecType.SPARK); - } - - @Test - public void testPPredEqualsSparseDenseSP() - { - runPPredTest(Type.EQUALS, true, false, ExecType.SPARK); - } - - @Test - public void testPPredEqualsSparseSparseSP() - { - runPPredTest(Type.EQUALS, true, true, ExecType.SPARK); - } - - @Test - public void testPPredNotEqualsDenseDenseSP() - { - runPPredTest(Type.NOT_EQUALS, false, false, ExecType.SPARK); - } - - @Test - public void testPPredNotEqualsDenseSparseSP() - { - runPPredTest(Type.NOT_EQUALS, false, true, ExecType.SPARK); - } - - @Test - public void testPPredNotEqualsSparseDenseSP() - { - runPPredTest(Type.NOT_EQUALS, true, false, ExecType.SPARK); - } - - @Test - public void testPPredNotEqualsSparseSparseSP() - { - runPPredTest(Type.NOT_EQUALS, true, true, ExecType.SPARK); - } - - @Test - public void testPPredLessDenseDenseSP() - { - runPPredTest(Type.LESS, false, false, ExecType.SPARK); - } - - @Test - public void testPPredLessDenseSparseSP() - { - runPPredTest(Type.LESS, false, true, ExecType.SPARK); - } - - @Test - public void testPPredLessSparseDenseSP() - { - runPPredTest(Type.LESS, true, false, ExecType.SPARK); - } - - @Test - public void testPPredLessSparseSparseSP() - { - runPPredTest(Type.LESS, true, true, ExecType.SPARK); - } - - @Test - public void testPPredLessEqualsDenseDenseSP() - { - runPPredTest(Type.LESS_EQUALS, false, false, ExecType.SPARK); - } - - @Test - public void testPPredLessEqualsDenseSparseSP() - { - runPPredTest(Type.LESS_EQUALS, false, true, ExecType.SPARK); - } - - @Test - public void testPPredLessEqualsSparseDenseSP() - { - runPPredTest(Type.LESS_EQUALS, true, false, ExecType.SPARK); - } - - @Test - public void testPPredLessEqualsSparseSparseSP() - { - runPPredTest(Type.LESS_EQUALS, true, true, ExecType.SPARK); - } - // ---------------------- - - @Test - public void testPPredGreaterDenseDenseMR() - { - runPPredTest(Type.GREATER, false, false, ExecType.MR); - } - - @Test - public void testPPredGreaterDenseSparseMR() - { - runPPredTest(Type.GREATER, false, true, ExecType.MR); - } - - @Test - public void testPPredGreaterSparseDenseMR() - { - runPPredTest(Type.GREATER, true, false, ExecType.MR); - } - - @Test - public void testPPredGreaterSparseSparseMR() - { - runPPredTest(Type.GREATER, true, true, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsDenseDenseMR() - { - runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsDenseSparseMR() - { - runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsSparseDenseMR() - { - runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsSparseSparseMR() - { - runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredEqualsDenseDenseMR() - { - runPPredTest(Type.EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredEqualsDenseSparseMR() - { - runPPredTest(Type.EQUALS, false, true, ExecType.MR); - } - - @Test - public void testPPredEqualsSparseDenseMR() - { - runPPredTest(Type.EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredEqualsSparseSparseMR() - { - runPPredTest(Type.EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredNotEqualsDenseDenseMR() - { - runPPredTest(Type.NOT_EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredNotEqualsDenseSparseMR() - { - runPPredTest(Type.NOT_EQUALS, false, true, ExecType.MR); - } - - @Test - public void testPPredNotEqualsSparseDenseMR() - { - runPPredTest(Type.NOT_EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredNotEqualsSparseSparseMR() - { - runPPredTest(Type.NOT_EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredLessDenseDenseMR() - { - runPPredTest(Type.LESS, false, false, ExecType.MR); - } - - @Test - public void testPPredLessDenseSparseMR() - { - runPPredTest(Type.LESS, false, true, ExecType.MR); - } - - @Test - public void testPPredLessSparseDenseMR() - { - runPPredTest(Type.LESS, true, false, ExecType.MR); - } - - @Test - public void testPPredLessSparseSparseMR() - { - runPPredTest(Type.LESS, true, true, ExecType.MR); - } - - @Test - public void testPPredLessEqualsDenseDenseMR() - { - runPPredTest(Type.LESS_EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredLessEqualsDenseSparseMR() - { - runPPredTest(Type.LESS_EQUALS, false, true, ExecType.MR); - } - - @Test - public void testPPredLessEqualsSparseDenseMR() - { - runPPredTest(Type.LESS_EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredLessEqualsSparseSparseMR() - { - runPPredTest(Type.LESS_EQUALS, true, true, ExecType.MR); - } - - - /** - * - * @param type - * @param instType - * @param sparse - */ - private void runPPredTest( Type type, boolean sp1, boolean sp2, ExecType et ) - { - String TEST_NAME = TEST_NAME1; - int rows = rows1; - int cols = cols1; - - RUNTIME_PLATFORM platformOld = rtplatform; - switch( et ){ - case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break; - case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break; - default: rtplatform = RUNTIME_PLATFORM.HYBRID; break; - } - - boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG; - if( rtplatform == RUNTIME_PLATFORM.SPARK ) - DMLScript.USE_LOCAL_SPARK_CONFIG = true; - - double sparsityLeft = sp1 ? sparsity2 : sparsity1; - double sparsityRight = sp2 ? sparsity2 : sparsity1; - - String TEST_CACHE_DIR = ""; - if (TEST_CACHE_ENABLED) { - TEST_CACHE_DIR = type.ordinal() + "_" + rows + "_" + cols + "_" + sparsityLeft + "_" + sparsityRight + "/"; - } - - try - { - TestConfiguration config = getTestConfiguration(TEST_NAME); - loadTestConfiguration(config, TEST_CACHE_DIR); - - /* This is for running the junit test the new way, i.e., construct the arguments directly */ - String HOME = SCRIPT_DIR + TEST_DIR; - fullDMLScriptName = HOME + TEST_NAME + ".dml"; - programArgs = new String[]{"-args", input("A"), input("B"), - Integer.toString(type.ordinal()), output("C") }; - - fullRScriptName = HOME + TEST_NAME + ".R"; - rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + type.ordinal() + " " + expectedDir(); - - //generate actual dataset - double[][] A = getRandomMatrix(rows, cols, -10, 10, sparsityLeft, 7); - writeInputMatrixWithMTD("A", A, true); - double[][] B = getRandomMatrix(rows, cols, -15, 15, sparsityRight, 3); - writeInputMatrixWithMTD("B", B, true); - - //run tests - runTest(true, false, null, -1); - runRScript(true); - - //compare matrices - HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("C"); - HashMap<CellIndex, Double> rfile = readRMatrixFromFS("C"); - TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R"); - } - finally - { - rtplatform = platformOld; - DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredScalarLeftTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredScalarLeftTest.java b/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredScalarLeftTest.java deleted file mode 100644 index 1ddf995..0000000 --- a/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredScalarLeftTest.java +++ /dev/null @@ -1,437 +0,0 @@ -/* - * 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. - */ - -package org.apache.sysml.test.integration.functions.binary.matrix_full_other; - -import java.util.HashMap; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM; -import org.apache.sysml.lops.LopProperties.ExecType; -import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex; -import org.apache.sysml.test.integration.AutomatedTestBase; -import org.apache.sysml.test.integration.TestConfiguration; -import org.apache.sysml.test.utils.TestUtils; - -/** - * The main purpose of this test is to verify the internal optimization regarding - * sparse-safeness of ppred for various input combinations. (ppred is not sparse-safe - * in general, but for certain instance involving 0 scalar it is). - * - * Furthermore, it is used to test all combinations of matrix-scalar, scalar-matrix - * ppred operations in all execution types. - * - */ -public class FullPPredScalarLeftTest extends AutomatedTestBase -{ - - private final static String TEST_NAME1 = "PPredScalarLeftTest"; - private final static String TEST_DIR = "functions/binary/matrix_full_other/"; - private final static String TEST_CLASS_DIR = TEST_DIR + FullPPredScalarLeftTest.class.getSimpleName() + "/"; - private final static double eps = 1e-10; - - private final static int rows1 = 1072; - private final static int cols1 = 1009; - - private final static double sparsity1 = 0.7; - private final static double sparsity2 = 0.1; - - public enum Type{ - GREATER, - LESS, - EQUALS, - NOT_EQUALS, - GREATER_EQUALS, - LESS_EQUALS, - } - - @BeforeClass - public static void init() - { - TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); - } - - @AfterClass - public static void cleanUp() - { - if (TEST_CACHE_ENABLED) { - TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); - } - } - - @Override - public void setUp() - { - addTestConfiguration( TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "B" }) ); - if (TEST_CACHE_ENABLED) { - setOutAndExpectedDeletionDisabled(true); - } - } - - - @Test - public void testPPredGreaterZeroDenseCP() - { - runPPredTest(Type.GREATER, true, false, ExecType.CP); - } - - @Test - public void testPPredLessZeroDenseCP() - { - runPPredTest(Type.LESS, true, false, ExecType.CP); - } - - @Test - public void testPPredEqualsZeroDenseCP() - { - runPPredTest(Type.EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredNotEqualsZeroDenseCP() - { - runPPredTest(Type.NOT_EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsZeroDenseCP() - { - runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredLessEqualsZeroDenseCP() - { - runPPredTest(Type.LESS_EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredGreaterNonZeroDenseCP() - { - runPPredTest(Type.GREATER, false, false, ExecType.CP); - } - - @Test - public void testPPredLessNonZeroDenseCP() - { - runPPredTest(Type.LESS, false, false, ExecType.CP); - } - - @Test - public void testPPredEqualsNonZeroDenseCP() - { - runPPredTest(Type.EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredNotEqualsNonZeroDenseCP() - { - runPPredTest(Type.NOT_EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsNonZeroDenseCP() - { - runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredLessEqualsNonZeroDenseCP() - { - runPPredTest(Type.LESS_EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredGreaterZeroSparseCP() - { - runPPredTest(Type.GREATER, true, true, ExecType.CP); - } - - @Test - public void testPPredLessZeroSparseCP() - { - runPPredTest(Type.LESS, true, true, ExecType.CP); - } - - @Test - public void testPPredEqualsZeroSparseCP() - { - runPPredTest(Type.EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredNotEqualsZeroSparseCP() - { - runPPredTest(Type.NOT_EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsZeroSparseCP() - { - runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredLessEqualsZeroSparseCP() - { - runPPredTest(Type.LESS_EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredGreaterNonZeroSparseCP() - { - runPPredTest(Type.GREATER, false, true, ExecType.CP); - } - - @Test - public void testPPredLessNonZeroSparseCP() - { - runPPredTest(Type.LESS, false, true, ExecType.CP); - } - - @Test - public void testPPredEqualsNonZeroSparseCP() - { - runPPredTest(Type.EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredNotEqualsNonZeroSparseCP() - { - runPPredTest(Type.NOT_EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsNonZeroSparseCP() - { - runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredLessEqualsNonZeroSparseCP() - { - runPPredTest(Type.LESS_EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredGreaterZeroDenseMR() - { - runPPredTest(Type.GREATER, true, false, ExecType.MR); - } - - @Test - public void testPPredLessZeroDenseMR() - { - runPPredTest(Type.LESS, true, false, ExecType.MR); - } - - @Test - public void testPPredEqualsZeroDenseMR() - { - runPPredTest(Type.EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredNotEqualsZeroDenseMR() - { - runPPredTest(Type.NOT_EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsZeroDenseMR() - { - runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredLessEqualsZeroDenseMR() - { - runPPredTest(Type.LESS_EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredGreaterNonZeroDenseMR() - { - runPPredTest(Type.GREATER, false, false, ExecType.MR); - } - - @Test - public void testPPredLessNonZeroDenseMR() - { - runPPredTest(Type.LESS, false, false, ExecType.MR); - } - - @Test - public void testPPredEqualsNonZeroDenseMR() - { - runPPredTest(Type.EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredNotEqualsNonZeroDenseMR() - { - runPPredTest(Type.NOT_EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsNonZeroDenseMR() - { - runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredLessEqualsNonZeroDenseMR() - { - runPPredTest(Type.LESS_EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredGreaterZeroSparseMR() - { - runPPredTest(Type.GREATER, true, true, ExecType.MR); - } - - @Test - public void testPPredLessZeroSparseMR() - { - runPPredTest(Type.LESS, true, true, ExecType.MR); - } - - @Test - public void testPPredEqualsZeroSparseMR() - { - runPPredTest(Type.EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredNotEqualsZeroSparseMR() - { - runPPredTest(Type.NOT_EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsZeroSparseMR() - { - runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredLessEqualsZeroSparseMR() - { - runPPredTest(Type.LESS_EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredGreaterNonZeroSparseMR() - { - runPPredTest(Type.GREATER, false, true, ExecType.MR); - } - - @Test - public void testPPredLessNonZeroSparseMR() - { - runPPredTest(Type.LESS, false, true, ExecType.MR); - } - - @Test - public void testPPredEqualsNonZeroSparseMR() - { - runPPredTest(Type.EQUALS, false, true, ExecType.MR); - } - - @Test - public void testPPredNotEqualsNonZeroSparseMR() - { - runPPredTest(Type.NOT_EQUALS, false, true, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsNonZeroSparseMR() - { - runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.MR); - } - - @Test - public void testPPredLessEqualsNonZeroSparseMR() - { - runPPredTest(Type.LESS_EQUALS, false, true, ExecType.MR); - } - - - /** - * - * @param type - * @param instType - * @param sparse - */ - private void runPPredTest( Type type, boolean zero, boolean sparse, ExecType et ) - { - String TEST_NAME = TEST_NAME1; - int rows = rows1; - int cols = cols1; - double sparsity = sparse ? sparsity2 : sparsity1; - double constant = zero ? 0 : 0.5; - - String TEST_CACHE_DIR = ""; - if (TEST_CACHE_ENABLED) { - TEST_CACHE_DIR = type.ordinal() + "_" + constant + "_" + sparsity + "/"; - } - - //rtplatform for MR - RUNTIME_PLATFORM platformOld = rtplatform; - rtplatform = (et==ExecType.MR) ? RUNTIME_PLATFORM.HADOOP : RUNTIME_PLATFORM.HYBRID; - - try - { - TestConfiguration config = getTestConfiguration(TEST_NAME); - - loadTestConfiguration(config, TEST_CACHE_DIR); - - /* This is for running the junit test the new way, i.e., construct the arguments directly */ - String HOME = SCRIPT_DIR + TEST_DIR; - fullDMLScriptName = HOME + TEST_NAME + ".dml"; - programArgs = new String[]{"-explain","-args", input("A"), - Integer.toString(type.ordinal()), Double.toString(constant), output("B") }; - - fullRScriptName = HOME + TEST_NAME + ".R"; - rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + - type.ordinal() + " " + constant + " " + expectedDir(); - - //generate actual dataset - double[][] A = getRandomMatrix(rows, cols, -1, 1, sparsity, 7); - writeInputMatrixWithMTD("A", A, true); - - //run tests - runTest(true, false, null, -1); - runRScript(true); - - //compare matrices - HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("B"); - HashMap<CellIndex, Double> rfile = readRMatrixFromFS("B"); - TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R"); - } - finally - { - rtplatform = platformOld; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredScalarRightTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredScalarRightTest.java b/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredScalarRightTest.java deleted file mode 100644 index 40139e0..0000000 --- a/src/test/java/org/apache/sysml/test/integration/functions/binary/matrix_full_other/FullPPredScalarRightTest.java +++ /dev/null @@ -1,436 +0,0 @@ -/* - * 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. - */ - -package org.apache.sysml.test.integration.functions.binary.matrix_full_other; - -import java.util.HashMap; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM; -import org.apache.sysml.lops.LopProperties.ExecType; -import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex; -import org.apache.sysml.test.integration.AutomatedTestBase; -import org.apache.sysml.test.integration.TestConfiguration; -import org.apache.sysml.test.utils.TestUtils; - -/** - * The main purpose of this test is to verify the internal optimization regarding - * sparse-safeness of ppred for various input combinations. (ppred is not sparse-safe - * in general, but for certain instance involving 0 scalar it is). - * - * Furthermore, it is used to test all combinations of matrix-scalar, scalar-matrix - * ppred operations in all execution types. - * - */ -public class FullPPredScalarRightTest extends AutomatedTestBase -{ - - private final static String TEST_NAME1 = "PPredScalarRightTest"; - private final static String TEST_DIR = "functions/binary/matrix_full_other/"; - private final static String TEST_CLASS_DIR = TEST_DIR + FullPPredScalarRightTest.class.getSimpleName() + "/"; - private final static double eps = 1e-10; - - private final static int rows1 = 1072; - private final static int cols1 = 1009; - - private final static double sparsity1 = 0.7; - private final static double sparsity2 = 0.1; - - public enum Type{ - GREATER, - LESS, - EQUALS, - NOT_EQUALS, - GREATER_EQUALS, - LESS_EQUALS, - } - - - @Override - public void setUp() - { - addTestConfiguration( TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "B" }) ); - if (TEST_CACHE_ENABLED) { - setOutAndExpectedDeletionDisabled(true); - } - } - - @BeforeClass - public static void init() - { - TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); - } - - @AfterClass - public static void cleanUp() - { - if (TEST_CACHE_ENABLED) { - TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR); - } - } - - @Test - public void testPPredGreaterZeroDenseCP() - { - runPPredTest(Type.GREATER, true, false, ExecType.CP); - } - - @Test - public void testPPredLessZeroDenseCP() - { - runPPredTest(Type.LESS, true, false, ExecType.CP); - } - - @Test - public void testPPredEqualsZeroDenseCP() - { - runPPredTest(Type.EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredNotEqualsZeroDenseCP() - { - runPPredTest(Type.NOT_EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsZeroDenseCP() - { - runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredLessEqualsZeroDenseCP() - { - runPPredTest(Type.LESS_EQUALS, true, false, ExecType.CP); - } - - @Test - public void testPPredGreaterNonZeroDenseCP() - { - runPPredTest(Type.GREATER, false, false, ExecType.CP); - } - - @Test - public void testPPredLessNonZeroDenseCP() - { - runPPredTest(Type.LESS, false, false, ExecType.CP); - } - - @Test - public void testPPredEqualsNonZeroDenseCP() - { - runPPredTest(Type.EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredNotEqualsNonZeroDenseCP() - { - runPPredTest(Type.NOT_EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsNonZeroDenseCP() - { - runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredLessEqualsNonZeroDenseCP() - { - runPPredTest(Type.LESS_EQUALS, false, false, ExecType.CP); - } - - @Test - public void testPPredGreaterZeroSparseCP() - { - runPPredTest(Type.GREATER, true, true, ExecType.CP); - } - - @Test - public void testPPredLessZeroSparseCP() - { - runPPredTest(Type.LESS, true, true, ExecType.CP); - } - - @Test - public void testPPredEqualsZeroSparseCP() - { - runPPredTest(Type.EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredNotEqualsZeroSparseCP() - { - runPPredTest(Type.NOT_EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsZeroSparseCP() - { - runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredLessEqualsZeroSparseCP() - { - runPPredTest(Type.LESS_EQUALS, true, true, ExecType.CP); - } - - @Test - public void testPPredGreaterNonZeroSparseCP() - { - runPPredTest(Type.GREATER, false, true, ExecType.CP); - } - - @Test - public void testPPredLessNonZeroSparseCP() - { - runPPredTest(Type.LESS, false, true, ExecType.CP); - } - - @Test - public void testPPredEqualsNonZeroSparseCP() - { - runPPredTest(Type.EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredNotEqualsNonZeroSparseCP() - { - runPPredTest(Type.NOT_EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredGreaterEqualsNonZeroSparseCP() - { - runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredLessEqualsNonZeroSparseCP() - { - runPPredTest(Type.LESS_EQUALS, false, true, ExecType.CP); - } - - @Test - public void testPPredGreaterZeroDenseMR() - { - runPPredTest(Type.GREATER, true, false, ExecType.MR); - } - - @Test - public void testPPredLessZeroDenseMR() - { - runPPredTest(Type.LESS, true, false, ExecType.MR); - } - - @Test - public void testPPredEqualsZeroDenseMR() - { - runPPredTest(Type.EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredNotEqualsZeroDenseMR() - { - runPPredTest(Type.NOT_EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsZeroDenseMR() - { - runPPredTest(Type.GREATER_EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredLessEqualsZeroDenseMR() - { - runPPredTest(Type.LESS_EQUALS, true, false, ExecType.MR); - } - - @Test - public void testPPredGreaterNonZeroDenseMR() - { - runPPredTest(Type.GREATER, false, false, ExecType.MR); - } - - @Test - public void testPPredLessNonZeroDenseMR() - { - runPPredTest(Type.LESS, false, false, ExecType.MR); - } - - @Test - public void testPPredEqualsNonZeroDenseMR() - { - runPPredTest(Type.EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredNotEqualsNonZeroDenseMR() - { - runPPredTest(Type.NOT_EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsNonZeroDenseMR() - { - runPPredTest(Type.GREATER_EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredLessEqualsNonZeroDenseMR() - { - runPPredTest(Type.LESS_EQUALS, false, false, ExecType.MR); - } - - @Test - public void testPPredGreaterZeroSparseMR() - { - runPPredTest(Type.GREATER, true, true, ExecType.MR); - } - - @Test - public void testPPredLessZeroSparseMR() - { - runPPredTest(Type.LESS, true, true, ExecType.MR); - } - - @Test - public void testPPredEqualsZeroSparseMR() - { - runPPredTest(Type.EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredNotEqualsZeroSparseMR() - { - runPPredTest(Type.NOT_EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsZeroSparseMR() - { - runPPredTest(Type.GREATER_EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredLessEqualsZeroSparseMR() - { - runPPredTest(Type.LESS_EQUALS, true, true, ExecType.MR); - } - - @Test - public void testPPredGreaterNonZeroSparseMR() - { - runPPredTest(Type.GREATER, false, true, ExecType.MR); - } - - @Test - public void testPPredLessNonZeroSparseMR() - { - runPPredTest(Type.LESS, false, true, ExecType.MR); - } - - @Test - public void testPPredEqualsNonZeroSparseMR() - { - runPPredTest(Type.EQUALS, false, true, ExecType.MR); - } - - @Test - public void testPPredNotEqualsNonZeroSparseMR() - { - runPPredTest(Type.NOT_EQUALS, false, true, ExecType.MR); - } - - @Test - public void testPPredGreaterEqualsNonZeroSparseMR() - { - runPPredTest(Type.GREATER_EQUALS, false, true, ExecType.MR); - } - - @Test - public void testPPredLessEqualsNonZeroSparseMR() - { - runPPredTest(Type.LESS_EQUALS, false, true, ExecType.MR); - } - - - /** - * - * @param type - * @param instType - * @param sparse - */ - private void runPPredTest( Type type, boolean zero, boolean sparse, ExecType et ) - { - String TEST_NAME = TEST_NAME1; - int rows = rows1; - int cols = cols1; - double sparsity = sparse ? sparsity2 : sparsity1; - double constant = zero ? 0 : 0.5; - - String TEST_CACHE_DIR = ""; - if (TEST_CACHE_ENABLED) { - TEST_CACHE_DIR = type.ordinal() + "_" + constant + "_" + sparsity + "/"; - } - - //rtplatform for MR - RUNTIME_PLATFORM platformOld = rtplatform; - rtplatform = (et==ExecType.MR) ? RUNTIME_PLATFORM.HADOOP : RUNTIME_PLATFORM.HYBRID; - - try - { - TestConfiguration config = getTestConfiguration(TEST_NAME); - loadTestConfiguration(config, TEST_CACHE_DIR); - - /* This is for running the junit test the new way, i.e., construct the arguments directly */ - String HOME = SCRIPT_DIR + TEST_DIR; - fullDMLScriptName = HOME + TEST_NAME + ".dml"; - programArgs = new String[]{"-args", input("A"), - Integer.toString(type.ordinal()), Double.toString(constant), output("B") }; - - fullRScriptName = HOME + TEST_NAME + ".R"; - rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + - type.ordinal() + " " + constant + " " + expectedDir(); - - //generate actual dataset - double[][] A = getRandomMatrix(rows, cols, -1, 1, sparsity, 7); - writeInputMatrixWithMTD("A", A, true); - - //run tests - runTest(true, false, null, -1); - runRScript(true); - - //compare matrices - HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("B"); - HashMap<CellIndex, Double> rfile = readRMatrixFromFS("B"); - TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R"); - } - finally - { - rtplatform = platformOld; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/java/org/apache/sysml/test/integration/functions/ternary/CTableMatrixIgnoreZerosTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/ternary/CTableMatrixIgnoreZerosTest.java b/src/test/java/org/apache/sysml/test/integration/functions/ternary/CTableMatrixIgnoreZerosTest.java index 75c5330..14464bb 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/ternary/CTableMatrixIgnoreZerosTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/ternary/CTableMatrixIgnoreZerosTest.java @@ -35,7 +35,7 @@ import org.apache.sysml.test.utils.TestUtils; /** * This test investigates the specific Hop-Lop rewrite for the following pattern: * - * IA = ppred (A, 0, "!=") * seq (1, nrow (A), 1); + * IA = (A != 0) * seq (1, nrow (A), 1); * IA = matrix (IA, rows = (nrow (A) * ncol(A)), cols = 1, byrow = FALSE); * VA = matrix ( A, rows = (nrow (A) * ncol(A)), cols = 1, byrow = FALSE); * IA = removeEmpty (target = IA, margin = "rows"); http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/scripts/applications/apply-transform/apply-transform.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/applications/apply-transform/apply-transform.dml b/src/test/scripts/applications/apply-transform/apply-transform.dml index 5110cb0..2c9d0ca 100644 --- a/src/test/scripts/applications/apply-transform/apply-transform.dml +++ b/src/test/scripts/applications/apply-transform/apply-transform.dml @@ -119,8 +119,8 @@ parfor(i in 1:ncol(X), check=0){ # note that max_val entries will get assigned num_bins+1 col = round((col - min_val)/bin_width - 0.5) + 1 - less_than_lb = ppred(col, 1, "<") - more_than_ub = ppred(col, num_bins, ">") + less_than_lb = (col < 1) + more_than_ub = (col > num_bins) col = (1 - less_than_lb - more_than_ub)*col + more_than_ub*num_bins + less_than_lb } http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/scripts/applications/apply-transform/apply-transform.pydml ---------------------------------------------------------------------- diff --git a/src/test/scripts/applications/apply-transform/apply-transform.pydml b/src/test/scripts/applications/apply-transform/apply-transform.pydml index d528098..84d8779 100644 --- a/src/test/scripts/applications/apply-transform/apply-transform.pydml +++ b/src/test/scripts/applications/apply-transform/apply-transform.pydml @@ -116,8 +116,8 @@ parfor(i in 1:ncol(X), check=0): # note that max_val entries will get assigned num_bins+1 col = round((col - min_val)/bin_width - 0.5) + 1 - less_than_lb = ppred(col, 1, "<") - more_than_ub = ppred(col, num_bins, ">") + less_than_lb = (col < 1) + more_than_ub = (col > num_bins) col = (1 - less_than_lb - more_than_ub)*col + more_than_ub*num_bins + less_than_lb http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/scripts/applications/arima_box-jenkins/arima.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/applications/arima_box-jenkins/arima.dml b/src/test/scripts/applications/arima_box-jenkins/arima.dml index e21b75e..188aaa2 100644 --- a/src/test/scripts/applications/arima_box-jenkins/arima.dml +++ b/src/test/scripts/applications/arima_box-jenkins/arima.dml @@ -65,7 +65,7 @@ arima_css = function(Matrix[Double] w, Matrix[Double] X, Integer pIn, Integer P, iter = 0 if(useJacobi == 1){ - check = sum(ppred(rowSums(abs(R)), 1, ">=")) + check = sum(rowSums(abs(R)) >= 1) if(check > 0){ print("R is not diagonal dominant. Suggest switching to an exact solver.") } http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/scripts/applications/arima_box-jenkins/arima.pydml ---------------------------------------------------------------------- diff --git a/src/test/scripts/applications/arima_box-jenkins/arima.pydml b/src/test/scripts/applications/arima_box-jenkins/arima.pydml index d1299c9..2546ec4 100644 --- a/src/test/scripts/applications/arima_box-jenkins/arima.pydml +++ b/src/test/scripts/applications/arima_box-jenkins/arima.pydml @@ -62,7 +62,7 @@ def arima_css(w:matrix[float], X:matrix[float], pIn: int, P: int, qIn: int, Q:in iter = 0 if(useJacobi == 1): - check = sum(ppred(rowSums(abs(R)), 1, ">=")) + check = sum(rowSums(abs(R)) >= 1) if(check > 0): print("R is not diagonal dominant. Suggest switching to an exact solver.") diff = tol+1.0 http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/scripts/applications/cspline/CsplineCG.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/applications/cspline/CsplineCG.dml b/src/test/scripts/applications/cspline/CsplineCG.dml index 2281270..8193561 100644 --- a/src/test/scripts/applications/cspline/CsplineCG.dml +++ b/src/test/scripts/applications/cspline/CsplineCG.dml @@ -167,7 +167,7 @@ interpSpline = function( ) return (double q) { #first find the right knots for interpolation - i = as.integer(nrow(X) - sum(ppred(X, x, ">=")) + 1) + i = as.integer(nrow(X) - sum(X >= x) + 1) #calc the y as per the algo docs t = (x - X[i-1,1]) / ( X[i,1] - X[i-1,1]) http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/scripts/applications/cspline/CsplineCG.pydml ---------------------------------------------------------------------- diff --git a/src/test/scripts/applications/cspline/CsplineCG.pydml b/src/test/scripts/applications/cspline/CsplineCG.pydml index 8e84f14..9451fb9 100644 --- a/src/test/scripts/applications/cspline/CsplineCG.pydml +++ b/src/test/scripts/applications/cspline/CsplineCG.pydml @@ -145,7 +145,7 @@ def calcKnotsDerivKs(X: matrix[float], Y: matrix[float], max_iteration: int, tol def interpSpline(x: float, X: matrix[float], Y: matrix[float], K: matrix[float]) -> (q: float): #first find the right knots for interpolation - i = nrow(X) - sum(ppred(X, x, ">=")) + 1 + i = nrow(X) - sum(X >= x) + 1 #calc the y as per the algo docs t = (x - X[i-2,0]) / ( X[i-1,0] - X[i-2,0]) http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/scripts/applications/cspline/CsplineDS.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/applications/cspline/CsplineDS.dml b/src/test/scripts/applications/cspline/CsplineDS.dml index ff34b5e..d81c215 100644 --- a/src/test/scripts/applications/cspline/CsplineDS.dml +++ b/src/test/scripts/applications/cspline/CsplineDS.dml @@ -142,7 +142,7 @@ interpSpline = function( ) return (double q) { #first find the right knots for interpolation - i = as.integer(nrow(X) - sum(ppred(X, x, ">=")) + 1) + i = as.integer(nrow(X) - sum(X >= x) + 1) #calc the y as per the algo docs t = (x - X[i-1,1]) / ( X[i,1] - X[i-1,1]) http://git-wip-us.apache.org/repos/asf/systemml/blob/d30e1888/src/test/scripts/applications/cspline/CsplineDS.pydml ---------------------------------------------------------------------- diff --git a/src/test/scripts/applications/cspline/CsplineDS.pydml b/src/test/scripts/applications/cspline/CsplineDS.pydml index dc16661..0efc681 100644 --- a/src/test/scripts/applications/cspline/CsplineDS.pydml +++ b/src/test/scripts/applications/cspline/CsplineDS.pydml @@ -124,7 +124,7 @@ def calcKnotsDerivKs(X: matrix[float], Y: matrix[float]) -> (K: matrix[float]): def interpSpline(x: float, X: matrix[float], Y: matrix[float], K: matrix[float]) -> (q: float): #first find the right knots for interpolation - i = nrow(X) - sum(ppred(X, x, ">=")) + 1 + i = nrow(X) - sum(X >= x) + 1 #calc the y as per the algo docs t = (x - X[i-2,0]) / ( X[i-1,0] - X[i-2,0])