Skip to content

Commit 95eedba

Browse files
authored
Fix lint error (#1124)
1 parent 5a66105 commit 95eedba

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def astar_torus(grid, start_node, goal_node):
158158
while parent_map[route[0][0]][route[0][1]] != ():
159159
route.insert(0, parent_map[route[0][0]][route[0][1]])
160160

161-
print("The route found covers %d grid cells." % len(route))
161+
print(f"The route found covers {len(route)} grid cells.")
162162
for i in range(1, len(route)):
163163
grid[route[i]] = 6
164164
plt.cla()
@@ -212,7 +212,7 @@ def calc_heuristic_map(M, goal_node):
212212
return heuristic_map
213213

214214

215-
class NLinkArm(object):
215+
class NLinkArm:
216216
"""
217217
Class for controlling and plotting a planar arm with an arbitrary number of links.
218218
"""

ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation_2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def astar_torus(grid, start_node, goal_node):
189189
while parent_map[route[0][0]][route[0][1]] != ():
190190
route.insert(0, parent_map[route[0][0]][route[0][1]])
191191

192-
print("The route found covers %d grid cells." % len(route))
192+
print(f"The route found covers {len(route)} grid cells.")
193193
for i in range(1, len(route)):
194194
grid[route[i]] = 6
195195
plt.cla()
@@ -243,7 +243,7 @@ def calc_heuristic_map(M, goal_node):
243243
return heuristic_map
244244

245245

246-
class NLinkArm(object):
246+
class NLinkArm:
247247
"""
248248
Class for controlling and plotting a planar arm with an arbitrary number of links.
249249
"""

PathPlanning/DynamicMovementPrimitives/dynamic_movement_primitives.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import numpy as np
1919

2020

21-
class DMP(object):
21+
class DMP:
2222

2323
def __init__(self, training_data, data_period, K=156.25, B=25):
2424
"""
@@ -215,21 +215,21 @@ def show_DMP_purpose(self):
215215
T_vals = np.linspace(T_orig, 2*T_orig, 20)
216216

217217
for new_q0_value in q0_vals:
218-
plot_title = "Initial Position = [%s, %s]" % \
219-
(round(new_q0_value[0], 2), round(new_q0_value[1], 2))
218+
plot_title = (f"Initial Position = [{round(new_q0_value[0], 2)},"
219+
f" {round(new_q0_value[1], 2)}]")
220220

221221
_, path = self.recreate_trajectory(new_q0_value, g_orig, T_orig)
222222
self.view_trajectory(path, title=plot_title, demo=True)
223223

224224
for new_g_value in g_vals:
225-
plot_title = "Goal Position = [%s, %s]" % \
226-
(round(new_g_value[0], 2), round(new_g_value[1], 2))
225+
plot_title = (f"Goal Position = [{round(new_g_value[0], 2)},"
226+
f" {round(new_g_value[1], 2)}]")
227227

228228
_, path = self.recreate_trajectory(q0_orig, new_g_value, T_orig)
229229
self.view_trajectory(path, title=plot_title, demo=True)
230230

231231
for new_T_value in T_vals:
232-
plot_title = "Period = %s [sec]" % round(new_T_value, 2)
232+
plot_title = f"Period = {round(new_T_value, 2)} [sec]"
233233

234234
_, path = self.recreate_trajectory(q0_orig, g_orig, new_T_value)
235235
self.view_trajectory(path, title=plot_title, demo=True)
@@ -257,5 +257,4 @@ def example_DMP():
257257

258258

259259
if __name__ == '__main__':
260-
261260
example_DMP()

PathPlanning/Eta3SplineTrajectory/eta3_spline_trajectory.py

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

2727
class MaxVelocityNotReached(Exception):
2828
def __init__(self, actual_vel, max_vel):
29-
self.message = 'Actual velocity {} does not equal desired max velocity {}!'.format(
30-
actual_vel, max_vel)
29+
self.message = f'Actual velocity {actual_vel} does not equal desired max velocity {max_vel}!'
3130

3231

3332
class eta3_trajectory(Eta3Path):
@@ -42,7 +41,7 @@ def __init__(self, segments, max_vel, v0=0.0, a0=0.0, max_accel=2.0, max_jerk=5.
4241
# ensure that all inputs obey the assumptions of the model
4342
assert max_vel > 0 and v0 >= 0 and a0 >= 0 and max_accel > 0 and max_jerk > 0 \
4443
and a0 <= max_accel and v0 <= max_vel
45-
super(eta3_trajectory, self).__init__(segments=segments)
44+
super(__class__, self).__init__(segments=segments)
4645
self.total_length = sum([s.segment_length for s in self.segments])
4746
self.max_vel = float(max_vel)
4847
self.v0 = float(v0)
@@ -166,7 +165,7 @@ def velocity_profile(self):
166165
try:
167166
assert np.isclose(self.vels[index], 0)
168167
except AssertionError as e:
169-
print('The final velocity {} is not zero'.format(self.vels[index]))
168+
print(f'The final velocity {self.vels[index]} is not zero')
170169
raise e
171170

172171
self.seg_lengths[index] = s_sf

PathPlanning/RRT/sobol/sobol.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ def i4_sobol(dim_num, seed):
370370
if (dim_num < 1 or dim_max < dim_num):
371371
print('I4_SOBOL - Fatal error!')
372372
print(' The spatial dimension DIM_NUM should satisfy:')
373-
print(' 1 <= DIM_NUM <= %d' % dim_max)
374-
print(' But this input value is DIM_NUM = %d' % dim_num)
373+
print(f' 1 <= DIM_NUM <= {dim_max:d}')
374+
print(f' But this input value is DIM_NUM = {dim_num:d}')
375375
return None
376376

377377
dim_num_save = dim_num
@@ -443,7 +443,7 @@ def i4_sobol(dim_num, seed):
443443
#
444444
l_var = i4_bit_lo0(seed)
445445

446-
elif (seed <= seed_save):
446+
elif seed <= seed_save:
447447

448448
seed_save = 0
449449
lastq = np.zeros(dim_num)
@@ -471,8 +471,8 @@ def i4_sobol(dim_num, seed):
471471
if maxcol < l_var:
472472
print('I4_SOBOL - Fatal error!')
473473
print(' Too many calls!')
474-
print(' MAXCOL = %d\n' % maxcol)
475-
print(' L = %d\n' % l_var)
474+
print(f' MAXCOL = {maxcol:d}\n')
475+
print(f' L = {l_var:d}\n')
476476
return None
477477

478478

@@ -819,7 +819,7 @@ def r8mat_write(filename, m, n, a):
819819
with open(filename, 'w') as output:
820820
for i in range(0, m):
821821
for j in range(0, n):
822-
s = ' %g' % (a[i, j])
822+
s = f' {a[i, j]:g}'
823823
output.write(s)
824824
output.write('\n')
825825

0 commit comments

Comments
 (0)