From 1c671d511c6f8db9d807c787e8f127295896cc7d Mon Sep 17 00:00:00 2001 From: Guilhem Saurel <guilhem.saurel@laas.fr> Date: Sat, 13 May 2023 17:43:18 +0200 Subject: [PATCH] tooling: add isort & toml-sort --- .pre-commit-config.yaml | 8 ++++++++ demo/demo_quadruped.py | 18 ++++++++++-------- exercizes/ex_0_ur5_joint_space_control.py | 19 ++++++++++--------- exercizes/ex_1.py | 9 +++++---- exercizes/ex_1_ur5.py | 11 ++++++----- exercizes/ex_2.py | 11 ++++++----- exercizes/ex_3_biped_balance_with_gui.py | 1 - exercizes/ex_4_LIPM_to_TSID.py | 6 +++--- exercizes/ex_4_conf.py | 3 ++- exercizes/ex_4_long_conf.py | 3 ++- exercizes/ex_4_plan_LIPM_romeo.py | 8 ++++---- exercizes/ex_4_talos_conf.py | 3 ++- exercizes/ex_4_walking.py | 11 +++++------ exercizes/romeo_conf.py | 3 ++- exercizes/talos_conf.py | 3 ++- exercizes/test_cop_task.py | 9 +++++---- exercizes/tsid_biped.py | 1 + exercizes/tsid_manipulator.py | 14 ++++++++------ exercizes/ur5_conf.py | 6 ++++-- exercizes/ur5_reaching_conf.py | 6 ++++-- pyproject.toml | 5 +++++ tests/python/generator.py | 5 +++-- tests/python/test_Contact.py | 6 ++++-- tests/python/test_ContactPoint.py | 1 - tests/python/test_Deprecations.py | 2 +- tests/python/test_Formulation.py | 3 ++- tests/python/test_RobotWrapper.py | 1 + tests/python/test_Solvers.py | 1 + tests/python/test_Tasks.py | 3 ++- tests/python/test_Trajectories.py | 1 + 30 files changed, 109 insertions(+), 72 deletions(-) create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 310a13f..a873326 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,10 @@ repos: rev: 23.3.0 hooks: - id: black +- repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort - repo: https://github.com/cheshirekow/cmake-format-precommit rev: v0.6.13 hooks: @@ -21,3 +25,7 @@ repos: hooks: - id: clang-format args: ['--style={BasedOnStyle: Google,SortIncludes: false}'] +- repo: https://github.com/pappasam/toml-sort + rev: v0.23.1 + hooks: + - id: toml-sort-fix diff --git a/demo/demo_quadruped.py b/demo/demo_quadruped.py index c31f50e..411eb0a 100644 --- a/demo/demo_quadruped.py +++ b/demo/demo_quadruped.py @@ -1,17 +1,19 @@ -import pinocchio as pin -import tsid -import numpy as np -from numpy import nan -from numpy.linalg import norm as norm import os -import gepetto.corbaserver -import time import subprocess import sys +import time + +import gepetto.corbaserver +import numpy as np +import pinocchio as pin +from numpy import nan +from numpy.linalg import norm as norm + +import tsid sys.path += [os.getcwd() + "/../exercizes"] -import plot_utils as plut import matplotlib.pyplot as plt +import plot_utils as plut np.set_printoptions(precision=3, linewidth=200, suppress=True) diff --git a/exercizes/ex_0_ur5_joint_space_control.py b/exercizes/ex_0_ur5_joint_space_control.py index f453f1d..290e60f 100644 --- a/exercizes/ex_0_ur5_joint_space_control.py +++ b/exercizes/ex_0_ur5_joint_space_control.py @@ -1,16 +1,17 @@ +import os +import subprocess +import time + +import gepetto.corbaserver +import matplotlib.pyplot as plt import numpy as np +import pinocchio as pin +import plot_utils as plut +import ur5_conf as conf from numpy import nan from numpy.linalg import norm as norm -import matplotlib.pyplot as plt -import plot_utils as plut -import time -import pinocchio as pin -import tsid -import gepetto.corbaserver -import subprocess -import os -import ur5_conf as conf +import tsid print("".center(conf.LINE_WIDTH, "#")) print(" Joint Space Inverse Dynamics - Manipulator ".center(conf.LINE_WIDTH, "#")) diff --git a/exercizes/ex_1.py b/exercizes/ex_1.py index 94ffffa..ee779c3 100644 --- a/exercizes/ex_1.py +++ b/exercizes/ex_1.py @@ -1,10 +1,11 @@ -import numpy as np -from numpy import nan -from numpy.linalg import norm as norm +import time + import matplotlib.pyplot as plt +import numpy as np import plot_utils as plut -import time import romeo_conf as conf +from numpy import nan +from numpy.linalg import norm as norm from tsid_biped import TsidBiped print("".center(conf.LINE_WIDTH, "#")) diff --git a/exercizes/ex_1_ur5.py b/exercizes/ex_1_ur5.py index 583eda9..ea6a549 100644 --- a/exercizes/ex_1_ur5.py +++ b/exercizes/ex_1_ur5.py @@ -1,13 +1,14 @@ -import numpy as np -from numpy import nan -from numpy.linalg import norm as norm +import time + import matplotlib.pyplot as plt +import numpy as np import plot_utils as plut -import time -from tsid_manipulator import TsidManipulator # import ur5_conf as conf import ur5_reaching_conf as conf +from numpy import nan +from numpy.linalg import norm as norm +from tsid_manipulator import TsidManipulator print(("".center(conf.LINE_WIDTH, "#"))) print((" TSID - Manipulator End-Effector Sin Tracking ".center(conf.LINE_WIDTH, "#"))) diff --git a/exercizes/ex_2.py b/exercizes/ex_2.py index 6a7ff6b..4d6e184 100644 --- a/exercizes/ex_2.py +++ b/exercizes/ex_2.py @@ -1,11 +1,12 @@ -import numpy as np -from numpy import nan -from numpy.linalg import norm as norm +import time + import matplotlib.pyplot as plt +import numpy as np +import pinocchio as pin import plot_utils as plut -import time import romeo_conf as conf -import pinocchio as pin +from numpy import nan +from numpy.linalg import norm as norm from tsid_biped import TsidBiped print("".center(conf.LINE_WIDTH, "#")) diff --git a/exercizes/ex_3_biped_balance_with_gui.py b/exercizes/ex_3_biped_balance_with_gui.py index 1ebe903..ffd7ad8 100644 --- a/exercizes/ex_3_biped_balance_with_gui.py +++ b/exercizes/ex_3_biped_balance_with_gui.py @@ -12,7 +12,6 @@ from tkinter import HORIZONTAL, Button, Entry, Frame, Label, Scale, Tk, mainloop import numpy as np import pinocchio as pin - import talos_conf as conf # import romeo_conf as conf diff --git a/exercizes/ex_4_LIPM_to_TSID.py b/exercizes/ex_4_LIPM_to_TSID.py index 40561b7..a36268c 100644 --- a/exercizes/ex_4_LIPM_to_TSID.py +++ b/exercizes/ex_4_LIPM_to_TSID.py @@ -1,11 +1,11 @@ -import numpy as np +import ex_4_conf as conf import LMPC_walking.second_order.plot_utils as plot_utils +import matplotlib.pyplot as plt +import numpy as np from LMPC_walking.second_order.LIPM_to_whole_body import ( compute_foot_traj, interpolate_lipm_traj, ) -import matplotlib.pyplot as plt -import ex_4_conf as conf # import ex_4_long_conf as conf diff --git a/exercizes/ex_4_conf.py b/exercizes/ex_4_conf.py index 92754a8..74f7a86 100644 --- a/exercizes/ex_4_conf.py +++ b/exercizes/ex_4_conf.py @@ -5,8 +5,9 @@ Created on Thu Apr 18 09:47:07 2019 @author: student """ -import numpy as np import os + +import numpy as np import pinocchio as pin np.set_printoptions(precision=3, linewidth=200, suppress=True) diff --git a/exercizes/ex_4_long_conf.py b/exercizes/ex_4_long_conf.py index 06e158c..c6cacd4 100644 --- a/exercizes/ex_4_long_conf.py +++ b/exercizes/ex_4_long_conf.py @@ -5,9 +5,10 @@ Created on Thu Apr 18 09:47:07 2019 @author: student """ -import numpy as np import os +import numpy as np + np.set_printoptions(precision=3, linewidth=200, suppress=True) LINE_WIDTH = 60 diff --git a/exercizes/ex_4_plan_LIPM_romeo.py b/exercizes/ex_4_plan_LIPM_romeo.py index 703152c..4823256 100644 --- a/exercizes/ex_4_plan_LIPM_romeo.py +++ b/exercizes/ex_4_plan_LIPM_romeo.py @@ -22,20 +22,20 @@ import numpy as np from quadprog import solve_qp try: - import LMPC_walking.second_order.reference_trajectories as reference_trajectories - import LMPC_walking.second_order.motion_model as motion_model - import LMPC_walking.second_order.cost_function as cost_function import LMPC_walking.second_order.constraints as constraints + import LMPC_walking.second_order.cost_function as cost_function + import LMPC_walking.second_order.motion_model as motion_model import LMPC_walking.second_order.plot_utils as plot_utils + import LMPC_walking.second_order.reference_trajectories as reference_trajectories except ModuleNotFoundError as e: print( "Please download LMPC_walking from https://github.com/machines-in-motion/lmpc_walking." ) raise e +import ex_4_conf as conf import matplotlib.pyplot as plt from plot_utils import * -import ex_4_conf as conf # import ex_4_long_conf as conf diff --git a/exercizes/ex_4_talos_conf.py b/exercizes/ex_4_talos_conf.py index ff22f6a..0f76b11 100644 --- a/exercizes/ex_4_talos_conf.py +++ b/exercizes/ex_4_talos_conf.py @@ -5,8 +5,9 @@ Created on Thu Apr 18 09:47:07 2019 @author: student """ -import numpy as np import os + +import numpy as np import pinocchio as pin from example_robot_data.robots_loader import getModelPath diff --git a/exercizes/ex_4_walking.py b/exercizes/ex_4_walking.py index a3ba4b5..986751e 100644 --- a/exercizes/ex_4_walking.py +++ b/exercizes/ex_4_walking.py @@ -1,16 +1,15 @@ import time -import numpy as np -import scipy.sparse as spa -import matplotlib.pyplot as plt -import tsid -import plot_utils as plut import ex_4_conf as conf - +import matplotlib.pyplot as plt +import numpy as np +import plot_utils as plut +import scipy.sparse as spa from numpy import nan from numpy.linalg import norm as norm from tsid_biped import TsidBiped +import tsid print("".center(conf.LINE_WIDTH, "#")) print(" Test Walking ".center(conf.LINE_WIDTH, "#")) diff --git a/exercizes/romeo_conf.py b/exercizes/romeo_conf.py index 3b7003b..a204015 100644 --- a/exercizes/romeo_conf.py +++ b/exercizes/romeo_conf.py @@ -5,8 +5,9 @@ Created on Thu Apr 18 09:47:07 2019 @author: student """ -import numpy as np import os + +import numpy as np import pinocchio as pin np.set_printoptions(precision=3, linewidth=200, suppress=True) diff --git a/exercizes/talos_conf.py b/exercizes/talos_conf.py index 9e3e075..4e8d933 100644 --- a/exercizes/talos_conf.py +++ b/exercizes/talos_conf.py @@ -1,6 +1,7 @@ import os -import pinocchio as pin + import numpy as np +import pinocchio as pin from example_robot_data.robots_loader import getModelPath np.set_printoptions(precision=3, linewidth=200, suppress=True) diff --git a/exercizes/test_cop_task.py b/exercizes/test_cop_task.py index 1561fe4..1894c06 100644 --- a/exercizes/test_cop_task.py +++ b/exercizes/test_cop_task.py @@ -7,13 +7,14 @@ which was the goal of the test, validating the CoP task. """ +import time + +import ex_4_conf as conf +import matplotlib.pyplot as plt import numpy as np +import plot_utils as plut from numpy import nan from numpy.linalg import norm as norm -import matplotlib.pyplot as plt -import plot_utils as plut -import time -import ex_4_conf as conf # import ex_4_long_conf as conf from tsid_biped import TsidBiped diff --git a/exercizes/tsid_biped.py b/exercizes/tsid_biped.py index 58a229c..d63d25a 100644 --- a/exercizes/tsid_biped.py +++ b/exercizes/tsid_biped.py @@ -4,6 +4,7 @@ import time import numpy as np import pinocchio as pin + import tsid diff --git a/exercizes/tsid_manipulator.py b/exercizes/tsid_manipulator.py index c2c1b08..93a7bc8 100644 --- a/exercizes/tsid_manipulator.py +++ b/exercizes/tsid_manipulator.py @@ -1,11 +1,13 @@ -import pinocchio as se3 -import tsid -import numpy as np -import numpy.matlib as matlib import os -import gepetto.corbaserver -import time import subprocess +import time + +import gepetto.corbaserver +import numpy as np +import numpy.matlib as matlib +import pinocchio as se3 + +import tsid class TsidManipulator: diff --git a/exercizes/ur5_conf.py b/exercizes/ur5_conf.py index a42b51e..97f4f81 100644 --- a/exercizes/ur5_conf.py +++ b/exercizes/ur5_conf.py @@ -5,9 +5,10 @@ Created on Thu Apr 18 09:47:07 2019 @author: student """ -import numpy as np import os +import numpy as np + np.set_printoptions(precision=3, linewidth=200, suppress=True) LINE_WIDTH = 60 @@ -52,9 +53,10 @@ REF_SPHERE_RADIUS = 0.03 EE_SPHERE_COLOR = (1, 0.5, 0, 0.5) EE_REF_SPHERE_COLOR = (1, 0, 0, 0.5) -from example_robot_data.robots_loader import getModelPath from os.path import join +from example_robot_data.robots_loader import getModelPath + urdf = "ur_description/urdf/ur5_robot.urdf" path = getModelPath(urdf) urdf = join(path, urdf) diff --git a/exercizes/ur5_reaching_conf.py b/exercizes/ur5_reaching_conf.py index d46a370..cfa9f62 100644 --- a/exercizes/ur5_reaching_conf.py +++ b/exercizes/ur5_reaching_conf.py @@ -5,9 +5,10 @@ Created on Thu Apr 18 09:47:07 2019 @author: student """ -import numpy as np import os +import numpy as np + np.set_printoptions(precision=3, linewidth=200, suppress=True) LINE_WIDTH = 60 @@ -52,9 +53,10 @@ REF_SPHERE_RADIUS = 0.03 EE_SPHERE_COLOR = (1, 0.5, 0, 0.5) EE_REF_SPHERE_COLOR = (1, 0, 0, 0.5) -from example_robot_data.robots_loader import getModelPath from os.path import join +from example_robot_data.robots_loader import getModelPath + urdf = "ur_description/urdf/ur5_robot.urdf" path = getModelPath(urdf) urdf = join(path, urdf) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4441909 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[tool.isort] +profile = "black" + +[tool.tomlsort] +all = true diff --git a/tests/python/generator.py b/tests/python/generator.py index 2f303c9..78b1933 100644 --- a/tests/python/generator.py +++ b/tests/python/generator.py @@ -1,7 +1,8 @@ -import pinocchio as pin +from math import pi + import hppfcl as fcl import numpy as np -from math import pi +import pinocchio as pin def create_7dof_arm(revoluteOnly=False): diff --git a/tests/python/test_Contact.py b/tests/python/test_Contact.py index a7417c1..3338191 100644 --- a/tests/python/test_Contact.py +++ b/tests/python/test_Contact.py @@ -1,7 +1,9 @@ +import copy + +import numpy as np import pinocchio as se3 + import tsid -import numpy as np -import copy print("") print("Test Contact") diff --git a/tests/python/test_ContactPoint.py b/tests/python/test_ContactPoint.py index 56ae365..cdf9e50 100644 --- a/tests/python/test_ContactPoint.py +++ b/tests/python/test_ContactPoint.py @@ -6,7 +6,6 @@ import pinocchio as se3 import tsid - print("") print("Test Contact") print("") diff --git a/tests/python/test_Deprecations.py b/tests/python/test_Deprecations.py index 7cdd353..8e0bf82 100644 --- a/tests/python/test_Deprecations.py +++ b/tests/python/test_Deprecations.py @@ -1,5 +1,5 @@ -import unittest import sys +import unittest import warnings import numpy as np diff --git a/tests/python/test_Formulation.py b/tests/python/test_Formulation.py index 07d3af0..6d99330 100644 --- a/tests/python/test_Formulation.py +++ b/tests/python/test_Formulation.py @@ -2,9 +2,10 @@ import os import numpy as np import pinocchio as se3 -import tsid from numpy.linalg import norm +import tsid + print("") print("Test InvDyn") print("") diff --git a/tests/python/test_RobotWrapper.py b/tests/python/test_RobotWrapper.py index 6e7bb07..7fa1df8 100644 --- a/tests/python/test_RobotWrapper.py +++ b/tests/python/test_RobotWrapper.py @@ -2,6 +2,7 @@ import os import numpy as np import pinocchio as se3 + import tsid print("") diff --git a/tests/python/test_Solvers.py b/tests/python/test_Solvers.py index d5c8f3a..b0d8bb4 100644 --- a/tests/python/test_Solvers.py +++ b/tests/python/test_Solvers.py @@ -1,4 +1,5 @@ import numpy as np + import tsid print("") diff --git a/tests/python/test_Tasks.py b/tests/python/test_Tasks.py index 59711dc..cb98d57 100644 --- a/tests/python/test_Tasks.py +++ b/tests/python/test_Tasks.py @@ -2,9 +2,10 @@ import os import numpy as np import pinocchio as pin -import tsid from numpy.linalg import norm +import tsid + print("") print("Test Task COM") print("") diff --git a/tests/python/test_Trajectories.py b/tests/python/test_Trajectories.py index 8c0acdd..0674e98 100644 --- a/tests/python/test_Trajectories.py +++ b/tests/python/test_Trajectories.py @@ -1,5 +1,6 @@ import numpy as np import pinocchio as se3 + import tsid print("") -- GitLab