Skip to content

Commit 2ddb9ee

Browse files
authored
check for number of input columns in concat transform (#3809)
1 parent 380f167 commit 2ddb9ee

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Microsoft.ML.Data/Transforms/ColumnConcatenatingEstimator.cs

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ internal ColumnConcatenatingEstimator(IHostEnvironment env, string outputColumnN
5454

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

test/Microsoft.ML.Tests/Transformers/ConcatTests.cs

+20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
56
using System.IO;
67
using Microsoft.ML.Data;
78
using Microsoft.ML.Data.IO;
@@ -17,6 +18,25 @@ public ConcatTests(ITestOutputHelper output) : base(output)
1718
{
1819
}
1920

21+
[Fact]
22+
void TestConcatNoInputColumns()
23+
{
24+
var thrown = false;
25+
26+
try
27+
{
28+
var pipe = ML.Transforms.Concatenate("Features");
29+
}
30+
catch(Exception ex)
31+
{
32+
Assert.Contains("Input columns not specified", ex.Message);
33+
thrown = true;
34+
35+
}
36+
Assert.True(thrown);
37+
Done();
38+
}
39+
2040
[Fact]
2141
void TestConcat()
2242
{

0 commit comments

Comments
 (0)