Skip to content

Commit 668742c

Browse files
committed
fix exceptions
1 parent 1aa0a34 commit 668742c

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

examples/frame_5_8.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
> 1.0e-5
7474
):
7575
raise ValueError("Displacement calculation error")
76-
else:
77-
print("Displacement calculation OK")
76+
77+
print("Displacement calculation OK")
7878

7979
# print('Reference: ', [-0.02238452, 0.00419677, 0.00593197])
8080

examples/slanted_frame_7_3.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@
6161
m["joints"][1]["displacements"] - [8.8622e-05, -2.2798e-04, -1.8971e-02]
6262
) > 1.0e-3 * norm(m["joints"][1]["displacements"]):
6363
raise ValueError("Displacement calculation error")
64-
else:
65-
print("Displacement calculation OK")
64+
65+
print("Displacement calculation OK")
6666

6767
if norm(
6868
m["joints"][3]["displacements"] - [4.4311e-05, -4.6696e-02, 4.7854e-03]
6969
) > 1.0e-3 * norm(m["joints"][3]["displacements"]):
7070
raise ValueError("Displacement calculation error")
71-
else:
72-
print("Displacement calculation OK")
71+
72+
print("Displacement calculation OK")

examples/slanted_frame_7_3_1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
> 1.0e-3
6262
):
6363
raise ValueError("Displacement calculation error")
64-
else:
65-
print("Displacement calculation OK")
64+
65+
print("Displacement calculation OK")
6666

6767
plots.plot_setup(m)
6868
plots.plot_members(m)

pystran/model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def add_joint(m, identifier, coordinates):
5050
Add a joint to the model.
5151
"""
5252
if identifier in m["joints"]:
53-
raise Exception("Joint already exists")
53+
raise RuntimeError("Joint already exists")
5454
else:
5555
m["joints"][identifier] = {"coordinates": array(coordinates)}
5656
if m["joints"][identifier]["coordinates"].shape != (m["dim"],):
57-
raise Exception("Coordinate dimension mismatch")
57+
raise RuntimeError("Coordinate dimension mismatch")
5858
return None
5959

6060

@@ -63,7 +63,7 @@ def add_truss_member(m, identifier, connectivity, sect):
6363
Add a truss member to the model.
6464
"""
6565
if identifier in m["truss_members"]:
66-
raise Exception("Truss member already exists")
66+
raise RuntimeError("Truss member already exists")
6767
else:
6868
m["truss_members"][identifier] = {
6969
"connectivity": array(connectivity, dtype=numpy.int32),
@@ -77,7 +77,7 @@ def add_beam_member(m, identifier, connectivity, sect):
7777
Add a beam member to the model.
7878
"""
7979
if identifier in m["beam_members"]:
80-
raise Exception("Beam member already exists")
80+
raise RuntimeError("Beam member already exists")
8181
else:
8282
m["beam_members"][identifier] = {
8383
"connectivity": array(connectivity, dtype=numpy.int32),

pystran/plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def plot_shear_forces(m, scale=1.0):
287287
connectivity = member["connectivity"]
288288
i, j = m["joints"][connectivity[0]], m["joints"][connectivity[1]]
289289
if m["dim"] == 3:
290-
raise Exception("3D not implemented")
290+
raise NotImplementedError("3D not implemented")
291291
else:
292292
line = _plot_2d_beam_shear_forces(ax, member, i, j, scale)
293293
return ax
@@ -301,7 +301,7 @@ def plot_beam_orientation(m, scale=1.0):
301301
ci, cj = i["coordinates"], j["coordinates"]
302302
xm = (ci + cj) / 2.0
303303
if m["dim"] == 3:
304-
raise Exception("3D not implemented")
304+
raise NotImplementedError("3D not implemented")
305305
else:
306306
e_x, e_z, h = beam_2d_member_geometry(i, j)
307307
xs = zeros(2)

pystran/truss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def truss_member_geometry(i, j):
1919
e_x = geometry.delt(i["coordinates"], j["coordinates"])
2020
h = geometry.len(i["coordinates"], j["coordinates"])
2121
if h <= 0.0:
22-
raise Exception("Length of element must be positive")
22+
raise ZeroDivisionError("Length of element must be positive")
2323
e_x /= h
2424
return e_x, h
2525

0 commit comments

Comments
 (0)