diff --git a/src/main/java/org/apache/sysds/runtime/matrix/data/MatrixBlock.java b/src/main/java/org/apache/sysds/runtime/matrix/data/MatrixBlock.java index 18bc30094c6..7525dab2f7f 100644 --- a/src/main/java/org/apache/sysds/runtime/matrix/data/MatrixBlock.java +++ b/src/main/java/org/apache/sysds/runtime/matrix/data/MatrixBlock.java @@ -4782,10 +4782,10 @@ public MatrixBlock pickValues(MatrixValue quantiles, MatrixValue ret, boolean av output=new MatrixBlock(qs.rlen, qs.clen, false); // resulting matrix is mostly likely be dense else output.reset(qs.rlen, qs.clen, false); - - for ( int i=0; i < qs.rlen; i++ ) { - // FIXME: [SYSTEMDS-3953] consider the average parameter here - output.set(i, 0, this.pickValue(qs.get(i,0)) ); + + for(int i = 0; i < qs.rlen; i++) { + // FIXME: include the average parameter here to fix SYSTEMDS-3953 + output.set(i, 0, this.pickValue(qs.get(i, 0))); } return output; diff --git a/src/test/java/org/apache/sysds/test/functions/binary/matrix/QuantileTest.java b/src/test/java/org/apache/sysds/test/functions/binary/matrix/QuantileTest.java index 489b31080ef..810e2614e7c 100644 --- a/src/test/java/org/apache/sysds/test/functions/binary/matrix/QuantileTest.java +++ b/src/test/java/org/apache/sysds/test/functions/binary/matrix/QuantileTest.java @@ -21,6 +21,7 @@ import java.util.HashMap; +import org.junit.Ignore; import org.junit.Test; import org.apache.sysds.common.Types.ExecMode; import org.apache.sysds.common.Types.ExecType; @@ -36,6 +37,7 @@ public class QuantileTest extends AutomatedTestBase private final static String TEST_NAME3 = "IQM"; private final static String TEST_NAME4 = "QuantileBug"; private final static String TEST_NAME5 = "MedianBug"; + private final static String TEST_NAME6 = "QuartileArray"; private final static String TEST_DIR = "functions/binary/matrix/"; private final static String TEST_CLASS_DIR = TEST_DIR + QuantileTest.class.getSimpleName() + "/"; @@ -51,15 +53,17 @@ public void setUp() { TestUtils.clearAssertionInformation(); addTestConfiguration(TEST_NAME1, - new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "R" }) ); + new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] {"R"})); addTestConfiguration(TEST_NAME2, - new TestConfiguration(TEST_CLASS_DIR, TEST_NAME2, new String[] { "R" }) ); + new TestConfiguration(TEST_CLASS_DIR, TEST_NAME2, new String[] {"R"})); addTestConfiguration(TEST_NAME3, - new TestConfiguration(TEST_CLASS_DIR, TEST_NAME3, new String[] { "R" }) ); + new TestConfiguration(TEST_CLASS_DIR, TEST_NAME3, new String[] {"R"})); addTestConfiguration(TEST_NAME4, - new TestConfiguration(TEST_CLASS_DIR, TEST_NAME4, new String[] { "R" }) ); + new TestConfiguration(TEST_CLASS_DIR, TEST_NAME4, new String[] {"R"})); addTestConfiguration(TEST_NAME5, - new TestConfiguration(TEST_CLASS_DIR, TEST_NAME5, new String[] { "R" }) ); + new TestConfiguration(TEST_CLASS_DIR, TEST_NAME5, new String[] {"R"})); + addTestConfiguration(TEST_NAME6, + new TestConfiguration(TEST_CLASS_DIR, TEST_NAME6, new String[] {"R"})); } @Test @@ -182,6 +186,18 @@ public void testMedianBugSP() { runQuantileTest(TEST_NAME5, -1, false, ExecType.SPARK); } + @Test + @Ignore // FIXME: fix SYSTEMDS-3953 + public void testQuartileArrayCP() { + runQuantileTest(TEST_NAME6, 0, false, ExecType.CP); + } + + @Test + @Ignore // FIXME: fix SYSTEMDS-3953 + public void testQuartileArraySP() { + runQuantileTest(TEST_NAME6, 0, false, ExecType.SPARK); + } + private void runQuantileTest( String TEST_NAME, double p, boolean sparse, ExecType et) { ExecMode platformOld = setExecMode(et); diff --git a/src/test/scripts/functions/binary/matrix/QuartileArray.R b/src/test/scripts/functions/binary/matrix/QuartileArray.R new file mode 100644 index 00000000000..3f4cff52597 --- /dev/null +++ b/src/test/scripts/functions/binary/matrix/QuartileArray.R @@ -0,0 +1,33 @@ +#------------------------------------------------------------- +# +# 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. +# +#------------------------------------------------------------- + +args <- commandArgs(TRUE) +options(digits=22) + +library("Matrix") + +A = as.matrix(c(1,5,7,10)) + +m = quantile(A, c(0.25, 0.5, 0.75)); + +writeMM(as(m, "CsparseMatrix"), paste(args[3], "R", sep="")); + + diff --git a/src/test/scripts/functions/binary/matrix/QuartileArray.dml b/src/test/scripts/functions/binary/matrix/QuartileArray.dml new file mode 100644 index 00000000000..a63ac8f0cbc --- /dev/null +++ b/src/test/scripts/functions/binary/matrix/QuartileArray.dml @@ -0,0 +1,24 @@ +#------------------------------------------------------------- +# +# 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. +# +#------------------------------------------------------------- + +A = as.matrix(list(1,5,7,10)); +m = quantile(A, as.matrix(list(0.25, 0.5, 0.75))); +write(m, $3, format="text");