john-on-line27 commented on code in PR #2629: URL: https://github.com/apache/systemds/pull/2629#discussion_r4452594284
########## src/test/java/org/apache/sysds/runtime/util/EMAUtilsTest.java: ########## @@ -0,0 +1,151 @@ +/* + * 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.runtime.util; + +import org.apache.sysds.runtime.matrix.data.MatrixValue; +import org.apache.sysds.test.AutomatedTestBase; +import org.apache.sysds.test.TestConfiguration; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; + +import static org.apache.sysds.test.TestUtils.readRMatrixFromFS; +import static org.apache.sysds.runtime.util.EMAUtils.*; + +public class EMAUtilsTest extends AutomatedTestBase { + private static final String TEST_NAME = "exponentialSmoothing"; + private static final String TEST_DIR = "functions/builtin/"; + private static final String TEST_CLASS_DIR = TEST_DIR + EMAUtilsTest.class.getSimpleName() + "/"; + + private static final double REFERENCE_EPS = 1e-4; + private static final Double[] TS_DATA = { + 112., 118., 132., 129., 121., 135., 148., 148., 136., 119., 104., 118., + 115., 126., 141., 135., 125., 149., 170., 170., 158., 133., 114., 140., + 145., 150., 178., 163., 172., 178., 199., 199., 184., 162., 146., 166., + 171., 180., 193., 181., 183., 218., 230., 242., 209., 191., 172., 194., + 196., 196., 236., 235., 229., 243., 264., 272., 237., 211., 180., 201. + }; + @Override + public void setUp() { + addTestConfiguration(TEST_NAME, + new TestConfiguration(TEST_CLASS_DIR, TEST_NAME, new String[] { "R_double", "R_triple", "R_triple_odd" })); + } + + @Test + public void testDoubleExponentialSmoothing() { + fullRScriptName = SCRIPT_DIR + TEST_DIR + TEST_NAME + ".R"; + String resultPath = output("R_double"); + + rCmd = getRCmd("double", resultPath); + runRScript(true); + + HashMap<MatrixValue.CellIndex, Double> rOutput = readRMatrixFromFS(resultPath); + Assert.assertFalse("R output should contain values", rOutput.isEmpty()); + + int numRows = (int) rOutput.keySet().stream().mapToLong(idx -> idx.row).max().orElse(0); + double[] rFittedValues = new double[numRows]; + for (int i = 1; i <= numRows; i++) { + rFittedValues[i - 1] = rOutput.get(new MatrixValue.CellIndex(i, 1)); + } + + + Container javaFittedValues = double_exponential_smoothing(TS_DATA, 0.3, 0.1); Review Comment: Originally I could not find the test files. I can merge the two test files, however, the current test functions in BuiltinEMATest.java are failing, and since the scope of the thesis does not overlap with the subjects of the tests, it will be unlikely that I will have the time to fix them. @ywcb00 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
