MCPcopy Create free account
hub / github.com/dmlc/xgboost / TestCatContainerMixed

Function TestCatContainerMixed

tests/cpp/data/test_cat_container.h:69–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68template <typename DfTest, typename EqCheck>
69auto TestCatContainerMixed(Context const* ctx, EqCheck&& is_eq) {
70 auto df =
71 DfTest::Make(DfTest::MakeStrs("abc", "bcd", "cde", "ab"), DfTest::MakeInts(2, 2, 3, 0, 4));
72 auto h_df = df.View();
73 auto cats = test_cat_detail::FromDf(ctx, h_df);
74 if (ctx->IsCPU()) {
75 test_cat_detail::HostCheck(cats);
76 } else {
77 test_cat_detail::DeviceCheck(cats);
78 }
79
80 cats.Sort(ctx);
81 auto sorted_idx = cats.RefSortedIndex(ctx);
82 auto sol = std::vector<bst_cat_t>{3, 0, 1, 2, 3, 0, 1, 2, 4};
83 is_eq(sorted_idx, sol);
84 auto view = cats.HostView();
85 [&] {
86 ASSERT_EQ(view.n_total_cats, sol.size());
87 ASSERT_EQ(view.feature_segments.size(), 3ul);
88 ASSERT_EQ(view.feature_segments[0], 0);
89 ASSERT_EQ(view.feature_segments[1], 4);
90 ASSERT_EQ(view.feature_segments[2], static_cast<bst_cat_t>(sol.size()));
91 }();
92
93 return df;
94}
95} // namespace xgboost

Callers

nothing calls this directly

Calls 9

FromDfFunction · 0.85
HostCheckFunction · 0.85
DeviceCheckFunction · 0.85
SortMethod · 0.80
RefSortedIndexMethod · 0.80
ViewMethod · 0.45
IsCPUMethod · 0.45
HostViewMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected