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 @@ -2856,8 +2856,9 @@ def point_from_proportion(self, alpha: float) -> Point3D:
def _throw_error_if_no_submobjects(self):
if len(self.submobjects) == 0:
caller_name = sys._getframe(1).f_code.co_name
cls = type(self).__name__
raise Exception(
f"Cannot call CurvesAsSubmobjects. {caller_name} for a CurvesAsSubmobject with no submobjects"
f"Cannot call {cls}.{caller_name} for a {cls} with no submobjects"
)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,28 @@ def test_curves_as_submobjects_point_from_proportion():
np.testing.assert_array_equal(obj.point_from_proportion(0.5), np.array([3, 0, 0]))


def test_curves_as_submobjects_error_messages_use_the_actual_class_name():
class DerivedCurves(CurvesAsSubmobjects):
pass

obj = DerivedCurves(VGroup())

with pytest.raises(
Exception,
match=r"Cannot call DerivedCurves\.point_from_proportion for a "
r"DerivedCurves with no submobjects",
):
obj.point_from_proportion(0)

obj.add(VMobject())
with pytest.raises(
Exception,
match=r"Cannot call DerivedCurves\.point_from_proportion for a "
r"DerivedCurves whose submobjects have no points",
):
obj.point_from_proportion(0)


def test_vgroup_init():
"""Test the VGroup instantiation."""
VGroup()
Expand Down