Skip to content

Commit

Permalink
Merge pull request #39 from DavisVaughan/feature/no-implicit-conversion
Browse files Browse the repository at this point in the history
Avoid implicit conversion from `sexp` to `double`
  • Loading branch information
Nowosad authored Aug 24, 2024
2 parents 4f4b113 + e75d9a2 commit 3f6587b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/create_connectivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void Slic::create_connectivity(doubles_matrix<> vals, cpp11::function avg_fun_fu
new_centers_vals[c_id][nval] = mean(new_c_id_centers_vals[nval]);
} else if (avg_fun_name.empty()){
// use user-defined function
new_centers_vals[c_id][nval] = avg_fun_fun(new_c_id_centers_vals[nval]);
new_centers_vals[c_id][nval] = cpp11::as_cpp<double>(avg_fun_fun(new_c_id_centers_vals[nval]));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/distances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ double get_vals_dist(vector<double>& values1, vector<double>& values2,
} else if (dist_name != ""){
return custom_distance(values1, values2, dist_name);
} else {
return dist_fun(values1, values2);
return cpp11::as_cpp<double>(dist_fun(values1, values2));
}
}

Expand Down Expand Up @@ -125,5 +125,5 @@ double custom_distance(vector<double>& values1, vector<double>& values2, std::st
double p = NA_REAL;
bool testNA = false;
std::string unit = "log2";
return single_distance(values1, values2, dist_name, p, testNA, unit);
return cpp11::as_cpp<double>(single_distance(values1, values2, dist_name, p, testNA, unit));
}
2 changes: 1 addition & 1 deletion src/generate_superpixels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void Slic::generate_superpixels(integers mat, doubles_matrix<> vals, double step
} else if (avg_fun_name == "mean2"){
centers_vals[c_id][nval] = mean(centers_vals_c_id[nval]);
} else if (avg_fun_name.empty()){
centers_vals[c_id][nval] = avg_fun_fun(centers_vals_c_id[nval]);
centers_vals[c_id][nval] = cpp11::as_cpp<double>(avg_fun_fun(centers_vals_c_id[nval]));
}
}
}
Expand Down

0 comments on commit 3f6587b

Please sign in to comment.