Skip to content

Commit

Permalink
Adding functional tests for all training scenarios (#2921)
Browse files Browse the repository at this point in the history
* Adding functional tests for training scenarios
  • Loading branch information
rogancarr authored Mar 14, 2019
1 parent dde909a commit acfe24a
Show file tree
Hide file tree
Showing 3 changed files with 557 additions and 37 deletions.
28 changes: 28 additions & 0 deletions test/Microsoft.ML.Functional.Tests/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.ML.Data;
using Microsoft.ML.Functional.Tests.Datasets;
using Xunit;
using Xunit.Sdk;

namespace Microsoft.ML.Functional.Tests
{
Expand Down Expand Up @@ -268,6 +269,33 @@ public static void AssertMetricsStatistics(RegressionMetricsStatistics metrics)
AssertMetricStatistics(metrics.LossFunction);
}

/// <summary>
/// Assert that two float arrays are not equal.
/// </summary>
/// <param name="array1">An array of floats.</param>
/// <param name="array2">An array of floats.</param>
public static void AssertNotEqual(float[] array1, float[] array2)
{
Assert.NotNull(array1);
Assert.NotNull(array2);
Assert.Equal(array1.Length, array2.Length);

bool mismatch = false;
for (int i = 0; i < array1.Length; i++)
try
{
// Use Assert to test for equality rather than
// to roll our own float equality checker.
Assert.Equal(array1[i], array2[i]);
}
catch(EqualException)
{
mismatch = true;
break;
}
Assert.True(mismatch);
}

/// <summary>
/// Verify that a float array has no NaNs or infinities.
/// </summary>
Expand Down
Loading

0 comments on commit acfe24a

Please sign in to comment.