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

baunsgaard 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 acf723e  [SYSTEMDS-3114] Replace on frames
acf723e is described below

commit acf723e7c06f0629ce3f9e287a9c035b08d173a3
Author: OlgaOvcharenko <[email protected]>
AuthorDate: Wed Sep 8 16:51:11 2021 +0200

    [SYSTEMDS-3114] Replace on frames
    
    This commit expands upon the support for replace on frames,
    it also include more extended tests, to verify the different value types,
    that can be contained in the frames.
    It also adds support for the federated version of replace.
    
    Closes #1389
---
 src/main/java/org/apache/sysds/common/Types.java   |   3 +
 .../cp/ParameterizedBuiltinCPInstruction.java      |   2 +-
 .../fed/ParameterizedBuiltinFEDInstruction.java    |   6 +-
 .../sysds/runtime/matrix/data/FrameBlock.java      |  23 ++-
 .../apache/sysds/runtime/util/UtilFunctions.java   |   4 +
 .../federated/primitives/FederatedReplaceTest.java | 161 +++++++++++++++++++++
 .../test/functions/frame/FrameReplaceTest.java     |  17 ++-
 .../privacy/algorithms/FederatedL2SVMTest.java     |  27 ++--
 .../FederatedReplaceTest.dml}                      |  25 +++-
 .../FederatedReplaceTestReference.dml}             |  19 ++-
 src/test/scripts/functions/frame/ReplaceTest.dml   |  14 +-
 .../intermediates/classification/bestAcc.csv.mtd   |  12 ++
 .../classification/dirtyScore.csv.mtd              |   7 +
 .../intermediates/classification/evalHp.csv.mtd    |  12 ++
 .../intermediates/classification/featureFrame.csv  |   1 +
 .../classification/featureFrame.csv.mtd            |  11 ++
 .../intermediates/classification/hp.csv.mtd        |  12 ++
 .../intermediates/classification/lp.csv.mtd        |  11 ++
 .../intermediates/classification/pip.csv.mtd       |  11 ++
 19 files changed, 331 insertions(+), 47 deletions(-)

diff --git a/src/main/java/org/apache/sysds/common/Types.java 
b/src/main/java/org/apache/sysds/common/Types.java
index b5d1330..f631f18 100644
--- a/src/main/java/org/apache/sysds/common/Types.java
+++ b/src/main/java/org/apache/sysds/common/Types.java
@@ -114,6 +114,9 @@ public class Types
                                        throw new DMLRuntimeException("Unknown 
value type: "+value);
                        }
                }
+               public static boolean isSameTypeString(ValueType vt1, ValueType 
vt2) {
+                       return 
vt1.toExternalString().equals(vt2.toExternalString());
+               }
        }
        
        /**
diff --git 
a/src/main/java/org/apache/sysds/runtime/instructions/cp/ParameterizedBuiltinCPInstruction.java
 
b/src/main/java/org/apache/sysds/runtime/instructions/cp/ParameterizedBuiltinCPInstruction.java
index cbe9be0..ccced11 100644
--- 
a/src/main/java/org/apache/sysds/runtime/instructions/cp/ParameterizedBuiltinCPInstruction.java
+++ 
b/src/main/java/org/apache/sysds/runtime/instructions/cp/ParameterizedBuiltinCPInstruction.java
@@ -232,7 +232,7 @@ public class ParameterizedBuiltinCPInstruction extends 
ComputationCPInstruction
                                FrameBlock ret = 
target.replaceOperations(pattern, replacement);
                                ec.setFrameOutput(output.getName(), ret);
                                ec.releaseFrameInput(params.get("target"));
-                       }else{
+                       } else{
                                MatrixBlock target = 
ec.getMatrixInput(params.get("target"));
                                double pattern = 
Double.parseDouble(params.get("pattern"));
                                double replacement = 
Double.parseDouble(params.get("replacement"));
diff --git 
a/src/main/java/org/apache/sysds/runtime/instructions/fed/ParameterizedBuiltinFEDInstruction.java
 
b/src/main/java/org/apache/sysds/runtime/instructions/fed/ParameterizedBuiltinFEDInstruction.java
index e4d8c46..02d34a1 100644
--- 
a/src/main/java/org/apache/sysds/runtime/instructions/fed/ParameterizedBuiltinFEDInstruction.java
+++ 
b/src/main/java/org/apache/sysds/runtime/instructions/fed/ParameterizedBuiltinFEDInstruction.java
@@ -136,7 +136,7 @@ public class ParameterizedBuiltinFEDInstruction extends 
ComputationFEDInstructio
                if(opcode.equalsIgnoreCase("replace")) {
                        // similar to unary federated instructions, get 
federated input
                        // execute instruction, and derive federated output 
matrix
-                       MatrixObject mo = (MatrixObject) getTarget(ec);
+                       CacheableData mo = getTarget(ec);
                        FederatedRequest fr1 = 
FederationUtils.callInstruction(instString,
                                output,
                                new CPOperand[] {getTargetOperand()},
@@ -144,7 +144,9 @@ public class ParameterizedBuiltinFEDInstruction extends 
ComputationFEDInstructio
                        mo.getFedMapping().execute(getTID(), true, fr1);
 
                        // derive new fed mapping for output
-                       MatrixObject out = ec.getMatrixObject(output);
+                       CacheableData out = ec.getCacheableData(output);
+                       if(mo instanceof FrameObject)
+                               ((FrameObject)out).setSchema(((FrameObject) 
mo).getSchema());
                        
out.getDataCharacteristics().set(mo.getDataCharacteristics());
                        
out.setFedMapping(mo.getFedMapping().copyWithNewID(fr1.getID()));
                }
diff --git a/src/main/java/org/apache/sysds/runtime/matrix/data/FrameBlock.java 
b/src/main/java/org/apache/sysds/runtime/matrix/data/FrameBlock.java
index fce1b38..86bbdab 100644
--- a/src/main/java/org/apache/sysds/runtime/matrix/data/FrameBlock.java
+++ b/src/main/java/org/apache/sysds/runtime/matrix/data/FrameBlock.java
@@ -41,6 +41,7 @@ import java.util.function.Function;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.NotImplementedException;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.io.Writable;
@@ -2445,14 +2446,28 @@ public class FrameBlock implements CacheBlock, 
Externalizable {
                public String apply(String input1, String input2) {     return 
null;}
        }
 
-       public FrameBlock replaceOperations(String pattern, String replacement){
+       public <T> FrameBlock replaceOperations(String pattern, String 
replacement) {
                FrameBlock ret = new FrameBlock(this);
+
+               ValueType patternType = UtilFunctions.isBoolean(pattern) ? 
ValueType.BOOLEAN : (NumberUtils.isCreatable(pattern) ?
+                       (UtilFunctions.isIntegerNumber(pattern) ? 
ValueType.INT64 : ValueType.FP64) : ValueType.STRING);
+               ValueType replacementType = 
UtilFunctions.isBoolean(replacement) ? ValueType.BOOLEAN : 
(NumberUtils.isCreatable(replacement) ?
+                       (UtilFunctions.isIntegerNumber(replacement) ? 
ValueType.INT64 : ValueType.FP64) : ValueType.STRING);
+
+               if(patternType != replacementType || 
!ValueType.isSameTypeString(patternType, replacementType))
+                       throw new DMLRuntimeException("Pattern and replacement 
types should be same.");
+
                for(int i = 0; i < ret.getNumColumns(); i++){
                        Array colData = ret._coldata[i];
-                       for(int j = 0; j < colData._size; j++){
+                       for(int j = 0; j < colData._size && 
(ValueType.isSameTypeString(_schema[i], patternType) || _schema[i] == 
ValueType.STRING); j++) {
+                               T patternNew =  (T) 
UtilFunctions.stringToObject(_schema[i], pattern);
+                               T replacementNew = (T) 
UtilFunctions.stringToObject(_schema[i], replacement);
+
                                Object ent = colData.get(j);
-                               if(ent != null && ent.equals(pattern))
-                                       colData.set(j,replacement); 
+                               if(ent != null && 
ent.toString().equals(patternNew.toString()))
+                                       colData.set(j,replacementNew);
+                               else  if(ent instanceof String && 
ent.equals(pattern))
+                                       colData.set(j, replacement);
                        }
                }
                return ret;
diff --git a/src/main/java/org/apache/sysds/runtime/util/UtilFunctions.java 
b/src/main/java/org/apache/sysds/runtime/util/UtilFunctions.java
index 7431a82..ee6d913 100644
--- a/src/main/java/org/apache/sysds/runtime/util/UtilFunctions.java
+++ b/src/main/java/org/apache/sysds/runtime/util/UtilFunctions.java
@@ -589,6 +589,10 @@ public class UtilFunctions {
                }               
                return 0; //equal 
        }
+
+       public static boolean isBoolean(String str) {
+               return String.valueOf(true).equalsIgnoreCase(str) || 
String.valueOf(false).equalsIgnoreCase(str);
+       }
        
        public static boolean isIntegerNumber( String str ) {
                byte[] c = str.getBytes();
diff --git 
a/src/test/java/org/apache/sysds/test/functions/federated/primitives/FederatedReplaceTest.java
 
b/src/test/java/org/apache/sysds/test/functions/federated/primitives/FederatedReplaceTest.java
new file mode 100644
index 0000000..1e039c2
--- /dev/null
+++ 
b/src/test/java/org/apache/sysds/test/functions/federated/primitives/FederatedReplaceTest.java
@@ -0,0 +1,161 @@
+/*
+ * 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.sysds.test.functions.federated.primitives;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.sysds.api.DMLScript;
+import org.apache.sysds.common.Types.ExecMode;
+import org.apache.sysds.runtime.meta.MatrixCharacteristics;
+import org.apache.sysds.runtime.util.HDFSTool;
+import org.apache.sysds.test.AutomatedTestBase;
+import org.apache.sysds.test.TestConfiguration;
+import org.apache.sysds.test.TestUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(value = Parameterized.class)
[email protected]
+public class FederatedReplaceTest extends AutomatedTestBase {
+       private final static String TEST_NAME = "FederatedReplaceTest";
+
+       private final static String TEST_DIR = "functions/federated/";
+       private static final String TEST_CLASS_DIR = TEST_DIR + 
FederatedReplaceTest.class.getSimpleName() + "/";
+
+       private final static int blocksize = 1024;
+       @Parameterized.Parameter()
+       public int rows;
+       @Parameterized.Parameter(1)
+       public int cols;
+       @Parameterized.Parameter(2)
+       public boolean rowPartitioned;
+       @Parameterized.Parameter(3)
+       public boolean isFrame;
+
+       @Parameterized.Parameters
+       public static Collection<Object[]> data() {
+               return Arrays.asList(new Object[][] {
+                       {20, 12, true, true},
+                       {20, 12, false, true},
+                       {20, 12, true, false},
+                       {20, 12, false, false}
+               });
+       }
+
+       @Override
+       public void setUp() {
+               TestUtils.clearAssertionInformation();
+               addTestConfiguration(TEST_NAME, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME, new String[] {"S"}));
+       }
+
+       @Test
+       public void testReplaceCP() {
+               runAggregateOperationTest(ExecMode.SINGLE_NODE);
+       }
+
+       private void runAggregateOperationTest(ExecMode execMode) {
+               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
+               ExecMode platformOld = rtplatform;
+
+               if(rtplatform == ExecMode.SPARK)
+                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
+
+               getAndLoadTestConfiguration(TEST_NAME);
+               String HOME = SCRIPT_DIR + TEST_DIR;
+
+               // write input matrices
+               int r = rows;
+               int c = cols / 4;
+               if(rowPartitioned) {
+                       r = rows / 4;
+                       c = cols;
+               }
+
+               double[][] X1 = getRandomMatrix(r, c, 1, 5, 1, 3);
+               double[][] X2 = getRandomMatrix(r, c, 1, 5, 1, 7);
+               double[][] X3 = getRandomMatrix(r, c, 1, 5, 1, 8);
+               double[][] X4 = getRandomMatrix(r, c, 1, 5, 1, 9);
+
+               for(int k : new int[] {1, 2, 3}) {
+                       Arrays.fill(X3[k], 0);
+               }
+
+               MatrixCharacteristics mc = new MatrixCharacteristics(r, c, 
blocksize, r * c);
+               writeInputMatrixWithMTD("X1", X1, false, mc);
+               writeInputMatrixWithMTD("X2", X2, false, mc);
+               writeInputMatrixWithMTD("X3", X3, false, mc);
+               writeInputMatrixWithMTD("X4", X4, false, mc);
+
+               // empty script name because we don't execute any script, just 
start the worker
+               fullDMLScriptName = "";
+               int port1 = getRandomAvailablePort();
+               int port2 = getRandomAvailablePort();
+               int port3 = getRandomAvailablePort();
+               int port4 = getRandomAvailablePort();
+               Thread t1 = startLocalFedWorkerThread(port1, FED_WORKER_WAIT_S);
+               Thread t2 = startLocalFedWorkerThread(port2, FED_WORKER_WAIT_S);
+               Thread t3 = startLocalFedWorkerThread(port3, FED_WORKER_WAIT_S);
+               Thread t4 = startLocalFedWorkerThread(port4);
+
+               rtplatform = execMode;
+               if(rtplatform == ExecMode.SPARK) {
+                       System.out.println(7);
+                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
+               }
+               TestConfiguration config = 
availableTestConfigurations.get(TEST_NAME);
+               loadTestConfiguration(config);
+
+               // Run reference dml script with normal matrix
+               fullDMLScriptName = HOME + TEST_NAME + "Reference.dml";
+               programArgs = new String[] {"-stats", "100", "-args", 
input("X1"), input("X2"), input("X3"), input("X4"),
+                       Boolean.toString(rowPartitioned).toUpperCase(), 
expected("S"), Boolean.toString(isFrame).toUpperCase()};
+
+               runTest(null);
+
+               fullDMLScriptName = HOME + TEST_NAME + ".dml";
+               programArgs = new String[] {"-stats", "100", "-nvargs",
+                       "in_X1=" + TestUtils.federatedAddress(port1, 
input("X1")),
+                       "in_X2=" + TestUtils.federatedAddress(port2, 
input("X2")),
+                       "in_X3=" + TestUtils.federatedAddress(port3, 
input("X3")),
+                       "in_X4=" + TestUtils.federatedAddress(port4, 
input("X4")), "rows=" + rows, "cols=" + cols,
+                       "rP=" + Boolean.toString(rowPartitioned).toUpperCase(), 
"out_S=" + output("S"),
+                       "isFrame=" + Boolean.toString(isFrame).toUpperCase()};
+
+               runTest(null);
+
+               // compare via files
+               compareResults(1e-9);
+
+               // check that federated input files are still existing
+               Assert.assertTrue(HDFSTool.existsFileOnHDFS(input("X1")));
+               Assert.assertTrue(HDFSTool.existsFileOnHDFS(input("X2")));
+               Assert.assertTrue(HDFSTool.existsFileOnHDFS(input("X3")));
+               Assert.assertTrue(HDFSTool.existsFileOnHDFS(input("X4")));
+
+               TestUtils.shutdownThreads(t1, t2, t3, t4);
+
+               rtplatform = platformOld;
+               DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
+
+       }
+}
diff --git 
a/src/test/java/org/apache/sysds/test/functions/frame/FrameReplaceTest.java 
b/src/test/java/org/apache/sysds/test/functions/frame/FrameReplaceTest.java
index 73868e3..b333bd3 100644
--- a/src/test/java/org/apache/sysds/test/functions/frame/FrameReplaceTest.java
+++ b/src/test/java/org/apache/sysds/test/functions/frame/FrameReplaceTest.java
@@ -19,14 +19,17 @@
 
 package org.apache.sysds.test.functions.frame;
 
-import static org.junit.Assert.assertTrue;
+import java.util.HashMap;
 
+import static org.junit.Assert.assertEquals;
 import org.apache.sysds.api.DMLScript;
 import org.apache.sysds.common.Types.ExecMode;
 import org.apache.sysds.common.Types.ExecType;
+import org.apache.sysds.runtime.matrix.data.MatrixValue;
 import org.apache.sysds.test.AutomatedTestBase;
 import org.apache.sysds.test.TestConfiguration;
 import org.apache.sysds.test.TestUtils;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class FrameReplaceTest extends AutomatedTestBase {
@@ -38,7 +41,7 @@ public class FrameReplaceTest extends AutomatedTestBase {
     @Override
     public void setUp() {
         TestUtils.clearAssertionInformation();
-        addTestConfiguration(TEST_NAME, new TestConfiguration(TEST_CLASS_DIR, 
TEST_NAME));
+        addTestConfiguration(TEST_NAME, new TestConfiguration(TEST_CLASS_DIR, 
TEST_NAME, new String[] {"S.scalar"}));
     }
 
     @Test
@@ -47,6 +50,7 @@ public class FrameReplaceTest extends AutomatedTestBase {
     }
 
     @Test
+    @Ignore
     public void testParforFrameIntermediatesSpark() {
         runReplaceTest(ExecType.SPARK);
     }
@@ -71,13 +75,12 @@ public class FrameReplaceTest extends AutomatedTestBase {
             getAndLoadTestConfiguration(TEST_NAME);
             String HOME = SCRIPT_DIR + TEST_DIR;
             fullDMLScriptName = HOME + TEST_NAME + ".dml";
-            programArgs = new String[] {};
+            programArgs = new String[] {"-nvargs", "out_S=" + output("S")};
 
             // run test
-            String out = runTest(null).toString();
-
-            assertTrue(out.contains("south"));
-            assertTrue(!out.contains("north"));
+            runTest(null);
+            HashMap<MatrixValue.CellIndex, Double> val = 
readDMLScalarFromOutputDir("S");
+            assertEquals(1.0, val.get(new MatrixValue.CellIndex(1, 1)), 0.0);
 
         }
         catch(Exception ex) {
diff --git 
a/src/test/java/org/apache/sysds/test/functions/privacy/algorithms/FederatedL2SVMTest.java
 
b/src/test/java/org/apache/sysds/test/functions/privacy/algorithms/FederatedL2SVMTest.java
index cbadd98..67b790f 100644
--- 
a/src/test/java/org/apache/sysds/test/functions/privacy/algorithms/FederatedL2SVMTest.java
+++ 
b/src/test/java/org/apache/sysds/test/functions/privacy/algorithms/FederatedL2SVMTest.java
@@ -19,26 +19,27 @@
 
 package org.apache.sysds.test.functions.privacy.algorithms;
 
-import edu.emory.mathcs.backport.java.util.Arrays;
-import org.apache.sysds.hops.OptimizerUtils;
-import org.apache.sysds.runtime.DMLRuntimeException;
-import org.junit.Assert;
-import org.junit.Test;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.sysds.api.DMLScript;
 import org.apache.sysds.common.Types;
+import org.apache.sysds.hops.OptimizerUtils;
+import org.apache.sysds.runtime.DMLRuntimeException;
 import org.apache.sysds.runtime.meta.MatrixCharacteristics;
 import org.apache.sysds.runtime.privacy.PrivacyConstraint;
 import org.apache.sysds.runtime.privacy.PrivacyConstraint.PrivacyLevel;
 import org.apache.sysds.test.AutomatedTestBase;
 import org.apache.sysds.test.TestConfiguration;
 import org.apache.sysds.test.TestUtils;
+import org.junit.Assert;
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
 @net.jcip.annotations.NotThreadSafe
 @RunWith(value = Parameterized.class)
 public class FederatedL2SVMTest extends AutomatedTestBase {
@@ -56,10 +57,10 @@ public class FederatedL2SVMTest extends AutomatedTestBase {
 
        @Parameterized.Parameters
        public static Collection<Object[]> data() {
-               return Arrays.asList(new Object[][]{
-                       {false},
-                       {true}
-               });
+               List<Object[]> tests = new ArrayList<>();
+               tests.add(new Object[]{false});
+               tests.add(new Object[]{true});
+               return tests;
        }
 
        @Override public void setUp() {
diff --git a/src/test/scripts/functions/frame/ReplaceTest.dml 
b/src/test/scripts/functions/federated/FederatedReplaceTest.dml
similarity index 55%
copy from src/test/scripts/functions/frame/ReplaceTest.dml
copy to src/test/scripts/functions/federated/FederatedReplaceTest.dml
index 2a12b48..81071a3 100644
--- a/src/test/scripts/functions/frame/ReplaceTest.dml
+++ b/src/test/scripts/functions/federated/FederatedReplaceTest.dml
@@ -7,9 +7,9 @@
 # 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
@@ -19,10 +19,21 @@
 #
 #-------------------------------------------------------------
 
-X = read("src/test/resources/datasets/homes/homes.csv") 
+if ($rP) {
+    A = federated(addresses=list($in_X1, $in_X2, $in_X3, $in_X4),
+        ranges=list(list(0, 0), list($rows/4, $cols), list($rows/4, 0), 
list(2*$rows/4, $cols),
+               list(2*$rows/4, 0), list(3*$rows/4, $cols), list(3*$rows/4, 0), 
list($rows, $cols)));
+} else {
+    A = federated(addresses=list($in_X1, $in_X2, $in_X3, $in_X4),
+            ranges=list(list(0, 0), list($rows, $cols/4), list(0,$cols/4), 
list($rows, $cols/2),
+               list(0,$cols/2), list($rows, 3*($cols/4)), list(0, 
3*($cols/4)), list($rows, $cols)));
+}
 
-X = replace(target = X, pattern="north", replacement="south")
-X = replace(target = X, pattern="east", replacement="south")
-X = replace(target = X, pattern="west", replacement="south")
+if ($isFrame) {
+    X = as.frame(A);
+    s = as.matrix(replace(target=X, pattern=0, replacement=1));
+} else {
+    s = replace(target=A, pattern=0, replacement=1);
+}
 
-print(toString(X))
\ No newline at end of file
+write(s, $out_S);
diff --git a/src/test/scripts/functions/frame/ReplaceTest.dml 
b/src/test/scripts/functions/federated/FederatedReplaceTestReference.dml
similarity index 75%
copy from src/test/scripts/functions/frame/ReplaceTest.dml
copy to src/test/scripts/functions/federated/FederatedReplaceTestReference.dml
index 2a12b48..1bd51ec 100644
--- a/src/test/scripts/functions/frame/ReplaceTest.dml
+++ b/src/test/scripts/functions/federated/FederatedReplaceTestReference.dml
@@ -7,9 +7,9 @@
 # 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
@@ -19,10 +19,13 @@
 #
 #-------------------------------------------------------------
 
-X = read("src/test/resources/datasets/homes/homes.csv") 
-
-X = replace(target = X, pattern="north", replacement="south")
-X = replace(target = X, pattern="east", replacement="south")
-X = replace(target = X, pattern="west", replacement="south")
+if($5) { A = rbind(read($1), read($2), read($3), read($4)); }
+else { A = cbind(read($1), read($2), read($3), read($4)); }
 
-print(toString(X))
\ No newline at end of file
+if ($7) {
+    X = as.frame(A);
+    s = as.matrix(replace(target=X, pattern=0, replacement=1));
+} else {
+    s = replace(target=A, pattern=0, replacement=1);
+}
+write(s, $6);
diff --git a/src/test/scripts/functions/frame/ReplaceTest.dml 
b/src/test/scripts/functions/frame/ReplaceTest.dml
index 2a12b48..10e8c4d 100644
--- a/src/test/scripts/functions/frame/ReplaceTest.dml
+++ b/src/test/scripts/functions/frame/ReplaceTest.dml
@@ -19,10 +19,14 @@
 #
 #-------------------------------------------------------------
 
-X = read("src/test/resources/datasets/homes/homes.csv") 
+X = frame(data=["1", "500", "abc", "2.5", "TRUE", "abc", "klm"], rows=100, 
cols=7, schema=["INT32", "INT64", "STRING", "FP64", "BOOLEAN", "STRING", 
"STRING"])
 
-X = replace(target = X, pattern="north", replacement="south")
-X = replace(target = X, pattern="east", replacement="south")
-X = replace(target = X, pattern="west", replacement="south")
+X = replace(target = X, pattern=1, replacement=3)
+X = replace(target = X, pattern=500, replacement=3000)
+X = replace(target = X, pattern="abc", replacement="cba")
+X = replace(target = X, pattern=2.5, replacement=0.5)
+X = replace(target = X, pattern=TRUE, replacement=FALSE)
 
-print(toString(X))
\ No newline at end of file
+out = frame(data=["3", "3000", "cba", "0.5", "FALSE", "cba", "klm"], rows=100, 
cols=7, schema=["INT32", "INT64", "STRING", "FP64", "BOOLEAN", "STRING", 
"STRING"])
+isCorrect = as.integer(sum(as.matrix(out == X)) == (nrow(X) * ncol(X)))
+write(isCorrect, $out_S)
diff --git 
a/src/test/scripts/functions/pipelines/intermediates/classification/bestAcc.csv.mtd
 
b/src/test/scripts/functions/pipelines/intermediates/classification/bestAcc.csv.mtd
new file mode 100644
index 0000000..d3f8f29
--- /dev/null
+++ 
b/src/test/scripts/functions/pipelines/intermediates/classification/bestAcc.csv.mtd
@@ -0,0 +1,12 @@
+{
+    "data_type": "matrix",
+    "value_type": "double",
+    "rows": 3,
+    "cols": 1,
+    "nnz": 3,
+    "format": "csv",
+    "author": "olga_ovcharenko",
+    "header": false,
+    "sep": ",",
+    "created": "2021-09-15 13:08:58 CEST"
+}
\ No newline at end of file
diff --git 
a/src/test/scripts/functions/pipelines/intermediates/classification/dirtyScore.csv.mtd
 
b/src/test/scripts/functions/pipelines/intermediates/classification/dirtyScore.csv.mtd
new file mode 100644
index 0000000..4689778
--- /dev/null
+++ 
b/src/test/scripts/functions/pipelines/intermediates/classification/dirtyScore.csv.mtd
@@ -0,0 +1,7 @@
+{
+    "data_type": "scalar",
+    "value_type": "double",
+    "format": "text",
+    "author": "olga_ovcharenko",
+    "created": "2021-09-15 13:08:58 CEST"
+}
\ No newline at end of file
diff --git 
a/src/test/scripts/functions/pipelines/intermediates/classification/evalHp.csv.mtd
 
b/src/test/scripts/functions/pipelines/intermediates/classification/evalHp.csv.mtd
new file mode 100644
index 0000000..98f02f0
--- /dev/null
+++ 
b/src/test/scripts/functions/pipelines/intermediates/classification/evalHp.csv.mtd
@@ -0,0 +1,12 @@
+{
+    "data_type": "matrix",
+    "value_type": "double",
+    "rows": 1,
+    "cols": 4,
+    "nnz": 4,
+    "format": "csv",
+    "author": "olga_ovcharenko",
+    "header": false,
+    "sep": ",",
+    "created": "2021-09-15 13:08:58 CEST"
+}
\ No newline at end of file
diff --git 
a/src/test/scripts/functions/pipelines/intermediates/classification/featureFrame.csv
 
b/src/test/scripts/functions/pipelines/intermediates/classification/featureFrame.csv
new file mode 100644
index 0000000..e9aacae
--- /dev/null
+++ 
b/src/test/scripts/functions/pipelines/intermediates/classification/featureFrame.csv
@@ -0,0 +1 @@
+#MissingValues,MinVla,MaxVal,AverageMin,AverageMax,#CategoricalFeatures,#NumericFeatures,Mean,#Outliers,#OHEfeatures,#Classes,Imbalance,#rows,#cols,pipelines,accuracy,execution
 time in ms,CV time in ms
diff --git 
a/src/test/scripts/functions/pipelines/intermediates/classification/featureFrame.csv.mtd
 
b/src/test/scripts/functions/pipelines/intermediates/classification/featureFrame.csv.mtd
new file mode 100644
index 0000000..f73d794
--- /dev/null
+++ 
b/src/test/scripts/functions/pipelines/intermediates/classification/featureFrame.csv.mtd
@@ -0,0 +1,11 @@
+{
+    "data_type": "frame",
+    "schema": 
"STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,",
+    "rows": 1,
+    "cols": 18,
+    "format": "csv",
+    "author": "olga_ovcharenko",
+    "header": false,
+    "sep": ",",
+    "created": "2021-09-15 13:08:58 CEST"
+}
\ No newline at end of file
diff --git 
a/src/test/scripts/functions/pipelines/intermediates/classification/hp.csv.mtd 
b/src/test/scripts/functions/pipelines/intermediates/classification/hp.csv.mtd
new file mode 100644
index 0000000..80fe788
--- /dev/null
+++ 
b/src/test/scripts/functions/pipelines/intermediates/classification/hp.csv.mtd
@@ -0,0 +1,12 @@
+{
+    "data_type": "matrix",
+    "value_type": "double",
+    "rows": 3,
+    "cols": 60,
+    "nnz": 28,
+    "format": "csv",
+    "author": "olga_ovcharenko",
+    "header": false,
+    "sep": ",",
+    "created": "2021-09-15 13:08:58 CEST"
+}
\ No newline at end of file
diff --git 
a/src/test/scripts/functions/pipelines/intermediates/classification/lp.csv.mtd 
b/src/test/scripts/functions/pipelines/intermediates/classification/lp.csv.mtd
new file mode 100644
index 0000000..241a6a0
--- /dev/null
+++ 
b/src/test/scripts/functions/pipelines/intermediates/classification/lp.csv.mtd
@@ -0,0 +1,11 @@
+{
+    "data_type": "frame",
+    "schema": "STRING,STRING,STRING,STRING,",
+    "rows": 1,
+    "cols": 4,
+    "format": "csv",
+    "author": "olga_ovcharenko",
+    "header": false,
+    "sep": ",",
+    "created": "2021-09-15 13:08:58 CEST"
+}
\ No newline at end of file
diff --git 
a/src/test/scripts/functions/pipelines/intermediates/classification/pip.csv.mtd 
b/src/test/scripts/functions/pipelines/intermediates/classification/pip.csv.mtd
new file mode 100644
index 0000000..33bc1d4
--- /dev/null
+++ 
b/src/test/scripts/functions/pipelines/intermediates/classification/pip.csv.mtd
@@ -0,0 +1,11 @@
+{
+    "data_type": "frame",
+    "schema": "STRING,STRING,STRING,STRING,",
+    "rows": 3,
+    "cols": 4,
+    "format": "csv",
+    "author": "olga_ovcharenko",
+    "header": false,
+    "sep": ",",
+    "created": "2021-09-15 13:08:58 CEST"
+}
\ No newline at end of file

Reply via email to