Counting number of scene.play and wait calls
See original GitHub issueI’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 😄
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)
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (15 by maintainers)
@kilacoda I first tought to do this only for
construct()
, but as obvious as it may seem I didn’t think to do it with the wholeSceneClass
lol, I’m stupid. So thank you very much for bringing up this idea.The issue was/is that if these calls are outside the
construct
, then we won’t be able to detect them (except by doing a weird recursive thing that would take long). We should not have this issue if we take the source (or the disassembly) of the whole class as all thewait
/play
calls are supposedly within the latter.So I think this is impossible (without rewriting the whole codebase) Closing this.