Skip to content

Commit d0b7315

Browse files
committed
a number of lint/docs/tool tweaks
1 parent d395330 commit d0b7315

File tree

16 files changed

+566
-509
lines changed

16 files changed

+566
-509
lines changed

.pre-commit-config.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
7-
exclude: (thirdparty/.*)|(.txt)$
7+
exclude: (thirdparty/.*)|(SOPHUS_VERSION)|(.txt)$
88
- id: check-yaml
99
args: ["--unsafe"]
1010
- id: check-json
@@ -26,3 +26,20 @@ repos:
2626
- id: cmake-format
2727
# lint does not pass
2828
#- id: cmake-lint
29+
- repo: https://github.com/astral-sh/ruff-pre-commit
30+
# Ruff version.
31+
rev: v0.4.8
32+
hooks:
33+
# Run the linter.
34+
- id: ruff
35+
args: [ --fix ]
36+
exclude: (sophus_pybind-stubs/.*)
37+
# Run the formatter.
38+
- id: ruff-format
39+
- repo: https://github.com/codespell-project/codespell
40+
rev: v2.1.0
41+
hooks:
42+
- id: codespell
43+
args:
44+
- --ignore-words-list
45+
- "te,tring,crate"

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 3.24)
2-
project(Sophus VERSION 1.24.6)
2+
3+
file(READ "SOPHUS_VERSION" SOPHUS_VERSION)
4+
project(Sophus VERSION ${SOPHUS_VERSION})
35

46
include(CMakePackageConfigHelpers)
57
include(GNUInstallDirs)

SOPHUS_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.24.6

examples/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.24)
22

33
project(SophusExample)
44

5-
find_package(Sophus 1.24.6 REQUIRED)
5+
file(READ "../SOPHUS_VERSION" SOPHUS_VERSION)
6+
find_package(Sophus ${SOPHUS_VERSION} REQUIRED)
67
set(CMAKE_CXX_STANDARD 17)
78

89
# Release by default Turn on Debug with "-DCMAKE_BUILD_TYPE=Debug"

package.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.

setup.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import re
3-
import shutil
3+
from pathlib import Path
44
import subprocess
55
import sys
66

@@ -17,6 +17,7 @@
1717
"win-arm64": "ARM64",
1818
}
1919

20+
2021
# A CMakeExtension needs a sourcedir instead of a file list.
2122
# The name must be the _single_ output extension from the CMake build.
2223
# If you need multiple extensions, see scikit-build.
@@ -69,7 +70,6 @@ def build_extension(self, ext):
6970
pass
7071

7172
else:
72-
7373
# Single config generators are handled "normally"
7474
single_config = any(x in cmake_generator for x in {"NMake", "Ninja"})
7575

@@ -108,30 +108,40 @@ def build_extension(self, ext):
108108
os.makedirs(self.build_temp)
109109

110110
if not os.path.exists(self.build_lib):
111-
os.makedirs(self.build_lib)
111+
os.makedirs(self.build_lib)
112112

113-
subprocess.check_call(["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp)
113+
subprocess.check_call(
114+
["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp
115+
)
114116
subprocess.check_call(
115117
["cmake", "--build", "."] + build_args, cwd=self.build_temp
116118
)
117119

118120
# copy stubs files from sophus_pybind-stubs to lib folder to be installed
119121
subprocess.run(
120-
f"cp sophus_pybind-stubs/*.pyi {self.build_lib}", shell=True, check=True,
122+
f"cp sophus_pybind-stubs/*.pyi {self.build_lib}",
123+
shell=True,
124+
check=True,
121125
)
122126
subprocess.run(
123-
f"cp sophus_pybind-stubs/*.typed {self.build_lib}", shell=True, check=True,
127+
f"cp sophus_pybind-stubs/*.typed {self.build_lib}",
128+
shell=True,
129+
check=True,
124130
)
125131
# copy .so file to lib
126-
subprocess.run(f"cp {self.build_temp}/*.so {self.build_lib}/", shell=True, check=True,)
132+
subprocess.run(
133+
f"cp {self.build_temp}/*.so {self.build_lib}/",
134+
shell=True,
135+
check=True,
136+
)
127137

128138

129139
def main():
130140
# The information here can also be placed in setup.cfg - better separation of
131141
# logic and declaration, and simpler if you include description/version in a file.
132142
setup(
133143
name="sophus_pybind",
134-
version="1.24.6",
144+
version=Path("SOPHUS_VERSION").read_text(),
135145
description="Sophus python API",
136146
long_description="Python API for sophus library",
137147
url="https://github.com/strasdat/sophus",

sophus_pybind-stubs/sophus_pybind.pyi

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,78 @@
11
from __future__ import annotations
22
import numpy
33
import typing
4-
__all__ = ['SE3', 'SO3', 'interpolate', 'iterativeMean']
4+
5+
__all__ = ["SE3", "SO3", "interpolate", "iterativeMean"]
6+
57
class SE3:
68
@staticmethod
79
@typing.overload
8-
def exp(arg0: numpy.ndarray[numpy.float64[3, 1]], arg1: numpy.ndarray[numpy.float64[3, 1]]) -> SE3:
10+
def exp(
11+
arg0: numpy.ndarray[numpy.float64[3, 1]],
12+
arg1: numpy.ndarray[numpy.float64[3, 1]],
13+
) -> SE3:
914
"""
1015
Create SE3 from a translational_part (3x1) and a rotation vector (3x1) of magnitude in rad. NOTE: translational_part is not translation vector in SE3
1116
"""
1217
@staticmethod
1318
@typing.overload
14-
def exp(arg0: numpy.ndarray[numpy.float64[m, 3]], arg1: numpy.ndarray[numpy.float64[m, 3]]) -> SE3:
19+
def exp(
20+
arg0: numpy.ndarray[numpy.float64[m, 3]],
21+
arg1: numpy.ndarray[numpy.float64[m, 3]],
22+
) -> SE3:
1523
"""
1624
Create a set of SE3 from translational_parts (Nx3) and rotation vectors (Nx3) of magnitude in rad. NOTE: translational_part is not translation vector in SE3
1725
"""
1826
@staticmethod
1927
@typing.overload
20-
def from_matrix(arg0: numpy.ndarray[numpy.float64[4, 4]]) -> SE3:
21-
...
28+
def from_matrix(arg0: numpy.ndarray[numpy.float64[4, 4]]) -> SE3: ...
2229
@staticmethod
2330
@typing.overload
24-
def from_matrix(arg0: numpy.ndarray[numpy.float64]) -> SE3:
25-
...
31+
def from_matrix(arg0: numpy.ndarray[numpy.float64]) -> SE3: ...
2632
@staticmethod
2733
@typing.overload
28-
def from_matrix3x4(arg0: numpy.ndarray[numpy.float64[3, 4]]) -> SE3:
29-
...
34+
def from_matrix3x4(arg0: numpy.ndarray[numpy.float64[3, 4]]) -> SE3: ...
3035
@staticmethod
3136
@typing.overload
32-
def from_matrix3x4(arg0: numpy.ndarray[numpy.float64]) -> SE3:
33-
...
34-
def __copy__(self) -> SE3:
35-
...
36-
def __getitem__(self, arg0: typing.Any) -> SE3:
37-
...
38-
def __imatmul__(self, arg0: SE3) -> SE3:
39-
...
37+
def from_matrix3x4(arg0: numpy.ndarray[numpy.float64]) -> SE3: ...
38+
def __copy__(self) -> SE3: ...
39+
def __getitem__(self, arg0: typing.Any) -> SE3: ...
40+
def __imatmul__(self, arg0: SE3) -> SE3: ...
4041
@typing.overload
4142
def __init__(self) -> None:
4243
"""
43-
Default Constructor initializing a group containing 1 identity element
44+
Default Constructor initializing a group containing 1 identity element
4445
"""
4546
@typing.overload
4647
def __init__(self, arg0: SE3) -> None:
4748
"""
4849
Copy constructor from single element
4950
"""
50-
def __len__(self) -> int:
51-
...
51+
def __len__(self) -> int: ...
5252
@typing.overload
53-
def __matmul__(self, arg0: SE3) -> SE3:
54-
...
53+
def __matmul__(self, arg0: SE3) -> SE3: ...
5554
@typing.overload
56-
def __matmul__(self, arg0: numpy.ndarray[numpy.float64[3, n]]) -> numpy.ndarray[numpy.float64[3, n]]:
57-
...
58-
def __repr__(self) -> str:
59-
...
60-
def __setitem__(self, arg0: typing.Any, arg1: SE3) -> None:
61-
...
62-
def __str__(self) -> str:
63-
...
55+
def __matmul__(
56+
self, arg0: numpy.ndarray[numpy.float64[3, n]]
57+
) -> numpy.ndarray[numpy.float64[3, n]]: ...
58+
def __repr__(self) -> str: ...
59+
def __setitem__(self, arg0: typing.Any, arg1: SE3) -> None: ...
60+
def __str__(self) -> str: ...
6461
@typing.overload
65-
def from_quat_and_translation(self, arg0: numpy.ndarray[numpy.float64[3, 1]], arg1: numpy.ndarray[numpy.float64[3, 1]]) -> SE3:
62+
def from_quat_and_translation(
63+
self,
64+
arg0: numpy.ndarray[numpy.float64[3, 1]],
65+
arg1: numpy.ndarray[numpy.float64[3, 1]],
66+
) -> SE3:
6667
"""
6768
Create SE3 from a quaternion as w, [x, y, z], and translation vector
6869
"""
6970
@typing.overload
70-
def from_quat_and_translation(self, arg0: numpy.ndarray[numpy.float64[m, 3]], arg1: numpy.ndarray[numpy.float64[m, 3]]) -> SE3:
71+
def from_quat_and_translation(
72+
self,
73+
arg0: numpy.ndarray[numpy.float64[m, 3]],
74+
arg1: numpy.ndarray[numpy.float64[m, 3]],
75+
) -> SE3:
7176
"""
7277
Create SE3 from a list of quaternion as w_vec: Nx1, xyz_vec: Nx3, and a list of translation vectors: Nx3
7378
"""
@@ -99,6 +104,7 @@ class SE3:
99104
"""
100105
Get the translation component of the transformation.
101106
"""
107+
102108
class SO3:
103109
@staticmethod
104110
def exp(arg0: numpy.ndarray[numpy.float64[m, 3]]) -> SO3:
@@ -107,12 +113,10 @@ class SO3:
107113
"""
108114
@staticmethod
109115
@typing.overload
110-
def from_matrix(arg0: numpy.ndarray[numpy.float64[3, 3]]) -> SO3:
111-
...
116+
def from_matrix(arg0: numpy.ndarray[numpy.float64[3, 3]]) -> SO3: ...
112117
@staticmethod
113118
@typing.overload
114-
def from_matrix(arg0: numpy.ndarray[numpy.float64]) -> SO3:
115-
...
119+
def from_matrix(arg0: numpy.ndarray[numpy.float64]) -> SO3: ...
116120
@staticmethod
117121
@typing.overload
118122
def from_quat(arg0: float, arg1: numpy.ndarray[numpy.float64[3, 1]]) -> SO3:
@@ -125,36 +129,29 @@ class SO3:
125129
"""
126130
Create rotations from a list of quaternions as w_vec: Nx1, xyz_vec: Nx3
127131
"""
128-
def __copy__(self) -> SO3:
129-
...
130-
def __getitem__(self, arg0: typing.Any) -> SO3:
131-
...
132-
def __imatmul__(self, arg0: SO3) -> SO3:
133-
...
132+
def __copy__(self) -> SO3: ...
133+
def __getitem__(self, arg0: typing.Any) -> SO3: ...
134+
def __imatmul__(self, arg0: SO3) -> SO3: ...
134135
@typing.overload
135136
def __init__(self) -> None:
136137
"""
137-
Default Constructor initializing a group containing 1 identity element
138+
Default Constructor initializing a group containing 1 identity element
138139
"""
139140
@typing.overload
140141
def __init__(self, arg0: SO3) -> None:
141142
"""
142143
Copy constructor from single element
143144
"""
144-
def __len__(self) -> int:
145-
...
145+
def __len__(self) -> int: ...
146146
@typing.overload
147-
def __matmul__(self, arg0: SO3) -> SO3:
148-
...
147+
def __matmul__(self, arg0: SO3) -> SO3: ...
149148
@typing.overload
150-
def __matmul__(self, arg0: numpy.ndarray[numpy.float64[3, n]]) -> numpy.ndarray[numpy.float64[3, n]]:
151-
...
152-
def __repr__(self) -> str:
153-
...
154-
def __setitem__(self, arg0: typing.Any, arg1: SO3) -> None:
155-
...
156-
def __str__(self) -> str:
157-
...
149+
def __matmul__(
150+
self, arg0: numpy.ndarray[numpy.float64[3, n]]
151+
) -> numpy.ndarray[numpy.float64[3, n]]: ...
152+
def __repr__(self) -> str: ...
153+
def __setitem__(self, arg0: typing.Any, arg1: SO3) -> None: ...
154+
def __str__(self) -> str: ...
158155
def inverse(self) -> SO3:
159156
"""
160157
Compute the inverse of the rotations.
@@ -171,10 +168,12 @@ class SO3:
171168
"""
172169
Return quaternion as Nx4 vectors with the order [w x y z].
173170
"""
171+
174172
def interpolate(arg0: SE3, arg1: SE3, arg2: float) -> SE3:
175173
"""
176174
Interpolate two SE3s of size 1.
177175
"""
176+
178177
def iterativeMean(arg0: SE3) -> SE3:
179178
"""
180179
Compute the iterative mean of a sequence.

0 commit comments

Comments
 (0)