Skip to content

Comments

Resolve issue hansalemaos#1#2

Open
ViniciusGGT wants to merge 3 commits intohansalemaos:mainfrom
ViniciusGGT:main
Open

Resolve issue hansalemaos#1#2
ViniciusGGT wants to merge 3 commits intohansalemaos:mainfrom
ViniciusGGT:main

Conversation

@ViniciusGGT
Copy link

Update calculate_all_coords(ends) to handle cases with no movement (d0 == 0 and d1 == 0), vertical-only movement (d0 == 0), and horizontal-only movement (d1 == 0)

…dle cases with no movement (d0 == 0 and d1 == 0), vertical-only movement (d0 == 0), and horizontal-only movement (d1 == 0)
Copilot AI review requested due to automatic review settings February 17, 2026 01:48
Copy link

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 updates calculate_all_coords(ends) to correctly handle edge cases where there is no movement or movement is purely vertical/horizontal, preventing invalid step sizes and division-by-zero in the line-generation logic.

Changes:

  • Add an early return for the “no movement” case (d0 == 0 and d1 == 0).
  • Add dedicated vertical-only (d0 == 0) and horizontal-only (d1 == 0) coordinate generation paths.
  • Preserve the existing general-case line interpolation for diagonal movement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

__init__.py Outdated
d0, d1 = np.diff(ends, axis=0)[0]

if d0 == 0 and d1 == 0:
return ends
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

In the d0 == 0 and d1 == 0 case, returning ends yields two identical points (shape (2, 2)), which then allows downstream logic (e.g., add_random_n_places in natural_mouse_movement) to introduce jitter/movement even though start==end. Consider returning a single-point path instead (e.g., just the start/end point) and cast to the same dtype as other branches (int32) for consistency.

Suggested change
return ends
# Start and end are the same point: return a single-point path as int32 for consistency.
return ends[[0]].astype(np.int32, copy=False)

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.

1 participant