File tree 3 files changed +562
-37
lines changed
Microsoft.ML.Functional.Tests
Microsoft.ML.Tests/Scenarios/Api/Estimators
3 files changed +562
-37
lines changed Original file line number Diff line number Diff line change 9
9
using Microsoft . ML . Data ;
10
10
using Microsoft . ML . Functional . Tests . Datasets ;
11
11
using Xunit ;
12
+ using Xunit . Sdk ;
12
13
13
14
namespace Microsoft . ML . Functional . Tests
14
15
{
@@ -268,6 +269,33 @@ public static void AssertMetricsStatistics(RegressionMetricsStatistics metrics)
268
269
AssertMetricStatistics ( metrics . LossFunction ) ;
269
270
}
270
271
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
+
271
299
/// <summary>
272
300
/// Verify that a float array has no NaNs or infinities.
273
301
/// </summary>
You can’t perform that action at this time.
0 commit comments