Skip to content

Conversation

Copy link

Copilot AI commented Nov 12, 2025

Adds comprehensive edge case tests for make_line_straight and make_line_angled functions introduced in the refactoring.

Test Coverage

make_line_straight (8 tests):

  • Boundary slopes: horizontal (m=0), vertical (m=∞), diagonal (m=±1)
  • Extreme slopes: steep (|m|>1), shallow (|m|<1)
  • Grid boundaries and short 2-point lines

make_line_angled (11 tests):

  • Cardinal angles: 0, π/2, -π/2, π
  • All quadrants: π/4, 3π/4, -π/4, -3π/4
  • Edge cases: zero length, boundary exceeding, angle wrapping (>2π)
  • Grid size variations

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.

Copilot AI mentioned this pull request Nov 12, 2025
1 task
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: waltsims <8669206+waltsims@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor make_line function to separate concerns Add edge case tests for refactored make_line functions Nov 12, 2025
Copilot AI requested a review from waltsims November 12, 2025 14:27
Copilot finished work on behalf of waltsims November 12, 2025 14:27
@waltsims waltsims requested review from Copilot and removed request for waltsims November 12, 2025 15:24
Copilot finished reviewing on behalf of waltsims November 12, 2025 15:28
Copy link
Contributor

Copilot AI left a 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 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_straight covering boundary slopes, extreme slopes, and grid boundaries
  • Adds 11 new tests for make_line_angled covering 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"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using == True is redundant in boolean assertions. Use assert line[0, 9] instead of assert line[0, 9] == True for more Pythonic code.

Suggested change
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"

Copilot uses AI. Check for mistakes.

# 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"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
assert np.allclose(line, line_pi), "Angle wrapping should work correctly"
assert np.array_equal(line, line_pi), "Angle wrapping should work correctly"

Copilot uses AI. Check for mistakes.

# 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"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using == True is redundant in boolean assertions. Use assert line[0, 0] instead of assert line[0, 0] == True for more Pythonic code.

Copilot uses AI. Check for mistakes.

# 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"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using == True is redundant in boolean assertions. Use assert line[9, 0] instead of assert line[9, 0] == True for more Pythonic code.

Suggested change
assert line[9, 0] == True, "First point should be at bottom-left"
assert line[9, 0], "First point should be at bottom-left"

Copilot uses AI. Check for mistakes.

# 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"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using == True is redundant in boolean assertions. Use assert line[0, 0] instead of assert line[0, 0] == True for more Pythonic code.

Suggested change
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"

Copilot uses AI. Check for mistakes.

# 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"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using == True is redundant in boolean assertions. Use assert line[4, 4] instead of assert line[4, 4] == True for more Pythonic code.

Suggested change
assert line[4, 4] == True, "Starting point should be marked"
assert line[4, 4], "Starting point should be marked"

Copilot uses AI. Check for mistakes.
Comment on lines +117 to +119
grid_size = Vector([20, 10])
startpoint = (2, 5)
endpoint = (18, 7) # Steep line, mostly vertical
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +131 to +132
startpoint = (5, 2)
endpoint = (7, 18) # Shallow line, mostly horizontal
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
startpoint = (5, 2)
endpoint = (7, 18) # Shallow line, mostly horizontal
startpoint = (2, 5)
endpoint = (18, 7) # Shallow line, mostly horizontal

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants