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 183: "t values issue that causes the animations to not be finished entirely" #698

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file not shown.
34 changes: 15 additions & 19 deletions tests/test_graphical_units/test_last_frame.py
@@ -1,31 +1,27 @@
import pytest

import manim as mn
from manim import color as C
from ..utils.testing_utils import get_scenes_to_test
from ..utils.GraphicalUnitTester import GraphicalUnitTester

mn.config.frame_rate = 5
mn.config.pixel_height = 150
mn.config.pixel_width = 150


def make_lbl(num):
text = mn.Text(f"{num}").scale(7)
text.num = num
return text


def update_lbl(lbl, dt):
lbl.num += 1
lbl.become(make_lbl(lbl.num))


class LastFrame(mn.Scene):
Copy link
Member

Choose a reason for hiding this comment

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

Comment/issue : I'm worry that it won't test anything, as graphical unit tests are run with the equivalent of -s flag ( every animation is skipped)
therfore, the last t value is always the run_time.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how this tests the change either...

Copy link
Member

Choose a reason for hiding this comment

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

I was going through older issues/PRs again and recall @kolibril13 mentioning a way to test video which is VERY applicable here as a way to test this PR. #1035

I recommend we test in this manner.

Copy link
Member

Choose a reason for hiding this comment

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

for the record, in #1019 I Implemented such tests on t values, so no need to implement this here.

def construct(self):
text = make_lbl(0).add_updater(update_lbl)
self.add(text)
sq = mn.Square(stroke_width=30).scale(3)
self.play(mn.ShowCreation(sq), run_time=1)
tick_start = 1.0
tick_end = 3.0
val_tracker = mn.ValueTracker(tick_start)
square = mn.Square(fill_opacity=1).set_stroke(width=0)
self.add(square)
num_colors = 1000
cols = mn.color_gradient([C.RED, C.WHITE, C.BLUE], num_colors)

def col_uptater(mob):
integ = int((val_tracker.get_value() - tick_start) / (tick_end - tick_start) * (num_colors - 1))
mob.set_color(cols[integ])

square.add_updater(col_uptater)
self.play(val_tracker.set_value, tick_end, rate_func=mn.linear, run_time=3)


MODULE_NAME = "last_frame"
Expand Down