-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add first attempt on Hash-based box search #53
base: develop
Are you sure you want to change the base?
Conversation
# discretized_coords = [] | ||
# for coord in point: | ||
# discretized_coords.append(int((coord + sys.float_info.epsilon) // self.search_radius)) |
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.
Drop unused code
Initialize the box-based neighbors search algorithm. | ||
:param search_radius: minimal distance for particles to become neighbors | ||
:param epsilon: precision for distance calculation, set to 10e-8 by default | ||
:param domain_size: upper bound for the working domain |
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.
not all arguments have been documented. please add all args
self.epsilon = epsilon | ||
self.domain_size = domain_size | ||
self._verbose = verbose | ||
self.box_size = cell_size if cell_size is not None else self.search_radius |
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.
Why we have cell_size
input param? I believe it should always be calculated
self._boxes_in_row = round(self.domain_size / self.search_radius) | ||
self._total_boxes = self._boxes_in_row ** 2 | ||
self.hashed_box_id2points = {} | ||
self.box_id2hash = {} | ||
self.hash2box_id = {} | ||
self._int_neighbor_boxes_ids = None | ||
self._box_neighbors = self._find_neighbor_boxes() |
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.
Please add comments to these vars, the names are not self-explanatory.
col = int((point[0] + sys.float_info.epsilon) // self.search_radius) | ||
row = int((point[1] + sys.float_info.epsilon) // self.search_radius) | ||
discretized_point_coords = [col, row] | ||
box_id = int(row * self._boxes_in_row + col) |
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.
Why is there code instead of docs?
LOG.debug(message) | ||
|
||
@staticmethod | ||
def _get_hash(col: int, row: int) -> int: |
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.
Please add comments to all methods, including private
What does this PR do?
Add hash-based box search and tests.
Issue reference
Explanation
This PR brings first attempt to implement hash-based box search for neighbors search optimization.
How to get?
git clone --recursive -b feature/blabla [email protected]:aartiukh/sph.git