Add edge case tests for refactored make_line functions#648
Add edge case tests for refactored make_line functions#648Copilot wants to merge 2 commits into263-refactor_make_linefrom
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
Co-authored-by: waltsims <8669206+waltsims@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive edge case tests for the refactored make_line_straight and make_line_angled functions, significantly expanding test coverage from 2 basic tests to 21 total tests.
- Adds 8 new tests for
make_line_straightcovering boundary slopes, extreme slopes, and grid boundaries - Adds 11 new tests for
make_line_angledcovering cardinal angles, all quadrants, and edge cases - All tests validate current behavior with 1-indexed coordinates
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Check that the line exists and is at the boundary | ||
| assert np.sum(line) > 0, "Line should have some points" | ||
| assert line[0, 9] == True, "First point should be at top-right corner" |
There was a problem hiding this comment.
Using == True is redundant in boolean assertions. Use assert line[0, 9] instead of assert line[0, 9] == True for more Pythonic code.
| assert line[0, 9] == True, "First point should be at top-right corner" | |
| assert line[0, 9], "First point should be at top-right corner" |
|
|
||
| # Compare with angle = π | ||
| line_pi = make_line(grid_size, startpoint, endpoint=None, angle=np.pi, length=length) | ||
| assert np.allclose(line, line_pi), "Angle wrapping should work correctly" |
There was a problem hiding this comment.
Using np.allclose for comparing boolean arrays is not ideal. Consider using np.array_equal(line, line_pi) instead, which is more appropriate for exact boolean array comparison.
| assert np.allclose(line, line_pi), "Angle wrapping should work correctly" | |
| assert np.array_equal(line, line_pi), "Angle wrapping should work correctly" |
|
|
||
| # Check that the line exists and is at the boundary | ||
| assert np.sum(line) > 0, "Line should have some points" | ||
| assert line[0, 0] == True, "First point should be at top-left corner" |
There was a problem hiding this comment.
Using == True is redundant in boolean assertions. Use assert line[0, 0] instead of assert line[0, 0] == True for more Pythonic code.
|
|
||
| # Check that the line exists and is at the boundary | ||
| assert np.sum(line) > 0, "Line should have some points" | ||
| assert line[9, 0] == True, "First point should be at bottom-left" |
There was a problem hiding this comment.
Using == True is redundant in boolean assertions. Use assert line[9, 0] instead of assert line[9, 0] == True for more Pythonic code.
| assert line[9, 0] == True, "First point should be at bottom-left" | |
| assert line[9, 0], "First point should be at bottom-left" |
|
|
||
| # Check that the line exists and is at the boundary | ||
| assert np.sum(line) > 0, "Line should have some points" | ||
| assert line[0, 0] == True, "First point should be at top-left corner" |
There was a problem hiding this comment.
Using == True is redundant in boolean assertions. Use assert line[0, 0] instead of assert line[0, 0] == True for more Pythonic code.
| assert line[0, 0] == True, "First point should be at top-left corner" | |
| assert line[0, 0], "First point should be at top-left corner" |
|
|
||
| # Check that we only have the starting point | ||
| assert np.sum(line) == 1, "Should only have the starting point" | ||
| assert line[4, 4] == True, "Starting point should be marked" |
There was a problem hiding this comment.
Using == True is redundant in boolean assertions. Use assert line[4, 4] instead of assert line[4, 4] == True for more Pythonic code.
| assert line[4, 4] == True, "Starting point should be marked" | |
| assert line[4, 4], "Starting point should be marked" |
| grid_size = Vector([20, 10]) | ||
| startpoint = (2, 5) | ||
| endpoint = (18, 7) # Steep line, mostly vertical |
There was a problem hiding this comment.
The comment states "Steep line, mostly vertical" but the coordinates suggest otherwise. With startpoint (2, 5) and endpoint (18, 7), the line has a slope of approximately 0.125 (delta_y=2, delta_x=16), making it a shallow, mostly horizontal line, not steep and vertical. Please correct the comment or adjust the test parameters.
| grid_size = Vector([20, 10]) | |
| startpoint = (2, 5) | |
| endpoint = (18, 7) # Steep line, mostly vertical | |
| grid_size = Vector([20, 20]) | |
| startpoint = (2, 5) | |
| endpoint = (4, 18) # Steep line, mostly vertical |
| startpoint = (5, 2) | ||
| endpoint = (7, 18) # Shallow line, mostly horizontal |
There was a problem hiding this comment.
The comment states "Shallow line, mostly horizontal" but the coordinates suggest otherwise. With startpoint (5, 2) and endpoint (7, 18), the line has a slope of 8 (delta_y=16, delta_x=2), making it a steep, mostly vertical line, not shallow and horizontal. Please correct the comment or adjust the test parameters.
| startpoint = (5, 2) | |
| endpoint = (7, 18) # Shallow line, mostly horizontal | |
| startpoint = (2, 5) | |
| endpoint = (18, 7) # Shallow line, mostly horizontal |
Adds comprehensive edge case tests for
make_line_straightandmake_line_angledfunctions introduced in the refactoring.Test Coverage
make_line_straight(8 tests):make_line_angled(11 tests):All 19 tests validate current behavior including 1-indexed coordinates and grid boundary handling.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.