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

Function TestCatContainerStr

tests/cpp/data/test_cat_container.h:38–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36
37template <typename DfTest, typename EqCheck>
38auto TestCatContainerStr(Context const* ctx, EqCheck&& is_eq) {
39 auto df = DfTest::Make(DfTest::MakeStrs("abc", "bcd", "cde", "ab"));
40 auto h_df = df.View();
41 auto cats = test_cat_detail::FromDf(ctx, h_df);
42 if (ctx->IsCPU()) {
43 test_cat_detail::HostCheck(cats);
44 } else {
45 test_cat_detail::DeviceCheck(cats);
46 }
47
48 [&] {
49 ASSERT_EQ(df.View().columns.size(), cats.NumFeatures());
50 }();
51
52 cats.Sort(ctx);
53
54 auto sol = std::vector<bst_cat_t>{3, 0, 1, 2};
55 auto sorted_idx = cats.RefSortedIndex(ctx);
56 is_eq(sorted_idx, sol);
57 [&] {
58 auto view = cats.HostView();
59 ASSERT_EQ(view.n_total_cats, sol.size());
60 ASSERT_EQ(view.feature_segments.size(), 2ul);
61 ASSERT_EQ(view.feature_segments[0], 0);
62 ASSERT_EQ(view.feature_segments[1], static_cast<bst_cat_t>(sol.size()));
63 }();
64
65 return df;
66}
67
68template <typename DfTest, typename EqCheck>
69auto TestCatContainerMixed(Context const* ctx, EqCheck&& is_eq) {

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected