Skip to content

Check for number of input columns in concat transform #3809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ internal ColumnConcatenatingEstimator(IHostEnvironment env, string outputColumnN

_host.CheckNonEmpty(outputColumnName, nameof(outputColumnName));
_host.CheckValue(inputColumnNames, nameof(inputColumnNames));
_host.CheckParam(inputColumnNames.Length > 0, nameof(inputColumnNames), "Input columns not specified");
_host.CheckParam(!inputColumnNames.Any(r => string.IsNullOrEmpty(r)), nameof(inputColumnNames),
"Contained some null or empty items");

Expand Down
20 changes: 20 additions & 0 deletions test/Microsoft.ML.Tests/Transformers/ConcatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.IO;
using Microsoft.ML.Data;
using Microsoft.ML.Data.IO;
Expand All @@ -17,6 +18,25 @@ public ConcatTests(ITestOutputHelper output) : base(output)
{
}

[Fact]
void TestConcatNoInputColumns()
{
var thrown = false;

try
{
var pipe = ML.Transforms.Concatenate("Features");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concatenate [](start = 41, length = 11)

maybe it make sense to remove params from inputColumnNames in Concatenate method?

}
catch(Exception ex)
{
Assert.Contains("Input columns not specified", ex.Message);
thrown = true;

}
Assert.True(thrown);
Done();
}

[Fact]
void TestConcat()
{
Expand Down