Skip to content
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

Adding functional tests for all training scenarios #2921

Merged
merged 10 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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
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