stop rejecting grid index 0 in set_value_from_xy_pos and set_value_from_xy_index#1386
Open
HrachShah wants to merge 1 commit into
Open
stop rejecting grid index 0 in set_value_from_xy_pos and set_value_from_xy_index#1386HrachShah wants to merge 1 commit into
HrachShah wants to merge 1 commit into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
GridMap.set_value_from_xy_pos used
if (not x_ind) or (not y_ind):to bail out for out-of-bounds coordinates, butnot 0isTruein Python, so the valid grid index 0 was always rejected. The same guard in set_value_from_xy_index also returnedreturn False, False(a 2-tuple) from the None-guard branch while the other branches returned a plain bool, so any caller that didflag = set_value_from_xy_index(...); if flag: ...would silently getFalsefromif (False, False):for an out-of-bounds call (which is what we want), but more importantly theset_value_from_xy_poswrapper was throwing away values at index 0.Swapped both guards to
if (x_ind is None) or (y_ind is None):, made set_value_from_xy_index's None-branch return a plainFalseto match the other branches, and added a regression test in tests/test_grid_map_lib.py that sets a value at (0, 0) and confirms it lands ingrid_map.data[0].