Skip to content

Commit f9fb121

Browse files
authored
Merge pull request #536 from MysaaJava/contribution
Changing Exception() uses to more specific subclasses
2 parents 718ae3b + 2d529bf commit f9fb121

20 files changed

+39
-35
lines changed

logo/logo.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def get_h_line(input_tracker):
9898
graph_dot_p2.move_to(get_graph_point(input_tracker_p2))
9999

100100
#
101-
self.play(ShowCreation(graph),)
101+
self.play(ShowCreation(graph))
102102
# Animacion del punto a
103103
self.add_foreground_mobject(graph_dot_p1)
104104
self.add_foreground_mobject(graph_dot_p2)
@@ -150,7 +150,11 @@ def get_h_line(input_tracker):
150150
)
151151

152152
self.add(
153-
input_triangle_p2, graph_dot_p2, v_line_p2, h_line_p2, output_triangle_p2,
153+
input_triangle_p2,
154+
graph_dot_p2,
155+
v_line_p2,
156+
h_line_p2,
157+
output_triangle_p2,
154158
)
155159
self.play(FadeIn(grupo_secante))
156160

manim/animation/creation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def interpolate_submobject(self, submob, start_submob, alpha):
3737
submob.pointwise_become_partial(start_submob, *self.get_bounds(alpha))
3838

3939
def get_bounds(self, alpha):
40-
raise Exception("Not Implemented")
40+
raise NotImplementedError()
4141

4242

4343
class ShowCreation(ShowPartial):
@@ -69,7 +69,7 @@ def __init__(self, vmobject, **kwargs):
6969

7070
def check_validity_of_input(self, vmobject):
7171
if not isinstance(vmobject, VMobject):
72-
raise Exception("DrawBorderThenFill only works for VMobjects")
72+
raise TypeError("DrawBorderThenFill only works for VMobjects")
7373

7474
def begin(self):
7575
self.outline = self.get_outline()

manim/animation/numbers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, decimal_mob, number_update_func, **kwargs):
2323

2424
def check_validity_of_input(self, decimal_mob):
2525
if not isinstance(decimal_mob, DecimalNumber):
26-
raise Exception("ChangingDecimal can only take " "in a DecimalNumber")
26+
raise TypeError("ChangingDecimal can only take in a DecimalNumber")
2727

2828
def yell_about_depricated_configuration(self, **kwargs):
2929
# Obviously this would optimally be removed at

manim/animation/specialized.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, car, target_point, **kwargs):
2929

3030
def check_if_input_is_car(self, car):
3131
if not isinstance(car, Car):
32-
raise Exception("MoveCar must take in Car object")
32+
raise TypeError("MoveCar must take in Car object")
3333

3434
def begin(self):
3535
super().begin()

manim/animation/transform.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def create_target(self):
8484
def check_target_mobject_validity(self):
8585
if self.target_mobject is None:
8686
message = "{}.create_target not properly implemented"
87-
raise Exception(message.format(self.__class__.__name__))
87+
raise NotImplementedError(message.format(self.__class__.__name__))
8888

8989
def clean_up_from_scene(self, scene):
9090
super().clean_up_from_scene(scene)
@@ -157,7 +157,7 @@ def __init__(self, mobject, **kwargs):
157157

158158
def check_validity_of_input(self, mobject):
159159
if not hasattr(mobject, "target"):
160-
raise Exception(
160+
raise ValueError(
161161
"MoveToTarget called on mobject" "without attribute 'target'"
162162
)
163163

@@ -179,7 +179,7 @@ def __init__(self, method, *args, **kwargs):
179179

180180
def check_validity_of_input(self, method):
181181
if not inspect.ismethod(method):
182-
raise Exception(
182+
raise ValueError(
183183
"Whoops, looks like you accidentally invoked "
184184
"the method you want to animate"
185185
)
@@ -244,7 +244,7 @@ def __init__(self, function, mobject, **kwargs):
244244
def create_target(self):
245245
target = self.function(self.mobject.copy())
246246
if not isinstance(target, Mobject):
247-
raise Exception(
247+
raise TypeError(
248248
"Functions passed to ApplyFunction must return object of type Mobject"
249249
)
250250
return target
@@ -266,7 +266,7 @@ def initialize_matrix(self, matrix):
266266
new_matrix[:2, :2] = matrix
267267
matrix = new_matrix
268268
elif matrix.shape != (3, 3):
269-
raise Exception("Matrix has bad dimensions")
269+
raise ValueError("Matrix has bad dimensions")
270270
return matrix
271271

272272

manim/mobject/coordinate_systems.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def __init__(self, dim=2):
4141
self.y_max = config["frame_y_radius"]
4242

4343
def coords_to_point(self, *coords):
44-
raise Exception("Not implemented")
44+
raise NotImplementedError()
4545

4646
def point_to_coords(self, point):
47-
raise Exception("Not implemented")
47+
raise NotImplementedError()
4848

4949
def c2p(self, *coords):
5050
"""Abbreviation for coords_to_point"""
@@ -55,7 +55,7 @@ def p2c(self, point):
5555
return self.point_to_coords(point)
5656

5757
def get_axes(self):
58-
raise Exception("Not implemented")
58+
raise NotImplementedError()
5959

6060
def get_axis(self, index):
6161
return self.get_axes()[index]

manim/mobject/mobject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ def set_colors_by_radial_gradient(
670670

671671
def set_submobject_colors_by_gradient(self, *colors):
672672
if len(colors) == 0:
673-
raise Exception("Need at least one color")
673+
raise ValueError("Need at least one color")
674674
elif len(colors) == 1:
675675
return self.set_color(*colors)
676676

@@ -1182,6 +1182,6 @@ class Group(Mobject):
11821182

11831183
def __init__(self, *mobjects, **kwargs):
11841184
if not all([isinstance(m, Mobject) for m in mobjects]):
1185-
raise Exception("All submobjects must be of type Mobject")
1185+
raise TypeError("All submobjects must be of type Mobject")
11861186
Mobject.__init__(self, **kwargs)
11871187
self.add(*mobjects)

manim/mobject/svg/drawings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ def __init__(self, suit_name, **kwargs):
10011001
"clubs": self.black,
10021002
}
10031003
if suit_name not in suits_to_colors:
1004-
raise Exception("Invalid suit name")
1004+
raise ValueError("Invalid suit name")
10051005
SVGMobject.__init__(self, file_name=suit_name, **kwargs)
10061006

10071007
color = suits_to_colors[suit_name]

manim/mobject/svg/svg_mobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def handle_command(self, command, coord_string):
396396
# TODO, this is a suboptimal approximation
397397
new_points = np.append([new_points[0]], new_points, axis=0)
398398
elif command == "A": # elliptical Arc
399-
raise Exception("Not implemented")
399+
raise NotImplementedError()
400400
elif command == "Z": # closepath
401401
return
402402

manim/mobject/svg/tex_mobject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def set_color_by_tex_to_color_map(self, texs_to_color_map, **kwargs):
286286
def index_of_part(self, part):
287287
split_self = self.split()
288288
if part not in split_self:
289-
raise Exception("Trying to get index of part not in MathTex")
289+
raise ValueError("Trying to get index of part not in MathTex")
290290
return split_self.index(part)
291291

292292
def index_of_part_by_tex(self, tex, **kwargs):
@@ -341,7 +341,7 @@ def fade_all_but(self, index_or_string, opacity=0.5):
341341
elif isinstance(arg, int):
342342
part = self.submobjects[arg]
343343
else:
344-
raise Exception("Expected int or string, got {0}".format(arg))
344+
raise TypeError("Expected int or string, got {0}".format(arg))
345345
for other_part in self.submobjects:
346346
if other_part is part:
347347
other_part.set_fill(opacity=1)

0 commit comments

Comments
 (0)