-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch search inside stack search #530
Merged
jeremykubica
merged 10 commits into
dirac-institute:main
from
vlnistor:I-356/batch-search
Apr 8, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e75f93f
batch search inside stack search
vlnistor 666d2e5
moved the batch search inside a context manager to remove the need to…
vlnistor 88d3289
fixed to include 2nd argument in prepare_batch
vlnistor 12894f8
conclude merge
vlnistor 0b25c32
resolving search_batch merge conflicts with main
vlnistor cbcaa9c
added move assignment operators for both TrajectoryList and GPUArray …
vlnistor cc5d52d
cleaned up comments
vlnistor 2106801
search_batch functionality extracted from search_all and search_singl…
vlnistor 9b5226f
renamed helper to compute_max_results and minor style changes
vlnistor 6180283
kbmod_reference notebook only change search.search -> search.search_all
vlnistor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class BatchSearchManager: | ||
def __init__(self, stack_search, search_list, min_observations): | ||
"""Manages a batch search over a list of Trajectory instances using a StackSearch instance. | ||
|
||
Parameters | ||
---------- | ||
stack_search: `StackSearch` | ||
StackSearch instance to use for the batch search. | ||
search_list: `list[Trajectory]` | ||
List of Trajectory instances to search along the stack. | ||
min_observations: `int` | ||
Minimum number of observations required to consider a candidate. | ||
""" | ||
self.stack_search = stack_search | ||
self.search_list = search_list | ||
self.min_observations = min_observations | ||
|
||
def __enter__(self): | ||
# Prepare memory for the batch search. | ||
self.stack_search.prepare_search(self.search_list, self.min_observations) | ||
return self.stack_search | ||
|
||
def __exit__(self, *_): | ||
""" | ||
This method is called when exiting the context. | ||
It cleans up resources by calling `finish_search` on the StackSearch instance. | ||
We return False to indicate that we do not want to suppress any exceptions that may have been raised. | ||
""" | ||
# Clean up | ||
self.stack_search.finish_search() | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main idea here was that I didn't want the user to have to call
prepare_batch_search
andfinish_search
manuallyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, but something to consider as a future extension: In theory this could be extended further by making this a generator:
where the
BatchSearchManager
tracks the block sizes to search, current block locations, etc.