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 9974c93507 [MINOR] Cleanup sliceLineDebug tests, new tests for frame toString 9974c93507 is described below commit 9974c9350737fbcbc8804d9665dfaadc767779a8 Author: Matthias Boehm <mboe...@gmail.com> AuthorDate: Tue May 21 10:55:53 2024 +0200 [MINOR] Cleanup sliceLineDebug tests, new tests for frame toString There was a suspicion that the frame toString() always pads "null"s to the default number of. However additional tests revealed, that this was an issue of the sliceLineDebug test, which does transformencode for the entire salaries dataset (including recoding of an ID column) before indexing relevant columns which preserved the original number of rows. The new tests are still useful. --- scripts/builtin/sliceLineDebug.dml | 4 +- .../test/component/frame/FrameToStringTest.java | 48 ++++++++++++++++++++++ .../part2/BuiltinSliceLineRealDataTest.java | 2 +- .../functions/builtin/sliceLineRealData.dml | 2 +- 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/scripts/builtin/sliceLineDebug.dml b/scripts/builtin/sliceLineDebug.dml index d3ea1494e3..c3eec20d91 100644 --- a/scripts/builtin/sliceLineDebug.dml +++ b/scripts/builtin/sliceLineDebug.dml @@ -40,9 +40,7 @@ m_sliceLineDebug = function(Matrix[Double] TK, Matrix[Double] TKC, Frame[Unknown] tfmeta, String tfspec) return(Matrix[Double] S) { - # FIXME: frame toString always pads to 100 rows - # print("sliceLineDebug: input\n"+toString(TK)+"\n"+toString(TKC)+"\n"+toString(tfmeta)); - print("sliceLineDebug:"); + print("\nsliceLineDebug: input\n"+toString(TK)+"\n"+toString(TKC)+"\n"+toString(tfmeta)); # prepare essential decoding info N = colnames(tfmeta); diff --git a/src/test/java/org/apache/sysds/test/component/frame/FrameToStringTest.java b/src/test/java/org/apache/sysds/test/component/frame/FrameToStringTest.java new file mode 100644 index 0000000000..2b29214b59 --- /dev/null +++ b/src/test/java/org/apache/sysds/test/component/frame/FrameToStringTest.java @@ -0,0 +1,48 @@ +/* + * 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.component.frame; + +import static org.junit.Assert.assertTrue; + +import org.apache.sysds.common.Types.ValueType; +import org.apache.sysds.runtime.frame.data.FrameBlock; +import org.apache.sysds.runtime.util.DataConverter; +import org.junit.Test; + +public class FrameToStringTest { + @Test + public void testDefault() { + FrameBlock f = createFrameBlock(); + assertTrue(DataConverter.toString(f).length() < 75); + } + + @Test + public void test100x100() { + FrameBlock f = createFrameBlock(); + assertTrue(DataConverter.toString(f, false, " ", "\n", 100, 100, 3).length() < 75); + } + + private FrameBlock createFrameBlock() { + FrameBlock f = new FrameBlock(new ValueType[]{ValueType.STRING, ValueType.STRING}); + for(int i=0; i<5; i++) + f.appendRow(new String[] {"a","b"}); + return f; + } +} diff --git a/src/test/java/org/apache/sysds/test/functions/builtin/part2/BuiltinSliceLineRealDataTest.java b/src/test/java/org/apache/sysds/test/functions/builtin/part2/BuiltinSliceLineRealDataTest.java index 7dff753a60..4de711b37c 100644 --- a/src/test/java/org/apache/sysds/test/functions/builtin/part2/BuiltinSliceLineRealDataTest.java +++ b/src/test/java/org/apache/sysds/test/functions/builtin/part2/BuiltinSliceLineRealDataTest.java @@ -38,7 +38,7 @@ public class BuiltinSliceLineRealDataTest extends AutomatedTestBase { @Override public void setUp() { - for(int i=1; i<=4; i++) + for(int i=1; i<=1; i++) addTestConfiguration(TEST_NAME+i, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME, new String[] {"R"})); } diff --git a/src/test/scripts/functions/builtin/sliceLineRealData.dml b/src/test/scripts/functions/builtin/sliceLineRealData.dml index 46c4bb368b..3145f2fb9d 100644 --- a/src/test/scripts/functions/builtin/sliceLineRealData.dml +++ b/src/test/scripts/functions/builtin/sliceLineRealData.dml @@ -25,7 +25,7 @@ y = as.matrix(Forig[,ncol(Forig)]); tfspec = read($2, data_type="scalar", value_type="string"); [X, meta] = transformencode(target=F, spec=tfspec); -meta = meta[,2:ncol(X)] +meta = meta[1:10,2:ncol(X)]; X = X[,2:ncol(X)] # one hot encoding