diff --git a/src/kbmod/search/pydocs/stack_search_docs.h b/src/kbmod/search/pydocs/stack_search_docs.h index 4ce0edb62..99b29a470 100644 --- a/src/kbmod/search/pydocs/stack_search_docs.h +++ b/src/kbmod/search/pydocs/stack_search_docs.h @@ -188,6 +188,15 @@ static const auto DOC_StackSearch_prepare_batch_search = R"doc( The minimum number of observations for a trajectory to be considered. )doc"; +static const auto DOC_StackSearch_compute_max_results = R"doc( + Compute the maximum number of results according to the x, y bounds and the RESULTS_PER_PIXEL constant + + Returns + ------- + max_results : `int` + The maximum number of results that a search will return according to the current bounds and the RESULTS_PER_PIXEL constant. + )doc"; + static const auto DOC_StackSearch_search_single_batch = R"doc( Perform a search on the given trajectories for the current batch. Batch is defined by the parameters set `set_start_bounds_x` & `set_start_bounds_y`. diff --git a/src/kbmod/search/stack_search.cpp b/src/kbmod/search/stack_search.cpp index d3137a650..6d3aeaa2a 100644 --- a/src/kbmod/search/stack_search.cpp +++ b/src/kbmod/search/stack_search.cpp @@ -187,7 +187,7 @@ void StackSearch::search_batch(){ } DebugTimer core_timer = DebugTimer("Running batch search", rs_logger); - int max_results = extract_max_results(); + int max_results = compute_max_results(); // staple C++ std::stringstream logmsg; @@ -200,7 +200,7 @@ void StackSearch::search_batch(){ results.resize(max_results); results.move_to_gpu(); - // Do the actual search on the GPU. + // Do the actual search on the GPU. DebugTimer search_timer = DebugTimer("Running search", rs_logger); #ifdef HAVE_CUDA deviceSearchFilter(psi_phi_array, params, gpu_search_list, results); @@ -217,13 +217,13 @@ void StackSearch::search_batch(){ } std::vector StackSearch::search_single_batch(){ - int max_results = extract_max_results(); + int max_results = compute_max_results(); search_batch(); return results.get_batch(0, max_results); } -int StackSearch::extract_max_results(){ +int StackSearch::compute_max_results(){ int search_width = params.x_start_max - params.x_start_min; int search_height = params.y_start_max - params.y_start_min; int num_search_pixels = search_width * search_height; @@ -307,6 +307,7 @@ static void stack_search_bindings(py::module& m) { .def("clear_psi_phi", &ks::clear_psi_phi, pydocs::DOC_StackSearch_clear_psi_phi) .def("get_results", &ks::get_results, pydocs::DOC_StackSearch_get_results) .def("set_results", &ks::set_results, pydocs::DOC_StackSearch_set_results) + .def("compute_max_results", &ks::compute_max_results, pydocs::DOC_StackSearch_compute_max_results) .def("search_single_batch", &ks::search_single_batch, pydocs::DOC_StackSearch_search_single_batch) .def("prepare_search", &ks::prepare_search, pydocs::DOC_StackSearch_prepare_batch_search) .def("finish_search", &ks::finish_search, pydocs::DOC_StackSearch_finish_search); diff --git a/src/kbmod/search/stack_search.h b/src/kbmod/search/stack_search.h index befc038b9..5b7906f7d 100644 --- a/src/kbmod/search/stack_search.h +++ b/src/kbmod/search/stack_search.h @@ -29,10 +29,9 @@ using Point = indexing::Point; using Image = search::Image; class StackSearch { - int extract_max_results(); public: StackSearch(ImageStack& imstack); - + int compute_max_results(); int num_images() const { return stack.img_count(); } int get_image_width() const { return stack.get_width(); } int get_image_height() const { return stack.get_height(); } diff --git a/tests/test_search.py b/tests/test_search.py index ebab5c6ac..3eefe8837 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -952,9 +952,6 @@ def test_search_batch(self): count = 10 imlist = [make_fake_layered_image(width, height, 5.0, 25.0, n / count, p) for n in range(count)] stack = ImageStack(imlist) - im_list = stack.get_images() - # Create a new list of LayeredImages with the added object. - new_im_list = [] for i in range(count): im = stack.get_single_image(i)