Skip to content
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

Fix Line failing with buff and path_arc (issue #4132) #4193

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

irvanalhaq9
Copy link
Contributor

@irvanalhaq9 irvanalhaq9 commented Mar 17, 2025

Overview: What does this pull request change?

Fixes issue: #4132

Motivation and Explanation: Why and how do your changes improve the library?

Issue Explanation

When buff is given, Line internally calls:

self.pointwise_become_partial(vmobject=self, a=buff_proportion, b=1 - buff_proportion)

(see: pointwise_become_partial in Line)

Since vmobject is self, modifying self.points also modifies vmobject.points.
This leads to a problem in the code (lines 1942-1949 and beyond),
where self.points = np.empty(...) also affects vmobject.points, erasing the data before it is used.

Solution

Before setting self.points = np.empty(...), we first make a copy of vmobject.points
to ensure we are working with valid data.

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

@irvanalhaq9
Copy link
Contributor Author

Seeking feedback from reviewers:

This PR modifies the pointwise_become_partial method. I made this change after investigating and tracing the last working commit for Line with buff and path_arc. I found that it worked correctly in commit 3a714115, but after commit 374eeeba, it no longer worked. It appears that PR #3760 introduced this issue (#4132).

Since that PR modified pointwise_become_partial, my initial fix focused on this method by making a copy of vmobject.points before setting self.points = np.empty(...) to prevent unintended in-place modifications.

However, I am now considering an alternative approach: instead of modifying pointwise_become_partial, a simpler solution might be to change how Line internally calls it. Instead of passing vmobject=self, what if we pass vmobject=self.copy()?

What do you think about this approach?
If this seems like a better solution, I can update the PR accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

1 participant