diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4afce58d40..7ce709d682 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ ci: repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.14.10 + rev: v0.15.9 hooks: # Run the linter. - id: ruff @@ -26,12 +26,12 @@ repos: - id: ruff-format - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.9.21 + rev: 0.11.3 hooks: # Update the uv lockfile - id: uv-lock - repo: https://github.com/crate-ci/typos - rev: v1.42.0 + rev: v1 hooks: - id: typos args: [] diff --git a/docs/print_api.py b/docs/print_api.py index 73e39bb507..657815b46d 100644 --- a/docs/print_api.py +++ b/docs/print_api.py @@ -31,7 +31,7 @@ def get_symbols(mod_name: str): else: children.append(name) - return (mod_name.split(".")[-1], children) + return (mod_name.rsplit(".", maxsplit=1)[-1], children) def print_symbols(sym_dict, indent=0): diff --git a/newton/_src/solvers/kamino/examples/newton/example_anymal_d.py b/newton/_src/solvers/kamino/examples/newton/example_anymal_d.py index ddf69d09dc..40bf179810 100644 --- a/newton/_src/solvers/kamino/examples/newton/example_anymal_d.py +++ b/newton/_src/solvers/kamino/examples/newton/example_anymal_d.py @@ -128,8 +128,9 @@ def test_final(self): self.model, self.state_0, "body velocities are small", - lambda q, qd: max(abs(qd)) - < 0.25, # Relaxed from 0.1 - unified pipeline has residual velocities up to ~0.2 + lambda q, qd: ( + max(abs(qd)) < 0.25 + ), # Relaxed from 0.1 - unified pipeline has residual velocities up to ~0.2 ) diff --git a/newton/_src/solvers/kamino/examples/newton/example_dr_legs.py b/newton/_src/solvers/kamino/examples/newton/example_dr_legs.py index dd87f0aaed..04e90b6a2f 100644 --- a/newton/_src/solvers/kamino/examples/newton/example_dr_legs.py +++ b/newton/_src/solvers/kamino/examples/newton/example_dr_legs.py @@ -149,8 +149,9 @@ def test_final(self): self.model, self.state_0, "body velocities are small", - lambda q, qd: max(abs(qd)) - < 0.25, # Relaxed from 0.1 - unified pipeline has residual velocities up to ~0.2 + lambda q, qd: ( + max(abs(qd)) < 0.25 + ), # Relaxed from 0.1 - unified pipeline has residual velocities up to ~0.2 ) diff --git a/newton/_src/usd/utils.py b/newton/_src/usd/utils.py index cf3b35fd21..8823df56a1 100644 --- a/newton/_src/usd/utils.py +++ b/newton/_src/usd/utils.py @@ -1718,11 +1718,9 @@ def _get_bound_material(target_prim: Usd.Prim) -> UsdShade.Material | None: if not rels: return None rels.sort( - key=lambda rel: 0 - if rel.GetName() == "material:binding" - else 1 - if rel.GetName() == "material:binding:preview" - else 2 + key=lambda rel: ( + 0 if rel.GetName() == "material:binding" else 1 if rel.GetName() == "material:binding:preview" else 2 + ) ) for rel in rels: targets = rel.GetTargets() diff --git a/newton/_src/utils/selection.py b/newton/_src/utils/selection.py index 7bc9716acf..94e71d88ab 100644 --- a/newton/_src/utils/selection.py +++ b/newton/_src/utils/selection.py @@ -380,7 +380,7 @@ def get_name_from_label(label: str): Returns: The final path component of the label. """ - return label.split("/")[-1] + return label.rsplit("/", maxsplit=1)[-1] def find_matching_ids(pattern: str, labels: list[str], world_ids, world_count: int): diff --git a/newton/examples/basic/example_basic_joints.py b/newton/examples/basic/example_basic_joints.py index 3b8dfbe3bb..31a0f892f9 100644 --- a/newton/examples/basic/example_basic_joints.py +++ b/newton/examples/basic/example_basic_joints.py @@ -226,8 +226,10 @@ def test_post_step(self): self.model, self.state_0, "linear motion on axis", - lambda q, qd: wp.length(abs(wp.cross(wp.spatial_top(qd), wp.vec3(0.0, 0.0, 1.0)))) < 1e-5 - and wp.length(wp.spatial_bottom(qd)) < 1e-5, + lambda q, qd: ( + wp.length(abs(wp.cross(wp.spatial_top(qd), wp.vec3(0.0, 0.0, 1.0)))) < 1e-5 + and wp.length(wp.spatial_bottom(qd)) < 1e-5 + ), indices=[self.model.body_label.index("b_prismatic")], ) diff --git a/newton/examples/basic/example_basic_shapes.py b/newton/examples/basic/example_basic_shapes.py index 5e31a2dd6e..e6739b0b3f 100644 --- a/newton/examples/basic/example_basic_shapes.py +++ b/newton/examples/basic/example_basic_shapes.py @@ -190,13 +190,15 @@ def test_final(self): self.model, self.state_0, "cylinder at rest pose", - lambda q, qd: abs(q[0] - cylinder_q[0]) < 0.01 - and abs(q[1] - cylinder_q[1]) < 0.01 - and abs(q[2] - cylinder_q[2]) < 1e-4 - and abs(q[3] - cylinder_q[3]) < 1e-4 - and abs(q[4] - cylinder_q[4]) < 1e-4 - and abs(q[5] - cylinder_q[5]) < 1e-4 - and abs(q[6] - cylinder_q[6]) < 1e-4, + lambda q, qd: ( + abs(q[0] - cylinder_q[0]) < 0.01 + and abs(q[1] - cylinder_q[1]) < 0.01 + and abs(q[2] - cylinder_q[2]) < 1e-4 + and abs(q[3] - cylinder_q[3]) < 1e-4 + and abs(q[4] - cylinder_q[4]) < 1e-4 + and abs(q[5] - cylinder_q[5]) < 1e-4 + and abs(q[6] - cylinder_q[6]) < 1e-4 + ), [3], ) self.box_pos[2] = 0.25 diff --git a/newton/examples/robot/example_robot_anymal_d.py b/newton/examples/robot/example_robot_anymal_d.py index 345f6a61c2..1b4214701a 100644 --- a/newton/examples/robot/example_robot_anymal_d.py +++ b/newton/examples/robot/example_robot_anymal_d.py @@ -152,8 +152,9 @@ def test_final(self): self.model, self.state_0, "body velocities are small", - lambda q, qd: max(abs(qd)) - < 0.25, # Relaxed from 0.1 - collision pipeline has residual velocities up to ~0.2 + lambda q, qd: ( + max(abs(qd)) < 0.25 + ), # Relaxed from 0.1 - collision pipeline has residual velocities up to ~0.2 ) @staticmethod diff --git a/newton/examples/robot/example_robot_cartpole.py b/newton/examples/robot/example_robot_cartpole.py index 277aaff665..ece484032b 100644 --- a/newton/examples/robot/example_robot_cartpole.py +++ b/newton/examples/robot/example_robot_cartpole.py @@ -129,34 +129,37 @@ def test_final(self): self.model, self.state_0, "cart only moves along y direction", - lambda q, qd: qd[0] == 0.0 - and abs(qd[1]) > 0.05 - and qd[2] == 0.0 - and wp.length_sq(wp.spatial_bottom(qd)) == 0.0, + lambda q, qd: ( + qd[0] == 0.0 and abs(qd[1]) > 0.05 and qd[2] == 0.0 and wp.length_sq(wp.spatial_bottom(qd)) == 0.0 + ), indices=[i * num_bodies_per_world for i in range(self.world_count)], ) newton.examples.test_body_state( self.model, self.state_0, "pole1 only has y-axis linear velocity and x-axis angular velocity", - lambda q, qd: qd[0] == 0.0 - and abs(qd[1]) > 0.05 - and qd[2] == 0.0 - and abs(qd[3]) > 0.3 - and qd[4] == 0.0 - and qd[5] == 0.0, + lambda q, qd: ( + qd[0] == 0.0 + and abs(qd[1]) > 0.05 + and qd[2] == 0.0 + and abs(qd[3]) > 0.3 + and qd[4] == 0.0 + and qd[5] == 0.0 + ), indices=[i * num_bodies_per_world + 1 for i in range(self.world_count)], ) newton.examples.test_body_state( self.model, self.state_0, "pole2 only has yz-plane linear velocity and x-axis angular velocity", - lambda q, qd: qd[0] == 0.0 - and abs(qd[1]) > 0.05 - and abs(qd[2]) > 0.05 - and abs(qd[3]) > 0.2 - and qd[4] == 0.0 - and qd[5] == 0.0, + lambda q, qd: ( + qd[0] == 0.0 + and abs(qd[1]) > 0.05 + and abs(qd[2]) > 0.05 + and abs(qd[3]) > 0.2 + and qd[4] == 0.0 + and qd[5] == 0.0 + ), indices=[i * num_bodies_per_world + 2 for i in range(self.world_count)], ) qd = self.state_0.body_qd.numpy() diff --git a/newton/examples/robot/example_robot_g1.py b/newton/examples/robot/example_robot_g1.py index 339e407d25..f86f919dc9 100644 --- a/newton/examples/robot/example_robot_g1.py +++ b/newton/examples/robot/example_robot_g1.py @@ -147,8 +147,9 @@ def test_final(self): self.model, self.state_0, "all body velocities are small", - lambda q, qd: max(abs(qd)) - < 0.015, # Relaxed from 0.005 - G1 has higher residual velocities with collision pipeline + lambda q, qd: ( + max(abs(qd)) < 0.015 + ), # Relaxed from 0.005 - G1 has higher residual velocities with collision pipeline ) @staticmethod diff --git a/newton/examples/selection/example_selection_cartpole.py b/newton/examples/selection/example_selection_cartpole.py index e21618fe72..c602eb643b 100644 --- a/newton/examples/selection/example_selection_cartpole.py +++ b/newton/examples/selection/example_selection_cartpole.py @@ -185,34 +185,37 @@ def test_final(self): self.model, self.state_0, "cart only moves along y direction", - lambda q, qd: qd[0] == 0.0 - and abs(qd[1]) > 0.05 - and qd[2] == 0.0 - and wp.length_sq(wp.spatial_bottom(qd)) == 0.0, + lambda q, qd: ( + qd[0] == 0.0 and abs(qd[1]) > 0.05 and qd[2] == 0.0 and wp.length_sq(wp.spatial_bottom(qd)) == 0.0 + ), indices=[i * num_bodies_per_world for i in range(self.world_count)], ) newton.examples.test_body_state( self.model, self.state_0, "pole1 only has y-axis linear velocity and x-axis angular velocity", - lambda q, qd: qd[0] == 0.0 - and abs(qd[1]) > 0.05 - and qd[2] == 0.0 - and abs(qd[3]) > 0.3 - and qd[4] == 0.0 - and qd[5] == 0.0, + lambda q, qd: ( + qd[0] == 0.0 + and abs(qd[1]) > 0.05 + and qd[2] == 0.0 + and abs(qd[3]) > 0.3 + and qd[4] == 0.0 + and qd[5] == 0.0 + ), indices=[i * num_bodies_per_world + 1 for i in range(self.world_count)], ) newton.examples.test_body_state( self.model, self.state_0, "pole2 only has yz-plane linear velocity and x-axis angular velocity", - lambda q, qd: qd[0] == 0.0 - and abs(qd[1]) > 0.05 - and abs(qd[2]) > 0.05 - and abs(qd[3]) > 0.2 - and qd[4] == 0.0 - and qd[5] == 0.0, + lambda q, qd: ( + qd[0] == 0.0 + and abs(qd[1]) > 0.05 + and abs(qd[2]) > 0.05 + and abs(qd[3]) > 0.2 + and qd[4] == 0.0 + and qd[5] == 0.0 + ), indices=[i * num_bodies_per_world + 2 for i in range(self.world_count)], )