fix VShowPassingFlash index out of bounds issue #2059
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Animation VShowPassingFlash often encounters an IndexError: index 0 is out of bounds for axis 0 with size 0.
for example:
The error message is as follows:
File "test.py", line 9, in construct
self.play(VShowPassingFlash(s))
File "manimlib/scene/scene.py", line 405, in wrapper
func(self, *args, **kwargs)
File "manimlib/scene/scene.py", line 661, in play
self.begin_animations(animations)
File "manimlib/scene/scene.py", line 616, in begin_animations
animation.begin()
File "site-packages/manimlib/animation/indication.py", line 227, in begin
super().begin()
File "manimlib/animation/animation.py", line 79, in begin
self.interpolate(0)
File "manimlib/animation/animation.py", line 143, in interpolate
self.interpolate_mobject(alpha)
File "manimlib/animation/animation.py", line 155, in interpolate_mobject
self.interpolate_submobject(*mobs, sub_alpha)
File "manimlib/animation/indication.py", line 247, in interpolate_submobject
submobject.set_stroke(width=widths * gaussian)
File "manimlib/mobject/types/vectorized_mobject.py", line 207, in set_stroke
data['stroke_width'][:, 0] = resize_with_interpolation(
File "manimlib/utils/iterables.py", line 109, in resize_with_interpolation
return np.array([
File "manimlib/utils/iterables.py", line 110, in
(1 - a) * nparray[lh] + a * nparray[rh]
IndexError: index 0 is out of bounds for axis 0 with size 0
Proposed changes
Test
Code:
Result: