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

Function CheckSparseColumn

tests/cpp/common/test_column_matrix.cc:55–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54template <typename BinIdxType>
55void CheckSparseColumn(SparseColumnIter<BinIdxType>* p_col, const GHistIndexMatrix& gmat) {
56 auto& col = *p_col;
57
58 size_t n_samples = gmat.row_ptr.size() - 1;
59 ASSERT_EQ(col.Size(), gmat.index.Size());
60 for (auto i = 0ull; i < col.Size(); i++) {
61 ASSERT_EQ(gmat.index[gmat.row_ptr[col.GetRowIdx(i)]], col.GetGlobalBinIdx(i));
62 }
63
64 for (auto i = 0ull; i < n_samples; i++) {
65 if (col[i] == Column<BinIdxType>::kMissingId) {
66 auto beg = gmat.row_ptr[i];
67 auto end = gmat.row_ptr[i + 1];
68 ASSERT_EQ(end - beg, 0);
69 }
70 }
71}
72
73TEST(ColumnMatrix, SparseColumn) {
74 int32_t max_num_bins[] = {static_cast<int32_t>(std::numeric_limits<uint8_t>::max()) + 1,

Callers 1

TESTFunction · 0.85

Calls 4

GetRowIdxMethod · 0.80
GetGlobalBinIdxMethod · 0.80
sizeMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected