Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions manim/mobject/types/vectorized_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2859,7 +2859,8 @@ def _throw_error_if_no_submobjects(self):
if len(self.submobjects) == 0:
caller_name = sys._getframe(1).f_code.co_name
raise Exception(
f"Cannot call CurvesAsSubmobjects. {caller_name} for a CurvesAsSubmobject with no submobjects"
f"Cannot call {type(self).__name__}.{caller_name} "
f"for a {type(self).__name__} with no submobjects"
)

def _get_submobjects_with_points(self):
Expand All @@ -2869,7 +2870,8 @@ def _get_submobjects_with_points(self):
if len(submobjs_with_pts) == 0:
caller_name = sys._getframe(1).f_code.co_name
raise Exception(
f"Cannot call CurvesAsSubmobjects. {caller_name} for a CurvesAsSubmobject whose submobjects have no points"
f"Cannot call {type(self).__name__}.{caller_name} "
f"for a {type(self).__name__} whose submobjects have no points"
)
return submobjs_with_pts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,3 +774,26 @@ def test_pointwise_become_partial_where_vmobject_is_self():
]
)
np.testing.assert_allclose(sq.points, expected_points)


@pytest.mark.parametrize("use_subclass", [False, True])
@pytest.mark.parametrize("empty_child", [False, True])
def test_curves_as_submobjects_errors_use_actual_class(use_subclass, empty_child):
class CustomCurves(CurvesAsSubmobjects):
pass

curves_class = CustomCurves if use_subclass else CurvesAsSubmobjects
curves = curves_class(VGroup())
if empty_child:
curves.add(VMobject())

with pytest.raises(Exception) as error:
curves.point_from_proportion(0)

reason = (
"whose submobjects have no points" if empty_child else "with no submobjects"
)
class_name = curves_class.__name__
assert str(error.value) == (
f"Cannot call {class_name}.point_from_proportion for a {class_name} {reason}"
)