File tree Expand file tree Collapse file tree 3 files changed +557
-37
lines changed
Microsoft.ML.Functional.Tests
Microsoft.ML.Tests/Scenarios/Api/Estimators Expand file tree Collapse file tree 3 files changed +557
-37
lines changed Original file line number Diff line number Diff line change 99using Microsoft . ML . Data ;
1010using Microsoft . ML . Functional . Tests . Datasets ;
1111using Xunit ;
12+ using Xunit . Sdk ;
1213
1314namespace 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>
You can’t perform that action at this time.
0 commit comments