Mobject.split() behaves differently between Cairo and OpenGL
Description of bug / unexpected behavior
As mentioned in #4914, the behavior of split is different between the two types of Mobject. Here is the implementation of Mobject.split:
def split(self) -> list[Mobject]:
result: list[Mobject] = [self] if len(self.points) > 0 else []
return result + self.submobjectsand here is the implementation of OpenGLMobject.split:
def split(self) -> Sequence[OpenGLMobject]:
return self.submobjectsIn short, the Cairo version potentially includes the calling mobject itself if it has any points, and otherwise simply returns a copy of self.submobjects. The OpenGL version never includes the mobject itself and it doesn't copy self.submobjects but simply returns the list itself.
It seems like this difference has existed since OpenGLMobject was introduced in the library, and nothing has broken horribly, so probably this isn't a huge issue in Manim's own source code. It might confuse users who switch from one to the other, though.
Expected behavior
I expect both types of Mobject to behave identically. I don't know which is the correct behavior; the method has no docstring and I haven't been able to find a case where split is called on a mobject which both has 1) points and 2) submobjects, so it isn't clear to me how to find out.
How to reproduce the issue
Code for reproducing the problemclass SplitTest(Scene):
def construct(self):
mob = Circle().move_to((-2, 1, 0))
mob.add(Square().move_to((0, 1, 0)))
mob.add(Triangle().move_to((2, 1, 0)))
self.add(mob)
self.add(mob[:].copy().shift(DOWN * 2))Additional media files
Images/GIFsThis is the output when rendering with Cairo:
This is the output when rendering with OpenGL:
Logs
Terminal outputPASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILARSystem specifications
System Details- OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)):
- RAM:
- Python version (
python/py/python3 --version): - Installed modules (provide output from
pip list):
PASTE HERE- LaTeX distribution (e.g. TeX Live 2020):
- Installed LaTeX packages:
Additional comments
Source: ManimCommunity/manim