Skip to content

Commit

Permalink
use member to save if ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
mnwright committed Apr 27, 2018
1 parent 1e25055 commit c54a045
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/Data.cpp
Expand Up @@ -22,7 +22,7 @@ namespace ranger {

Data::Data() :
num_rows(0), num_rows_rounded(0), num_cols(0), snp_data(0), num_cols_no_snp(0), externalData(true), index_data(0), max_num_unique_values(
0) {
0), order_snps(false) {
}

Data::~Data() {
Expand Down Expand Up @@ -264,6 +264,8 @@ void Data::orderSnpLevels(std::string dependent_variable_name, bool corrected_im
// Save order
snp_order[i] = order(means, false);
}

order_snps = true;
}

} // namespace ranger
Expand Down
11 changes: 5 additions & 6 deletions src/Data.h
Expand Up @@ -73,16 +73,13 @@ class Data {
}

// Order SNPs
if (snp_order.empty()) {
return result;
} else {
if (order_snps) {
if (col_permuted >= num_cols) {
return snp_order[col_permuted + no_split_variables.size() - 2 * num_cols_no_snp][result];
result = snp_order[col_permuted + no_split_variables.size() - 2 * num_cols_no_snp][result];
} else {
return snp_order[col - num_cols_no_snp][result];
result = snp_order[col - num_cols_no_snp][result];
}
}

return result;
}

Expand Down Expand Up @@ -200,6 +197,7 @@ class Data {

void setSnpOrder(std::vector<std::vector<size_t>>& snp_order) {
this->snp_order = snp_order;
order_snps = true;
}

protected:
Expand Down Expand Up @@ -228,6 +226,7 @@ class Data {

// Order of 0/1/2 for ordered splitting
std::vector<std::vector<size_t>> snp_order;
bool order_snps;
};

} // namespace ranger
Expand Down

0 comments on commit c54a045

Please sign in to comment.