Skip to content

Commit 2ce97b5

Browse files
committed
adjust test.
1 parent cb46ff3 commit 2ce97b5

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

tests/cpp/metric/test_rank_metric.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,24 @@
1717
#include "xgboost/host_device_vector.h" // for HostDeviceVector
1818
#include "xgboost/json.h" // for Json, String, Object
1919

20-
namespace xgboost {
21-
namespace metric {
20+
namespace xgboost::metric {
2221

2322
inline void VerifyPrecision(DataSplitMode data_split_mode = DataSplitMode::kRow) {
24-
// When the limit for precision is not given, it takes the limit at
25-
// std::numeric_limits<unsigned>::max(); hence all values are very small
26-
// NOTE(AbdealiJK): Maybe this should be fixed to be num_row by default.
2723
auto ctx = xgboost::CreateEmptyGenericParam(GPUIDX);
28-
xgboost::Metric * metric = xgboost::Metric::Create("pre", &ctx);
24+
xgboost::Metric* metric = xgboost::Metric::Create("pre", &ctx);
2925
ASSERT_STREQ(metric->Name(), "pre");
30-
EXPECT_NEAR(GetMetricEval(metric, {0, 1}, {0, 1}, {}, {}, data_split_mode), 0, 1e-7);
31-
EXPECT_NEAR(GetMetricEval(metric,
32-
{0.1f, 0.9f, 0.1f, 0.9f},
33-
{ 0, 0, 1, 1}, {}, {}, data_split_mode),
34-
0, 1e-7);
26+
EXPECT_NEAR(GetMetricEval(metric, {0, 1}, {0, 1}, {}, {}, data_split_mode), 0.5, 1e-7);
27+
EXPECT_NEAR(
28+
GetMetricEval(metric, {0.1f, 0.9f, 0.1f, 0.9f}, {0, 0, 1, 1}, {}, {}, data_split_mode), 0.5,
29+
1e-7);
3530

3631
delete metric;
3732
metric = xgboost::Metric::Create("pre@2", &ctx);
3833
ASSERT_STREQ(metric->Name(), "pre@2");
3934
EXPECT_NEAR(GetMetricEval(metric, {0, 1}, {0, 1}, {}, {}, data_split_mode), 0.5f, 1e-7);
40-
EXPECT_NEAR(GetMetricEval(metric,
41-
{0.1f, 0.9f, 0.1f, 0.9f},
42-
{ 0, 0, 1, 1}, {}, {}, data_split_mode),
43-
0.5f, 0.001f);
35+
EXPECT_NEAR(
36+
GetMetricEval(metric, {0.1f, 0.9f, 0.1f, 0.9f}, {0, 0, 1, 1}, {}, {}, data_split_mode), 0.5f,
37+
0.001f);
4438

4539
EXPECT_ANY_THROW(GetMetricEval(metric, {0, 1}, {}, {}, {}, data_split_mode));
4640

@@ -187,5 +181,4 @@ inline void VerifyNDCGExpGain(DataSplitMode data_split_mode = DataSplitMode::kRo
187181
ndcg = metric->Evaluate(predt, p_fmat);
188182
ASSERT_NEAR(ndcg, 1.0, kRtEps);
189183
}
190-
} // namespace metric
191-
} // namespace xgboost
184+
} // namespace xgboost::metric

0 commit comments

Comments
 (0)