Skip to content

Commit 7576a42

Browse files
author
Sourcery AI
committed
'Refactored by Sourcery'
1 parent 1480b14 commit 7576a42

37 files changed

+119
-196
lines changed

examples/core_animation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232

3333
def build_shape():
3434
boxshp = BRepPrimAPI_MakeBox(50.0, 50.0, 50.0).Shape()
35-
ais_boxshp = display.DisplayShape(boxshp, update=True)[0]
36-
return ais_boxshp
35+
return display.DisplayShape(boxshp, update=True)[0]
3736

3837

3938
def rotating_cube_1_axis(event=None):
@@ -44,7 +43,7 @@ def rotating_cube_1_axis(event=None):
4443
angle = 0.0
4544
tA = time.time()
4645
n_rotations = 200
47-
for i in range(n_rotations):
46+
for _ in range(n_rotations):
4847
aCubeTrsf.SetRotation(ax1, angle)
4948
aCubeToploc = TopLoc_Location(aCubeTrsf)
5049
display.Context.SetLocation(ais_boxshp, aCubeToploc)
@@ -63,7 +62,7 @@ def rotating_cube_2_axis(event=None):
6362
angle = 0.0
6463
tA = time.time()
6564
n_rotations = 200
66-
for i in range(n_rotations):
65+
for _ in range(n_rotations):
6766
a_cube_trsf.SetRotation(ax1, angle)
6867
a_cube_trsf2.SetRotation(ax2, angle)
6968
aCubeToploc = TopLoc_Location(a_cube_trsf * a_cube_trsf2)

examples/core_boolean_fuzzy_cut_emmenthaler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232

3333

3434
def random_pnt():
35-
x, y, z = [random.uniform(0, 1) for i in range(3)]
35+
x, y, z = [random.uniform(0, 1) for _ in range(3)]
3636
return gp_Pnt(x, y, z)
3737

3838

3939
def random_vec():
40-
x, y, z = [random.uniform(-1, 1) for i in range(3)]
40+
x, y, z = [random.uniform(-1, 1) for _ in range(3)]
4141
return gp_Vec(x, y, z)
4242

4343

examples/core_boolean_sewed_shapes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
def MakeSolidFromShell(shell):
3232
ms = BRepBuilderAPI_MakeSolid()
3333
ms.Add(topods.Shell(shell))
34-
solid = ms.Solid()
35-
return solid
34+
return ms.Solid()
3635

3736

3837
def make_face_from_4_points(pnt1, pnt2, pnt3, pnt4):

examples/core_display_activate_manipulator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ def createLayout(self):
7676
def show_layer(self):
7777
if self.show_layer_button.isChecked():
7878
self.layer.show()
79-
self.display.FitAll()
8079
else:
8180
self.layer.hide()
82-
self.display.FitAll()
81+
82+
self.display.FitAll()
8383

8484
def activate_manipulator(self):
8585
if self.activate_manip_button.isChecked():

examples/core_display_callbacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def print_xy_click(shp, *kwargs):
2828

2929

3030
def compute_bbox(shp, *kwargs):
31-
print("Compute bbox for %s " % shp)
31+
print(f"Compute bbox for {shp} ")
3232
for shape in shp:
3333
bbox = Bnd_Box()
3434
brepbndlib_Add(shape, bbox)

examples/core_display_clip_planes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def disable_clip_plane(event=None):
6969
def animate_translate_clip_plane(event=None):
7070
plane_definition = clip_plane_1.ToPlane() # it's a gp_Pln
7171
h = 0.2
72-
for i in range(100):
72+
for _ in range(100):
7373
plane_definition.Translate(gp_Vec(0.0, 0.0, h))
7474
clip_plane_1.SetEquation(plane_definition)
7575
display.Context.UpdateCurrentViewer()

examples/core_display_material_compound_subshape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
s = BRepPrimAPI_MakeCylinder(radius, 200).Shape()
3434
delta_x = 0.0
3535
solids = []
36-
for mat in available_materials:
36+
for _ in available_materials:
3737
s2 = translate_shp(s, gp_Vec(delta_x, 0.0, 0.0))
3838
delta_x += 2 * radius + 1.0
3939
solids.append(s2)

examples/core_display_point_cloud.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,20 @@ def pcd_get_number_of_vertices(pcd_filename):
4545
POINTS 397
4646
DATA ascii
4747
"""
48-
f = open(pcd_filename, "r")
49-
# read 8 lines
50-
for i in range(8):
51-
f.readline()
52-
# the 9th line holds the number of points
53-
number_of_points = int(f.readline().split()[1])
54-
f.close()
48+
with open(pcd_filename, "r") as f:
49+
# read 8 lines
50+
for _ in range(8):
51+
f.readline()
52+
# the 9th line holds the number of points
53+
number_of_points = int(f.readline().split()[1])
5554
return number_of_points
5655

5756

5857
def random_points(event=None):
5958
n_points = 500000
6059
# first, create a set of 1000 points
6160
points_3d = Graphic3d_ArrayOfPoints(n_points)
62-
for idx in range(n_points):
61+
for _ in range(n_points):
6362
x = random.uniform(-50, 50)
6463
y = random.uniform(-50, 50)
6564
z = random.uniform(-50, 50)
@@ -86,9 +85,9 @@ def bunny(event=None):
8685
# fedd it with vertices
8786
fp = open(pcd_file_name, "r")
8887
# read 11 lines to skip header
89-
for i in range(10):
88+
for _ in range(10):
9089
fp.readline()
91-
for i in range(nbr_of_vertices):
90+
for _ in range(nbr_of_vertices):
9291
line = fp.readline()
9392
x, y, z = map(float, line.split())
9493
pc.AddVertex(x, y, z)

examples/core_display_signal_slots.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def get_occ_viewer():
3333
widgets = app.topLevelWidgets()
3434
for wi in widgets:
3535
if hasattr(wi, "_menus"): # OCC.Display.SimpleGui.MainWindow
36-
viewer = wi.findChild(qtViewer3d, "qt_viewer_3d")
37-
return viewer
36+
return wi.findChild(qtViewer3d, "qt_viewer_3d")
3837

3938

4039
def on_select(shapes):
@@ -75,8 +74,7 @@ def also_on_select(shapes):
7574
def location_from_vector(x, y, z):
7675
trsf = gp_Trsf()
7776
trsf.SetTranslation(gp_Vec(x, y, z))
78-
loc = TopLoc_Location(trsf)
79-
return loc
77+
return TopLoc_Location(trsf)
8078

8179

8280
cube = BRepPrimAPI_MakeBox(100, 100, 100).Shape()

examples/core_geometry_airfoil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(self, chord, span, profile):
4949
def make_shape(self):
5050
# 1 - retrieve the data from the UIUC airfoil data page
5151
foil_dat_url = (
52-
"http://m-selig.ae.illinois.edu/ads/coord_seligFmt/%s.dat" % self.profile
52+
f"http://m-selig.ae.illinois.edu/ads/coord_seligFmt/{self.profile}.dat"
5353
)
5454
# explicitly tell to not use ssl verification
5555
ssl._create_default_https_context = ssl._create_unverified_context

0 commit comments

Comments
 (0)