Skip to content

Commit 9ecd3f0

Browse files
author
Rogan Carr
committed
Adding functional tests for training scenarios
1 parent f7b0a95 commit 9ecd3f0

File tree

3 files changed

+562
-37
lines changed

3 files changed

+562
-37
lines changed

test/Microsoft.ML.Functional.Tests/Common.cs

+28
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.ML.Data;
1010
using Microsoft.ML.Functional.Tests.Datasets;
1111
using Xunit;
12+
using Xunit.Sdk;
1213

1314
namespace Microsoft.ML.Functional.Tests
1415
{
@@ -268,6 +269,33 @@ public static void AssertMetricsStatistics(RegressionMetricsStatistics metrics)
268269
AssertMetricStatistics(metrics.LossFunction);
269270
}
270271

272+
/// <summary>
273+
/// Assert that two float arrays are not equal.
274+
/// </summary>
275+
/// <param name="array1">An array of floats.</param>
276+
/// <param name="array2">An array of floats.</param>
277+
public static void AssertNotEqual(float[] array1, float[] array2)
278+
{
279+
Assert.NotNull(array1);
280+
Assert.NotNull(array2);
281+
Assert.Equal(array1.Length, array2.Length);
282+
283+
bool mismatch = false;
284+
for (int i = 0; i < array1.Length; i++)
285+
try
286+
{
287+
// Use Assert to test for equality rather than
288+
// to roll our own float equality checker.
289+
Assert.Equal(array1[i], array2[i]);
290+
}
291+
catch(EqualException)
292+
{
293+
mismatch = true;
294+
break;
295+
}
296+
Assert.True(mismatch);
297+
}
298+
271299
/// <summary>
272300
/// Verify that a float array has no NaNs or infinities.
273301
/// </summary>

0 commit comments

Comments
 (0)