-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Counting number of scene.play and wait calls #214
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
Comments
Instead of disassembling a function, just keep an instance member that counts the number of times these have been called.
|
I know, but I need to get the number of play and On second thought, I don't think that using disassembling is not orthodox. I think I will use that, if no one objects :D. |
I think it's fair game, though the inspect module in general tends to be a bit slow. Would be interesting to see if there are any speed changes after your PR. |
That's a problem. But there is another that I didn't think about: when So I don't think its possible to count number of |
One workaround (that would require a major rewrite of some parts of manim) is to implement scene rendering in a lazy fashion allowing for dry runs. For example, you can run all of deconstruct without actually rendering anything, just changing the coordinates/colors/etc of your abstract mobjects. After that dry run, you can easily get the count of play/wait, as well as many other Things About the Scene that may be interesting on their own accord. After that you can actually do the rendering. BTW, such a system might also help the scene caching stuff. |
This is a brilliant idea, but IMO this is too much work for what we need. Unless there are other projects of features that would need this kind of thing, I think this is worthless.
And could you clarify this point ? I don't see why this could improve caching. |
If we had such an abstract system detached from the rendering system, we could run the old Scene and the new Scene without rendering them to determine whether they are the same. If they are, then don't render the new one. |
But I agree that would require a major rewrite of basically everything.. |
I see. This is pretty much what it does in scene caching.
In fact this could be easily done with a decorator placed for |
Ugh let's not pickle things unless absolutely necessary :) |
Then I don't see how we could do without calling |
What's the problem with using |
@kilacoda I first tought to do this only for The issue was/is that if these calls are outside the |
@kilacoda On second thought it won't work when there is a loop. Like, manim will be trick into finding only one |
So I think this is impossible (without rewriting the whole codebase) |
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
orscene.wait
inconstruct()
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
andscene.wait
one after the other (so it does not need to get the total number ofscene.play
andscene.wait
calls.So, to do that, I think the only solution is to disassemble
construct
function to get the numberCALL_FUNCTION
instances withscene.play
andscene.wait
. Something like this https://stackoverflow.com/a/16042229/12009882But 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)
The text was updated successfully, but these errors were encountered: