Skip to content

Counting number of scene.play and wait calls #214

@huguesdevimeux

Description

@huguesdevimeux

I'm refactoring the progressbar and t-values generation. See #183

I'm facing an issue ; I would like to be able to count the number of calls of scene.play or scene.wait in construct() defintion, because I need to know when is the last animation.

As far as I know there is no way to do it in manim, as right now manim just takes scene.play and scene.wait one after the other (so it does not need to get the total number of scene.play and scene.wait calls.

So, to do that, I think the only solution is to disassemble construct function to get the number CALL_FUNCTION instances with scene.play and scene.wait. Something like this https://stackoverflow.com/a/16042229/12009882

But my question is, is it good? Like, is it ok to have something like this? Because this method is slightly too much hacky in my mind (although it would work and is not very complicated).

Maybe this is totally fine and I'm just nitpicking, please tell me :D

EDIT : Looking for CALL_FUNCTION in function's instructions (disassembled) won't work as the name of the function does not appear. Instead, we can look for LOAD_METHOD with argval 'wait' or 'play'.
Example :

Instruction(opname='LOAD_METHOD', opcode=160, arg=3, argval='wait', argrepr='wait', offset=22, starts_line=None, is_jump_target=False)

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedWe would appreciate help on this issue/PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions