提交 721ecc48 编写于 作者: H HuXiaowei 提交者: Jiangtao Hu

Tools/calibration: Optimized the memory usage in loops.

Dict.items() generate intermediate result lists several times, fixed for loops
to use dict automatic iteration instead.
And use dict in place update instead of build new intermediate dict if possible.
上级 126dda37
......@@ -42,21 +42,25 @@ def load_calibration_raw_data(fn):
cmd_table = {}
cmd_table[cmd] = [acc]
speed_table[speed] = cmd_table
for speed, cmd_table in speed_table.items():
new_cmd_table = {}
for cmd, acc_list in cmd_table.items():
new_cmd_table[cmd] = round(np.mean(acc_list), 2)
speed_table[speed] = new_cmd_table
for speed in speed_table:
cmd_table = speed_table[speed]
for cmd in cmd_table:
cmd_table[cmd] = round(np.mean(cmd_table[cmd]), 2)
#After this the acc_list converted to an average float number.
speed_table2 = {}
for speed, cmd_table in speed_table.items():
for speed in speed_table:
cmd_table = speed_table[speed]
acc_table = {}
for cmd, acc in cmd_table.items():
for cmd in cmd_table:
acc = cmd_table[cmd]
if acc in acc_table:
acc_table[acc].append(cmd)
else:
acc_table[acc] = [cmd]
speed_table2[speed] = acc_table
return speed_table2
def load_calibration_raw_data_old(fn):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册