MCPcopy Index your code
hub / github.com/ManimCommunity/manim / _assert_valid_submobjects_internal

Method _assert_valid_submobjects_internal

manim/mobject/mobject.py:153–176  ·  view source on GitHub ↗
(
        self, submobjects: list[Mobject], mob_class: type[Mobject]
    )

Source from the content-addressed store, hash-verified

151 return self._assert_valid_submobjects_internal(submobjects, Mobject)
152
153 def _assert_valid_submobjects_internal(
154 self, submobjects: list[Mobject], mob_class: type[Mobject]
155 ) -> Self:
156 for i, submob in enumerate(submobjects):
157 if not isinstance(submob, mob_class):
158 error_message = (
159 f"Only values of type {mob_class.__name__} can be added "
160 f"as submobjects of {type(self).__name__}, but the value "
161 f"{submob} (at index {i}) is of type "
162 f"{type(submob).__name__}."
163 )
164 # Intended for subclasses such as VMobject, which
165 # cannot have regular Mobjects as submobjects
166 if isinstance(submob, Mobject):
167 error_message += (
168 " You can try adding this value into a Group instead."
169 )
170 raise TypeError(error_message)
171 if submob is self:
172 raise ValueError(
173 f"Cannot add {type(self).__name__} as a submobject of "
174 f"itself (at index {i})."
175 )
176 return self
177
178 @classmethod
179 def animation_override_for(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected