This is an automated email from the ASF dual-hosted git repository.

markd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/master by this push:
     new 3411672  [SYSTEMDS-151] Removing deprecation in test code
3411672 is described below

commit 34116722d908dc5dec172104ab3a6efdfb71a8bc
Author: Mark Dokter <[email protected]>
AuthorDate: Mon Nov 2 17:46:06 2020 +0100

    [SYSTEMDS-151] Removing deprecation in test code
    
    Resolving JIRA issue https://issues.apache.org/jira/browse/SYSTEMDS-151
---
 .../org/apache/sysds/test/AutomatedTestBase.java   | 20 ----------
 src/test/java/org/apache/sysds/test/TestUtils.java | 44 ++++++++++++----------
 .../parfor/misc/ParForAdversarialLiteralsTest.java | 11 ++----
 3 files changed, 28 insertions(+), 47 deletions(-)

diff --git a/src/test/java/org/apache/sysds/test/AutomatedTestBase.java 
b/src/test/java/org/apache/sysds/test/AutomatedTestBase.java
index d802997..3c3b85b 100644
--- a/src/test/java/org/apache/sysds/test/AutomatedTestBase.java
+++ b/src/test/java/org/apache/sysds/test/AutomatedTestBase.java
@@ -94,7 +94,6 @@ import org.junit.Before;
  * </ul>
  *
  */
-@SuppressWarnings("deprecation")
 public abstract class AutomatedTestBase {
 
        private static final Log LOG = 
LogFactory.getLog(AutomatedTestBase.class.getName());
@@ -997,25 +996,6 @@ public abstract class AutomatedTestBase {
        }
 
        /**
-        * <p>
-        * Loads a test configuration with its parameters. Adds the output 
directories to the output list as well as to the
-        * list of possible comparison files.
-        * </p>
-        *
-        * @param configurationName test configuration name
-        *
-        */
-       @Deprecated
-       protected void loadTestConfiguration(String configurationName) {
-               if(!availableTestConfigurations.containsKey(configurationName))
-                       fail("test configuration not available: " + 
configurationName);
-
-               TestConfiguration config = 
availableTestConfigurations.get(configurationName);
-
-               loadTestConfiguration(config);
-       }
-
-       /**
         * Runs an R script, default to the old way
         */
        protected void runRScript() {
diff --git a/src/test/java/org/apache/sysds/test/TestUtils.java 
b/src/test/java/org/apache/sysds/test/TestUtils.java
index 6a7d8e6..1755e89 100644
--- a/src/test/java/org/apache/sysds/test/TestUtils.java
+++ b/src/test/java/org/apache/sysds/test/TestUtils.java
@@ -60,6 +60,7 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.SequenceFile;
+import org.apache.hadoop.io.SequenceFile.Writer;
 import org.apache.sysds.common.Types.FileFormat;
 import org.apache.sysds.common.Types.ValueType;
 import org.apache.sysds.runtime.data.TensorBlock;
@@ -461,11 +462,12 @@ public class TestUtils
 
        /**
         * Reads values from a matrix file in HDFS in DML format
-        * 
-        * @deprecated You should not use this method, it is recommended to use 
the
-        *             corresponding method in AutomatedTestBase
-        * @param filePath
-        * @return
+        *
+        * NOTE: For reading the output of a matrix produced by a JUnit test, 
use the convenience
+        *       function {@link 
AutomatedTestBase#readDMLMatrixFromHDFS(String)}
+        *
+        * @param filePath Path to the file to be read.
+        * @return Matrix values in a hashmap <index,value>
         */
        public static HashMap<CellIndex, Double> readDMLMatrixFromHDFS(String 
filePath) 
        {
@@ -491,12 +493,12 @@ public class TestUtils
 
        /**
         * Reads values from a matrix file in OS's FS in R format
-        * 
-        * @deprecated You should not use this method, it is recommended to use 
the
-        *             corresponding method in AutomatedTestBase
-        * 
-        * @param filePath
-        * @return
+        *
+        * NOTE: For reading the output of a matrix produced by a R validation 
code of a JUnit test, use the convenience
+        *       function {@link AutomatedTestBase#readRMatrixFromFS(String)}
+        *
+        * @param filePath Path to the file to be read.
+        * @return Matrix values in a hashmap <index,value>
         */
        public static HashMap<CellIndex, Double> readRMatrixFromFS(String 
filePath) 
        {
@@ -2083,10 +2085,11 @@ public class TestUtils
                        SequenceFile.Writer writer = null;
                        try {
                                Path path = new Path(file);
-                               FileSystem fs = 
IOUtilFunctions.getFileSystem(path, conf);
-                               writer = new SequenceFile.Writer(fs, conf, path,
-                                       MatrixIndexes.class, MatrixCell.class);
-
+                               Writer.Option filePath = Writer.file(path);
+                               Writer.Option keyClass = 
Writer.keyClass(MatrixIndexes.class);
+                               Writer.Option valueClass = 
Writer.valueClass(MatrixBlock.class);
+                               Writer.Option compression = 
Writer.compression(SequenceFile.CompressionType.NONE);
+                               writer = SequenceFile.createWriter(conf, 
filePath, keyClass, valueClass, compression);
                                MatrixIndexes index = new MatrixIndexes();
                                MatrixCell value = new MatrixCell();
                                for (int i = 0; i < matrix.length; i++) {
@@ -2131,10 +2134,11 @@ public class TestUtils
                        
                try {
                        Path path = new Path(file);
-                       FileSystem fs = IOUtilFunctions.getFileSystem(path, 
conf);
-                       writer = new SequenceFile.Writer(fs, conf, path,
-                                       MatrixIndexes.class, MatrixBlock.class);
-
+                       Writer.Option filePath = Writer.file(path);
+                       Writer.Option keyClass = 
Writer.keyClass(MatrixIndexes.class);
+                       Writer.Option valueClass = 
Writer.valueClass(MatrixBlock.class);
+                       Writer.Option compression = 
Writer.compression(SequenceFile.CompressionType.NONE);
+                       writer = SequenceFile.createWriter(conf, filePath, 
keyClass, valueClass, compression);
                        MatrixIndexes index = new MatrixIndexes();
                        MatrixBlock value = new MatrixBlock();
                        for (int i = 0; i < matrix.length; i += rowsInBlock) {
@@ -2142,7 +2146,7 @@ public class TestUtils
                                for (int j = 0; j < matrix[i].length; j += 
colsInBlock) {
                                        int cols = Math.min(colsInBlock, 
(matrix[i].length - j));
                                        index.setIndexes(((i / rowsInBlock) + 
1), ((j / colsInBlock) + 1));
-                                       value = new MatrixBlock(rows, cols, 
sparseFormat);
+                                       value.reset(rows, cols, sparseFormat);
                                        for (int k = 0; k < rows; k++) {
                                                for (int l = 0; l < cols; l++) {
                                                        value.setValue(k, l, 
matrix[i + k][j + l]);
diff --git 
a/src/test/java/org/apache/sysds/test/functions/parfor/misc/ParForAdversarialLiteralsTest.java
 
b/src/test/java/org/apache/sysds/test/functions/parfor/misc/ParForAdversarialLiteralsTest.java
index cbd755b..afeab47 100644
--- 
a/src/test/java/org/apache/sysds/test/functions/parfor/misc/ParForAdversarialLiteralsTest.java
+++ 
b/src/test/java/org/apache/sysds/test/functions/parfor/misc/ParForAdversarialLiteralsTest.java
@@ -100,11 +100,9 @@ public class ParForAdversarialLiteralsTest extends 
AutomatedTestBase
                runLiteralTest(TEST_NAME4b);
        }
 
-       @SuppressWarnings("deprecation")
        private void runLiteralTest( String testName )
        {
-               String TEST_NAME = testName;
-               TestConfiguration config = getTestConfiguration(TEST_NAME);
+               TestConfiguration config = getTestConfiguration(testName);
                config.addVariable("rows", rows);
                config.addVariable("cols", cols);
                loadTestConfiguration(config);
@@ -114,18 +112,17 @@ public class ParForAdversarialLiteralsTest extends 
AutomatedTestBase
                String IN = "A";
                String OUT = 
(testName.equals(TEST_NAME1a)||testName.equals(TEST_NAME1b))?Lop.CP_ROOT_THREAD_ID:"B";
 
-               fullDMLScriptName = HOME + TEST_NAME + ".dml";
+               fullDMLScriptName = HOME + testName + ".dml";
                programArgs = new String[]{"-args", input(IN),
                        Integer.toString(rows), Integer.toString(cols), 
output(OUT) };
                
-               fullRScriptName = HOME + TEST_NAME + ".R";
+               fullRScriptName = HOME + testName + ".R";
                rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " 
" + expectedDir();
                
                double[][] A = getRandomMatrix(rows, cols, 0, 1, sparsity, 7);
                writeInputMatrix("A", A, false);
 
-               boolean exceptionExpected = false;
-               runTest(true, exceptionExpected, null, -1);
+               runTest(true, false, null, -1);
                
                //compare matrices
                HashMap<CellIndex, Double> dmlin = 
TestUtils.readDMLMatrixFromHDFS(input(IN));

Reply via email to