Manim: ThreeDScene.move_camera() results in NotImplementedError

Created on 2 Jun 2020  路  9Comments  路  Source: ManimCommunity/manim

Commit 62050bbb04a1f8e481972e1db36f2634dfbae425 changes the pass statements of some methods in Mobject() into NotImplementedError .

This causes the move_camera method in a ThreeDScene or SpecialThreeDScene to fail, throwing a NotImplementedError, as it uses the interpolate_color method of Mobject.

from manim import *

class TestScene(SpecialThreeDScene):
    def construct(self):
        self.move_camera(
            **self.default_angled_camera_position,
            run_time=1,
        )

The snippet above triggers the NotImplementedError in the interpolate_color method of Mobject()

This could be fixed by reverting the NotImplementedError of the interpolate_color method back into the pass statement that it originally was.

I think it would also prove fruitful if the methods become_partial and pointwise_become_partial also just had pass statements as they could also result in another method somewhere else not working properly.

bug

Most helpful comment

Yes, become_partial is really useless because its function may be the same as pointwise_become_partial, and the latter is implemented by subclass.

All 9 comments

Wait so this snippet is calling interpolate_color which is currently set to raise a NotImplementedError?

The fix then should be to make a decision as to whether or not call that function, instead of calling a function that does nothing, no?

In hindsight, yeah, that would be the right solution.

I've removed the methods that must be implemented in subclasses and made manim only call interpolate_color if the Mobject has such a method. I'll test it some more and make a PR in some hours time.

I think it is possible to keep NotImplementedError for these methods of Mobject, but write these methods for all its subclasses, and just treat Mobject as a similar abstract class, which will be more clear.

Now only ValueTracker is a direct subclass of Mobject, so you can write interpolate_color or interpolate methods for ValueTracker, which can solve this problem and make the code clearer.

Now only ValueTracker is a direct subclass of Mobject

VMobject, PMobject, ImageMobject are also direct subclasses of it.

These are the only ones with custom interpolate_color method.

VMobject, PMobject, ImageMobject are also direct subclasses of it.

These are the only ones with custom interpolate_color method.

I mean ValueTracker is the only subclass that directly inherits from Mobject, but does not implement these methods.
While other VMobject, PMobject, ImageMobject have implemented interpolate method or interpolate_color method. So just implement the interpolate method for ValueTracker.

Why should ValueTracker even have an interpolate_color method? It isn't a coloured Mobject right?

I think the best way would be to remove the methods that need to be implemented by children, and only use those methods if the child has them.

I say interpolate method which to interpolate between two ValueTracker, not interpolate_color.
If ValueTracker has interpolate method, it won't call the interpolate_color method, and there is actually no use of interpolate_color for ValueTracker.
Isn't this better.

Oh, I see what you mean. That's a better way.

Also, this is slightly unrelated, but I found that the method become_partial is not mentioned anywhere in the code other than as its definition in Mobject. Should it be removed outright?

Yes, become_partial is really useless because its function may be the same as pointwise_become_partial, and the latter is implemented by subclass.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

huguesdevimeux picture huguesdevimeux  路  5Comments

naveen521kk picture naveen521kk  路  5Comments

XorUnison picture XorUnison  路  6Comments

kolibril13 picture kolibril13  路  5Comments

naveen521kk picture naveen521kk  路  4Comments