Skip to content

Commit

Permalink
[MINOR] Cleanup sliceLineDebug tests, new tests for frame toString
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mboehm7 committed May 21, 2024
1 parent 9e99f3c commit 9974c93
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
4 changes: 1 addition & 3 deletions scripts/builtin/sliceLineDebug.dml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"}));
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/scripts/functions/builtin/sliceLineRealData.dml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9974c93

Please sign in to comment.