Commit 67e0cc0 1 parent cc68aee commit 67e0cc0 Copy full SHA for 67e0cc0
File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 44
44
#include < gtest/gtest.h>
45
45
#include < test_utils.h>
46
46
47
+ #include < cmath>
47
48
#include < cstddef>
48
49
#include < memory>
49
50
#include < random>
@@ -1208,7 +1209,11 @@ class ObjectiveTest : public ::testing::TestWithParam<ObjectiveTestParameters> {
1208
1209
NumLeftOfBin (cdf_hist, params.max_n_bins - 1 ),
1209
1210
NumLeftOfBin (cdf_hist, split_bin_index));
1210
1211
1211
- ASSERT_NEAR (ground_truth_gain, hypothesis_gain, params.tolerance );
1212
+ // The gain may actually be NaN. If so, a comparison between the result and
1213
+ // ground truth would yield false, even if they are both (correctly) NaNs.
1214
+ if (!std::isnan (ground_truth_gain) || !std::isnan (hypothesis_gain)) {
1215
+ ASSERT_NEAR (ground_truth_gain, hypothesis_gain, params.tolerance );
1216
+ }
1212
1217
}
1213
1218
};
1214
1219
You can’t perform that action at this time.
0 commit comments