dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
8.93k stars 1.86k forks source link

Make double assertions compare with tolerance instead of precision #6923

Closed ericstj closed 6 months ago

ericstj commented 6 months ago

Precision might cause small differences to round to a different number. Instead compare with a tolerance which is not sensitive to rounding.

See comment here: https://github.com/dotnet/machinelearning/pull/6703#issuecomment-1866985302

codecov[bot] commented 6 months ago

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (efab011) 68.79% compared to head (7dd0d0d) 68.80%. Report is 3 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6923 +/- ## ======================================= Coverage 68.79% 68.80% ======================================= Files 1249 1249 Lines 249431 249433 +2 Branches 25510 25510 ======================================= + Hits 171604 171628 +24 + Misses 71214 71191 -23 - Partials 6613 6614 +1 ``` | [Flag](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | Coverage Δ | | |---|---|---| | [Debug](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | `68.80% <90.45%> (+<0.01%)` | :arrow_up: | | [production](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | `63.26% <ø> (+0.01%)` | :arrow_up: | | [test](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | `88.49% <90.45%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | Coverage Δ | | |---|---|---| | [...crosoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuQ29yZS5UZXN0cy9Vbml0VGVzdHMvVGVzdEVudHJ5UG9pbnRzLmNz) | `98.45% <100.00%> (ø)` | | | [test/Microsoft.ML.Core.Tests/UnitTests/TestLoss.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuQ29yZS5UZXN0cy9Vbml0VGVzdHMvVGVzdExvc3MuY3M=) | `100.00% <100.00%> (ø)` | | | [...t/Microsoft.ML.Core.Tests/UnitTests/TestVBuffer.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuQ29yZS5UZXN0cy9Vbml0VGVzdHMvVGVzdFZCdWZmZXIuY3M=) | `95.31% <100.00%> (ø)` | | | [test/Microsoft.ML.CpuMath.UnitTests/UnitTests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuQ3B1TWF0aC5Vbml0VGVzdHMvVW5pdFRlc3RzLmNz) | `95.70% <100.00%> (ø)` | | | [test/Microsoft.ML.Fairlearn.Tests/MetricTest.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuRmFpcmxlYXJuLlRlc3RzL01ldHJpY1Rlc3QuY3M=) | `100.00% <100.00%> (ø)` | | | [test/Microsoft.ML.Fairlearn.Tests/UtilityTest.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuRmFpcmxlYXJuLlRlc3RzL1V0aWxpdHlUZXN0LmNz) | `100.00% <100.00%> (ø)` | | | [...osoft.ML.OnnxTransformerTest/OnnxTransformTests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuT25ueFRyYW5zZm9ybWVyVGVzdC9Pbm54VHJhbnNmb3JtVGVzdHMuY3M=) | `95.58% <100.00%> (ø)` | | | [...soft.ML.Predictor.Tests/TestGamPublicInterfaces.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuUHJlZGljdG9yLlRlc3RzL1Rlc3RHYW1QdWJsaWNJbnRlcmZhY2VzLmNz) | `100.00% <100.00%> (ø)` | | | [...est/Microsoft.ML.Predictor.Tests/TestPredictors.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuUHJlZGljdG9yLlRlc3RzL1Rlc3RQcmVkaWN0b3JzLmNz) | `69.62% <100.00%> (ø)` | | | [test/Microsoft.ML.Tests/AnomalyDetectionTests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuVGVzdHMvQW5vbWFseURldGVjdGlvblRlc3RzLmNz) | `99.29% <100.00%> (ø)` | | | ... and [14 more](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | | ... and [5 files with indirect coverage changes](https://app.codecov.io/gh/dotnet/machinelearning/pull/6923/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet)