Skip to content

Commit

Permalink
Make the vectors const
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremykubica committed Sep 18, 2024
1 parent 3f9e86b commit e838ca1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 deletions src/kbmod/search/stack_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ uint64_t StackSearch::compute_max_results() {
return num_search_pixels * params.results_per_pixel;
}

std::vector<float> StackSearch::extract_psi_or_phi_curve(Trajectory& trj, bool extract_psi) {
std::vector<float> StackSearch::extract_psi_or_phi_curve(const Trajectory& trj, bool extract_psi) {
prepare_psi_phi();

const unsigned int num_times = stack.img_count();
Expand All @@ -256,27 +256,27 @@ std::vector<float> StackSearch::extract_psi_or_phi_curve(Trajectory& trj, bool e
return result;
}

std::vector<std::vector<float> > StackSearch::get_psi_curves(std::vector<Trajectory>& trajectories) {
std::vector<std::vector<float> > StackSearch::get_psi_curves(const std::vector<Trajectory>& trajectories) {
std::vector<std::vector<float> > all_results;
for (auto& trj : trajectories) {
for (const auto& trj : trajectories) {
all_results.push_back(extract_psi_or_phi_curve(trj, true));
}
return all_results;
}

std::vector<float> StackSearch::get_psi_curves(Trajectory& trj) {
std::vector<float> StackSearch::get_psi_curves(const Trajectory& trj) {
return extract_psi_or_phi_curve(trj, true);
}

std::vector<std::vector<float> > StackSearch::get_phi_curves(std::vector<Trajectory>& trajectories) {
std::vector<std::vector<float> > StackSearch::get_phi_curves(const std::vector<Trajectory>& trajectories) {
std::vector<std::vector<float> > all_results;
for (auto& trj : trajectories) {
for (const auto& trj : trajectories) {
all_results.push_back(extract_psi_or_phi_curve(trj, false));
}
return all_results;
}

std::vector<float> StackSearch::get_phi_curves(Trajectory& trj) {
std::vector<float> StackSearch::get_phi_curves(const Trajectory& trj) {
return extract_psi_or_phi_curve(trj, false);
}

Expand Down Expand Up @@ -322,14 +322,14 @@ static void stack_search_bindings(py::module& m) {
.def("get_imagestack", &ks::get_imagestack, py::return_value_policy::reference_internal,
pydocs::DOC_StackSearch_get_imagestack)
// For testings
.def("get_psi_curves", (std::vector<float>(ks::*)(tj&)) & ks::get_psi_curves,
.def("get_psi_curves", (std::vector<float>(ks::*)(const tj&)) & ks::get_psi_curves,
pydocs::DOC_StackSearch_get_psi_curves)
.def("get_phi_curves", (std::vector<float>(ks::*)(tj&)) & ks::get_phi_curves,
.def("get_phi_curves", (std::vector<float>(ks::*)(const tj&)) & ks::get_phi_curves,
pydocs::DOC_StackSearch_get_phi_curves)
.def("get_psi_curves",
(std::vector<std::vector<float> >(ks::*)(std::vector<tj>&)) & ks::get_psi_curves)
(std::vector<std::vector<float> >(ks::*)(const std::vector<tj>&)) & ks::get_psi_curves)
.def("get_phi_curves",
(std::vector<std::vector<float> >(ks::*)(std::vector<tj>&)) & ks::get_phi_curves)
(std::vector<std::vector<float> >(ks::*)(const std::vector<tj>&)) & ks::get_phi_curves)
.def("prepare_psi_phi", &ks::prepare_psi_phi, pydocs::DOC_StackSearch_prepare_psi_phi)
.def("clear_psi_phi", &ks::clear_psi_phi, pydocs::DOC_StackSearch_clear_psi_phi)
.def("get_number_total_results", &ks::get_number_total_results,
Expand Down
10 changes: 5 additions & 5 deletions src/kbmod/search/stack_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class StackSearch {
std::vector<Trajectory> get_results(uint64_t start, uint64_t count);

// Getters for the Psi and Phi data.
std::vector<float> get_psi_curves(Trajectory& t);
std::vector<float> get_phi_curves(Trajectory& t);
std::vector<std::vector<float> > get_psi_curves(std::vector<Trajectory>& trajectories);
std::vector<std::vector<float> > get_phi_curves(std::vector<Trajectory>& trajectories);
std::vector<float> get_psi_curves(const Trajectory& t);
std::vector<float> get_phi_curves(const Trajectory& t);
std::vector<std::vector<float> > get_psi_curves(const std::vector<Trajectory>& trajectories);
std::vector<std::vector<float> > get_phi_curves(const std::vector<Trajectory>& trajectories);

// Helper functions for computing Psi and Phi
void prepare_psi_phi();
Expand All @@ -75,7 +75,7 @@ class StackSearch {
virtual ~StackSearch(){};

protected:
std::vector<float> extract_psi_or_phi_curve(Trajectory& trj, bool extract_psi);
std::vector<float> extract_psi_or_phi_curve(const Trajectory& trj, bool extract_psi);

// Core data and search parameters. Note the StackSearch does not own
// the ImageStack and it must exist for the duration of the object's life.
Expand Down

0 comments on commit e838ca1

Please sign in to comment.