| 67 | |
| 68 | template <typename DfTest, typename EqCheck> |
| 69 | auto 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 |
nothing calls this directly
no test coverage detected