mirror of
https://github.com/AtsushiSakai/PythonRobotics.git
synced 2026-01-10 20:28:12 -05:00
Fix lint error (#1124)
This commit is contained in:
@@ -158,7 +158,7 @@ def astar_torus(grid, start_node, goal_node):
|
||||
while parent_map[route[0][0]][route[0][1]] != ():
|
||||
route.insert(0, parent_map[route[0][0]][route[0][1]])
|
||||
|
||||
print("The route found covers %d grid cells." % len(route))
|
||||
print(f"The route found covers {len(route)} grid cells.")
|
||||
for i in range(1, len(route)):
|
||||
grid[route[i]] = 6
|
||||
plt.cla()
|
||||
@@ -212,7 +212,7 @@ def calc_heuristic_map(M, goal_node):
|
||||
return heuristic_map
|
||||
|
||||
|
||||
class NLinkArm(object):
|
||||
class NLinkArm:
|
||||
"""
|
||||
Class for controlling and plotting a planar arm with an arbitrary number of links.
|
||||
"""
|
||||
|
||||
@@ -189,7 +189,7 @@ def astar_torus(grid, start_node, goal_node):
|
||||
while parent_map[route[0][0]][route[0][1]] != ():
|
||||
route.insert(0, parent_map[route[0][0]][route[0][1]])
|
||||
|
||||
print("The route found covers %d grid cells." % len(route))
|
||||
print(f"The route found covers {len(route)} grid cells.")
|
||||
for i in range(1, len(route)):
|
||||
grid[route[i]] = 6
|
||||
plt.cla()
|
||||
@@ -243,7 +243,7 @@ def calc_heuristic_map(M, goal_node):
|
||||
return heuristic_map
|
||||
|
||||
|
||||
class NLinkArm(object):
|
||||
class NLinkArm:
|
||||
"""
|
||||
Class for controlling and plotting a planar arm with an arbitrary number of links.
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ from matplotlib import pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
|
||||
class DMP(object):
|
||||
class DMP:
|
||||
|
||||
def __init__(self, training_data, data_period, K=156.25, B=25):
|
||||
"""
|
||||
@@ -215,21 +215,21 @@ class DMP(object):
|
||||
T_vals = np.linspace(T_orig, 2*T_orig, 20)
|
||||
|
||||
for new_q0_value in q0_vals:
|
||||
plot_title = "Initial Position = [%s, %s]" % \
|
||||
(round(new_q0_value[0], 2), round(new_q0_value[1], 2))
|
||||
plot_title = (f"Initial Position = [{round(new_q0_value[0], 2)},"
|
||||
f" {round(new_q0_value[1], 2)}]")
|
||||
|
||||
_, path = self.recreate_trajectory(new_q0_value, g_orig, T_orig)
|
||||
self.view_trajectory(path, title=plot_title, demo=True)
|
||||
|
||||
for new_g_value in g_vals:
|
||||
plot_title = "Goal Position = [%s, %s]" % \
|
||||
(round(new_g_value[0], 2), round(new_g_value[1], 2))
|
||||
plot_title = (f"Goal Position = [{round(new_g_value[0], 2)},"
|
||||
f" {round(new_g_value[1], 2)}]")
|
||||
|
||||
_, path = self.recreate_trajectory(q0_orig, new_g_value, T_orig)
|
||||
self.view_trajectory(path, title=plot_title, demo=True)
|
||||
|
||||
for new_T_value in T_vals:
|
||||
plot_title = "Period = %s [sec]" % round(new_T_value, 2)
|
||||
plot_title = f"Period = {round(new_T_value, 2)} [sec]"
|
||||
|
||||
_, path = self.recreate_trajectory(q0_orig, g_orig, new_T_value)
|
||||
self.view_trajectory(path, title=plot_title, demo=True)
|
||||
@@ -257,5 +257,4 @@ def example_DMP():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
example_DMP()
|
||||
|
||||
@@ -26,8 +26,7 @@ show_animation = True
|
||||
|
||||
class MaxVelocityNotReached(Exception):
|
||||
def __init__(self, actual_vel, max_vel):
|
||||
self.message = 'Actual velocity {} does not equal desired max velocity {}!'.format(
|
||||
actual_vel, max_vel)
|
||||
self.message = f'Actual velocity {actual_vel} does not equal desired max velocity {max_vel}!'
|
||||
|
||||
|
||||
class eta3_trajectory(Eta3Path):
|
||||
@@ -42,7 +41,7 @@ class eta3_trajectory(Eta3Path):
|
||||
# ensure that all inputs obey the assumptions of the model
|
||||
assert max_vel > 0 and v0 >= 0 and a0 >= 0 and max_accel > 0 and max_jerk > 0 \
|
||||
and a0 <= max_accel and v0 <= max_vel
|
||||
super(eta3_trajectory, self).__init__(segments=segments)
|
||||
super(__class__, self).__init__(segments=segments)
|
||||
self.total_length = sum([s.segment_length for s in self.segments])
|
||||
self.max_vel = float(max_vel)
|
||||
self.v0 = float(v0)
|
||||
@@ -166,7 +165,7 @@ class eta3_trajectory(Eta3Path):
|
||||
try:
|
||||
assert np.isclose(self.vels[index], 0)
|
||||
except AssertionError as e:
|
||||
print('The final velocity {} is not zero'.format(self.vels[index]))
|
||||
print(f'The final velocity {self.vels[index]} is not zero')
|
||||
raise e
|
||||
|
||||
self.seg_lengths[index] = s_sf
|
||||
|
||||
@@ -370,8 +370,8 @@ def i4_sobol(dim_num, seed):
|
||||
if (dim_num < 1 or dim_max < dim_num):
|
||||
print('I4_SOBOL - Fatal error!')
|
||||
print(' The spatial dimension DIM_NUM should satisfy:')
|
||||
print(' 1 <= DIM_NUM <= %d' % dim_max)
|
||||
print(' But this input value is DIM_NUM = %d' % dim_num)
|
||||
print(f' 1 <= DIM_NUM <= {dim_max:d}')
|
||||
print(f' But this input value is DIM_NUM = {dim_num:d}')
|
||||
return None
|
||||
|
||||
dim_num_save = dim_num
|
||||
@@ -443,7 +443,7 @@ def i4_sobol(dim_num, seed):
|
||||
#
|
||||
l_var = i4_bit_lo0(seed)
|
||||
|
||||
elif (seed <= seed_save):
|
||||
elif seed <= seed_save:
|
||||
|
||||
seed_save = 0
|
||||
lastq = np.zeros(dim_num)
|
||||
@@ -471,8 +471,8 @@ def i4_sobol(dim_num, seed):
|
||||
if maxcol < l_var:
|
||||
print('I4_SOBOL - Fatal error!')
|
||||
print(' Too many calls!')
|
||||
print(' MAXCOL = %d\n' % maxcol)
|
||||
print(' L = %d\n' % l_var)
|
||||
print(f' MAXCOL = {maxcol:d}\n')
|
||||
print(f' L = {l_var:d}\n')
|
||||
return None
|
||||
|
||||
|
||||
@@ -819,7 +819,7 @@ def r8mat_write(filename, m, n, a):
|
||||
with open(filename, 'w') as output:
|
||||
for i in range(0, m):
|
||||
for j in range(0, n):
|
||||
s = ' %g' % (a[i, j])
|
||||
s = f' {a[i, j]:g}'
|
||||
output.write(s)
|
||||
output.write('\n')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user