-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Add unit tests for A* path planner (PythonRobotics #123) #1234
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR enhances testing coverage for the A* path planner by adding two new unit tests that verify basic path generation functionality and the edge case where the start point equals the goal.
- Added a test to check that a generated path has matching start and end points, regardless of the order returned.
- Added a focused test for the scenario when the start equals the goal, ensuring the path contains exactly that one point.
Comments suppressed due to low confidence (1)
PathPlanning/AStar/test_astar_unit.py:5
- [nitpick] Consider adding docstrings to the test methods for clearer context and future maintainability.
class TestAStar(unittest.TestCase):
def test_basic_path(self): | ||
# create simple U-shaped obstacle walls | ||
ox = [i for i in range(60)] # bottom wall | ||
oy = [0 for _ in range(60)] | ||
|
||
for i in range(60): # right wall | ||
ox.append(60) | ||
oy.append(i) | ||
|
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.
[nitpick] If similar obstacle wall setups are used elsewhere, consider refactoring this pattern into a helper function to improve code reuse.
def test_basic_path(self): | |
# create simple U-shaped obstacle walls | |
ox = [i for i in range(60)] # bottom wall | |
oy = [0 for _ in range(60)] | |
for i in range(60): # right wall | |
ox.append(60) | |
oy.append(i) | |
def generate_u_shaped_obstacles(self): | |
ox = [i for i in range(60)] # bottom wall | |
oy = [0 for _ in range(60)] | |
for i in range(60): # right wall | |
ox.append(60) | |
oy.append(i) | |
return ox, oy | |
def test_basic_path(self): | |
# create simple U-shaped obstacle walls | |
ox, oy = self.generate_u_shaped_obstacles() |
Copilot uses AI. Check for mistakes.
from PathPlanning.AStar.a_star import AStarPlanner | ||
|
||
|
||
class TestAStar(unittest.TestCase): |
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.
@rsleiti There is already test file for AStar code. Please move this test code into this file.
https://github.com/AtsushiSakai/PythonRobotics/blob/master/tests/test_a_star.py
What does this implement/fix?
This pull request adds two
unittest
test cases for the A* path planner inPathPlanning/AStar/a_star.py
. The tests check basic path generation and the edge case where the start equals the goal.Why is this useful?
This improves testing coverage for a core algorithm in the PythonRobotics repository. It helps ensure the planner behaves correctly after future changes.
Checklist:
python3 -m PathPlanning.AStar.test_astar_unit