Skip to content

Commit

Permalink
Code comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Jan 11, 2022
1 parent e7c68ca commit d3b325d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/tree/tree_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -893,21 +893,21 @@ void RegTree::Save(dmlc::Stream* fo) const {
}
}
}

// typed array, not boolean
template <typename JT, typename T>
std::enable_if_t<!std::is_same<T, Json>::value && !std::is_same<JT, Boolean>::value, T> GetElem(
std::vector<T> const& arr, size_t i) {
return arr[i];
}

// typed array boolean
template <typename JT, typename T>
std::enable_if_t<!std::is_same<T, Json>::value && std::is_same<T, uint8_t>::value &&
std::is_same<JT, Boolean>::value,
bool>
GetElem(std::vector<T> const& arr, size_t i) {
return arr[i] == 1;
}

// json array
template <typename JT, typename T>
std::enable_if_t<
std::is_same<T, Json>::value,
Expand Down Expand Up @@ -966,7 +966,7 @@ void RegTree::LoadCategoricalSplit(Json const& in) {

++cnt;
if (cnt == categories_nodes.size()) {
last_cat_node = -1;
last_cat_node = -1; // Don't break, we still need to initialize the remaining nodes.
} else {
last_cat_node = GetElem<Integer>(categories_nodes, cnt);
}
Expand All @@ -987,8 +987,8 @@ void RegTree::SaveCategoricalSplit(Json* p_out) const {

I64Array categories_segments;
I64Array categories_sizes;
I32Array categories;
I32Array categories_nodes;
I32Array categories; // bst_cat_t = int32_t
I32Array categories_nodes; // bst_note_t = int32_t

for (size_t i = 0; i < nodes_.size(); ++i) {
if (this->split_types_[i] == FeatureType::kCategorical) {
Expand Down

0 comments on commit d3b325d

Please sign in to comment.