This is an automated email from the ASF dual-hosted git repository. mboehm7 pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/main by this push: new af68796b5b [SYSTEMDS-3639] Added new SliceLine tests, prep for incSliceLine af68796b5b is described below commit af68796b5bf5093e8bdf55012486d2858de9e2aa Author: Frederic Zoepffel <f.zoepf...@gmail.com> AuthorDate: Mon Apr 22 20:32:12 2024 +0200 [SYSTEMDS-3639] Added new SliceLine tests, prep for incSliceLine Closes #2021. --- .../builtin/part2/BuiltinSliceFinderTest.java | 188 +++++++++++++++++++++ 1 file changed, 188 insertions(+) diff --git a/src/test/java/org/apache/sysds/test/functions/builtin/part2/BuiltinSliceFinderTest.java b/src/test/java/org/apache/sysds/test/functions/builtin/part2/BuiltinSliceFinderTest.java index 127105d3f8..d30cd1a240 100644 --- a/src/test/java/org/apache/sysds/test/functions/builtin/part2/BuiltinSliceFinderTest.java +++ b/src/test/java/org/apache/sysds/test/functions/builtin/part2/BuiltinSliceFinderTest.java @@ -146,6 +146,163 @@ public class BuiltinSliceFinderTest extends AutomatedTestBase public void testTop10SinglenodeTPSelE2() { runSliceFinderTest(10, "oe", false, true, ExecMode.SINGLE_NODE); } + + @Test + public void testSlicefinderCustomInputs1() { + double[][] X = { + {2, 1, 1, 2, 3, 2, 3, 3, 1, 2}, + {2, 2, 2, 3, 4, 1, 2, 1, 3, 2}, + {2, 1, 3, 3, 2, 2, 3, 1, 1, 4}, + {1, 2, 2, 1, 3, 2, 3, 2, 2, 3}, + {3, 2, 3, 4, 3, 3, 4, 1, 1, 3}, + {4, 3, 2, 3, 4, 4, 3, 4, 1, 1}, + {2, 2, 2, 4, 3, 3, 2, 2, 1, 2}, + {1, 1, 2, 2, 3, 3, 2, 1, 1, 2}, + {4, 3, 2, 1, 3, 2, 4, 2, 4, 3}, + {1, 3, 1, 4, 1, 3, 3, 2, 3, 2}, + {2, 4, 3, 1, 2, 4, 1, 3, 2, 4}, + {3, 2, 4, 3, 1, 4, 2, 3, 4, 1}, + {4, 1, 2, 4, 3, 1, 4, 2, 1, 3}, + {1, 3, 4, 2, 4, 3, 1, 4, 2, 3}, + {2, 4, 1, 3, 2, 4, 3, 1, 4, 2}, + {3, 2, 4, 1, 3, 4, 2, 3, 1, 4}, + {4, 1, 3, 2, 4, 1, 4, 2, 3, 1}, + {1, 3, 2, 4, 1, 3, 4, 2, 4, 3}, + {2, 4, 1, 3, 2, 4, 3, 1, 2, 4}, + {2, 3, 3, 2, 1, 4, 2, 3, 2, 3} + }; + double[][] e = { + {0.159}, {0.588}, {0.414}, {0.305}, {0.193}, {0.195}, {0.878}, {0.149}, {0.835}, {0.344}, + {0.123}, {0.456}, {0.789}, {0.987}, {0.654}, {0.321}, {0.246}, {0.135}, {0.579}, {0.802} + }; + int K = 10; + double[][] correctRes = { + {0.307, 2.807, 0.878, 4.000}, + {0.307, 2.807, 0.878, 4.000}, + {0.282, 2.759, 0.987, 4.000}, + {0.157, 4.046, 0.987, 7.000}, + {0.127, 2.956, 0.878, 5.000}, + {0.122, 2.942, 0.878, 5.000}, + {0.074, 3.298, 0.987, 6.000}, + {0.064, 4.197, 0.878, 8.000}, + {0.061, 2.796, 0.987, 5.000}, + {0.038, 3.194, 0.878, 6.000} + }; + testSlicefinderCustomInputs(X, e, K, correctRes); + } + + @Test + public void testSlicefinderCustomInputs2() { + double[][] X = { + {2, 1, 1, 1, 3, 4, 2, 2, 1, 2}, + {3, 3, 3, 2, 1, 2, 3, 1, 4, 2}, + {3, 2, 3, 1, 1, 1, 4, 3, 4, 2}, + {1, 3, 2, 3, 2, 3, 2, 1, 2, 1}, + {4, 3, 1, 1, 1, 1, 1, 1, 3, 2}, + {2, 2, 3, 3, 2, 2, 2, 3, 4, 1}, + {3, 2, 2, 2, 4, 4, 2, 4, 1, 1}, + {1, 3, 3, 2, 1, 3, 1, 2, 4, 4}, + {2, 1, 2, 2, 3, 1, 2, 3, 2, 1}, + {4, 1, 3, 4, 1, 4, 2, 3, 4, 4}, + {4, 2, 4, 4, 2, 1, 2, 1, 1, 4}, + {4, 1, 1, 4, 1, 4, 3, 2, 4, 2}, + {2, 1, 2, 2, 3, 1, 4, 3, 3, 4}, + {4, 1, 3, 1, 3, 1, 2, 1, 3, 3}, + {2, 1, 3, 1, 1, 3, 1, 2, 1, 2}, + {1, 3, 4, 3, 1, 2, 2, 2, 1, 1}, + {2, 4, 4, 3, 4, 1, 2, 1, 2, 4}, + {3, 3, 3, 3, 3, 1, 2, 3, 4, 4}, + {3, 2, 2, 2, 4, 1, 4, 2, 3, 1}, + {1, 2, 3, 2, 4, 3, 2, 3, 2, 3} + }; + + double[][] e = { + {0.591}, {0.858}, {0.144}, {0.350}, {0.931}, {0.951}, {0.788}, {0.491}, {0.358}, {0.443}, + {0.231}, {0.564}, {0.897}, {0.879}, {0.546}, {0.132}, {0.462}, {0.153}, {0.759}, {0.028} + }; + int K = 10; + double[][] correctRes = { + {0.410, 3.466, 0.931, 4.000}, + {0.410, 3.466, 0.931, 4.000}, + {0.111, 2.802, 0.897, 4.000}, + {0.075, 3.805, 0.951, 6.000}, + {0.057, 4.278, 0.897, 7.000}, + {0.047, 3.711, 0.931, 6.000}, + {0.035, 3.152, 0.897, 5.000}, + {0.032, 4.179, 0.897, 7.000}, + {0.023, 3.634, 0.931, 6.000}, + {0.013, 3.091, 0.931, 5.000} + }; + + testSlicefinderCustomInputs(X, e, K, correctRes); + } + + + @Test + public void testSlicefinderCustomInputs3() { + double[][] X = { + {2, 1, 1, 2, 3, 2, 3, 3, 1, 2}, + {2, 2, 2, 3, 4, 1, 2, 1, 3, 2}, + {2, 1, 3, 3, 2, 2, 3, 1, 1, 4}, + {1, 2, 2, 1, 3, 2, 3, 2, 2, 3}, + {3, 2, 3, 4, 3, 3, 4, 1, 1, 3}, + {4, 3, 2, 3, 4, 4, 3, 4, 1, 1}, + {2, 2, 2, 4, 3, 3, 2, 2, 1, 2}, + {1, 1, 2, 2, 3, 3, 2, 1, 1, 2}, + {4, 3, 2, 1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0.159}, {0.588}, {0.414}, {0.305}, {0.193}, {0.195}, {0.878}, {0.149}, {0.835}, {0.344}, + {0.123}, {0.456}, {0.789}, {0.987}, {0.654}, {0.321}, {0.246}, {0.135}, {0.579}, {0.802}, + {0.591}, {0.858}, {0.144}, {0.350}, {0.931}, {0.951}, {0.788}, {0.491}, {0.358}, {0.443}, + {0.231}, {0.564}, {0.897}, {0.879}, {0.546}, {0.132}, {0.462}, {0.153}, {0.759}, {0.028} + }; + int K = 10; + double[][] correctRes = { + {0.149, 4.300, 0.931, 6.000}, + {0.113, 3.138, 0.987, 4.000}, + {0.093, 4.644, 0.931, 7.000}, + {0.090, 4.630, 0.951, 7.000}, + {0.059, 8.002, 0.951, 14.000}, + {0.024, 2.954, 0.951, 4.000}, + {0.017, 3.415, 0.897, 5.000}, + {0.010, 3.398, 0.878, 5.000}, + {0.009, 2.923, 0.897, 4.000}, + {0.008, 3.391, 0.897, 5.000} + }; + testSlicefinderCustomInputs(X, e, K, correctRes); + } // @Test // public void testTop10SparkTP() { @@ -204,4 +361,35 @@ public class BuiltinSliceFinderTest extends AutomatedTestBase rtplatform = platformOld; } } + + public void testSlicefinderCustomInputs(double[][] X, double[][] e, int K, double[][] correctRes) { + boolean dp = true, selCols = false; + ExecMode mode = ExecMode.SINGLE_NODE; + ExecMode platformOld = setExecMode(mode); + loadTestConfiguration(getTestConfiguration(TEST_NAME)); + String HOME = SCRIPT_DIR + TEST_DIR; + + try { + loadTestConfiguration(getTestConfiguration(TEST_NAME)); + + writeInputMatrixWithMTD("X", X, false); + writeInputMatrixWithMTD("e", e, false); + + fullDMLScriptName = HOME + TEST_NAME + ".dml"; + programArgs = new String[]{"-args", input("X"), input("e"), String.valueOf(K), + String.valueOf(!dp).toUpperCase(), String.valueOf(selCols).toUpperCase(), + String.valueOf(VERBOSE).toUpperCase(), output("R")}; + + runTest(true, false, null, -1); + + HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromOutputDir("R"); + double[][] ret = TestUtils.convertHashMapToDoubleArray(dmlfile); + TestUtils.compareMatrices(correctRes, ret, 1e-2); + + Assert.assertFalse(heavyHittersContainsSubString("evalSlice")); + } + finally { + rtplatform = platformOld; + } + } }