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

Function TEST

tests/cpp/tree/test_tree_model.cc:15–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14namespace xgboost {
15TEST(Tree, ModelShape) {
16 bst_feature_t n_features = std::numeric_limits<uint32_t>::max();
17 RegTree tree{1u, n_features};
18 ASSERT_EQ(tree.NumFeatures(), n_features);
19
20 {
21 // json
22 Json j_tree{Object{}};
23 tree.SaveModel(&j_tree);
24 std::vector<char> dumped;
25 Json::Dump(j_tree, &dumped);
26 RegTree new_tree;
27
28 auto j_loaded = Json::Load(StringView{dumped.data(), dumped.size()});
29 new_tree.LoadModel(j_loaded);
30 ASSERT_EQ(new_tree.NumFeatures(), n_features);
31 }
32 {
33 // ubjson
34 Json j_tree{Object{}};
35 tree.SaveModel(&j_tree);
36 std::vector<char> dumped;
37 Json::Dump(j_tree, &dumped, std::ios::binary);
38 RegTree new_tree;
39
40 auto j_loaded = Json::Load(StringView{dumped.data(), dumped.size()}, std::ios::binary);
41 new_tree.LoadModel(j_loaded);
42 ASSERT_EQ(new_tree.NumFeatures(), n_features);
43 }
44}
45
46TEST(Tree, AllocateNode) {
47 RegTree tree;

Callers

nothing calls this directly

Calls 15

CPUFunction · 0.85
DftBadValueFunction · 0.85
CheckReloadFunction · 0.85
GrowTreeFunction · 0.85
ConstructTreeFunction · 0.85
TestCategoricalTreeDumpFunction · 0.85
ExpandNodeMethod · 0.80
CollapseToLeafMethod · 0.80
NumExtraNodesMethod · 0.80
GetNodesMethod · 0.80
ExpandCategoricalMethod · 0.80
GetNumLeavesMethod · 0.80

Tested by

no test coverage detected