ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
26.48k stars 1.82k forks source link

feat: set_default for Animation class #3876

Closed christopher-hampson closed 4 months ago

christopher-hampson commented 4 months ago

Overview: What does this pull request change?

Adds set_default class method to Animation class based on existing implementation for Mobject class.

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

Addresses issue #3142

Links to added or changed documentation pages

Further Information and Comments

Reviewer Checklist

JasonGrace2282 commented 4 months ago

Hello, thanks for sending a PR for this feature :) Off of a quick look, the implementation seems fine (I'll take a closer look, hopefully later this week). Would you mind adding some tests for this behavior? Thanks for helping make Manim better :sparkles:

P.S. Don't worry about the pre-commit failure. We'll fix that in a different PR.

christopher-hampson commented 4 months ago

Just tested and it works for me! A simple test to add would be something like

def test_animation_set_default():
    s = Square()
    Rotate.set_default(run_time=100)
    anim = Rotate(s)
    assert anim.run_time == 100

Other than that, looks good to me :)

Thanks for reviewing and suggesting this test! I'll get this added shortly. :+1: