Skip to content

Commit

Permalink
a number of lint/docs/tool tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
strasdat committed Jun 12, 2024
1 parent d395330 commit d0b7315
Show file tree
Hide file tree
Showing 16 changed files with 566 additions and 509 deletions.
19 changes: 18 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: (thirdparty/.*)|(.txt)$
exclude: (thirdparty/.*)|(SOPHUS_VERSION)|(.txt)$
- id: check-yaml
args: ["--unsafe"]
- id: check-json
Expand All @@ -26,3 +26,20 @@ repos:
- id: cmake-format
# lint does not pass
#- id: cmake-lint
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.8
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
exclude: (sophus_pybind-stubs/.*)
# Run the formatter.
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
args:
- --ignore-words-list
- "te,tring,crate"
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.24)
project(Sophus VERSION 1.24.6)

file(READ "SOPHUS_VERSION" SOPHUS_VERSION)
project(Sophus VERSION ${SOPHUS_VERSION})

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
Expand Down
1 change: 1 addition & 0 deletions SOPHUS_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.24.6
3 changes: 2 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.24)

project(SophusExample)

find_package(Sophus 1.24.6 REQUIRED)
file(READ "../SOPHUS_VERSION" SOPHUS_VERSION)
find_package(Sophus ${SOPHUS_VERSION} REQUIRED)
set(CMAKE_CXX_STANDARD 17)

# Release by default Turn on Debug with "-DCMAKE_BUILD_TYPE=Debug"
Expand Down
22 changes: 0 additions & 22 deletions package.xml

This file was deleted.

26 changes: 18 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import re
import shutil
from pathlib import Path
import subprocess
import sys

Expand All @@ -17,6 +17,7 @@
"win-arm64": "ARM64",
}


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

else:

# Single config generators are handled "normally"
single_config = any(x in cmake_generator for x in {"NMake", "Ninja"})

Expand Down Expand Up @@ -108,30 +108,40 @@ def build_extension(self, ext):
os.makedirs(self.build_temp)

if not os.path.exists(self.build_lib):
os.makedirs(self.build_lib)
os.makedirs(self.build_lib)

subprocess.check_call(["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp)
subprocess.check_call(
["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp
)
subprocess.check_call(
["cmake", "--build", "."] + build_args, cwd=self.build_temp
)

# copy stubs files from sophus_pybind-stubs to lib folder to be installed
subprocess.run(
f"cp sophus_pybind-stubs/*.pyi {self.build_lib}", shell=True, check=True,
f"cp sophus_pybind-stubs/*.pyi {self.build_lib}",
shell=True,
check=True,
)
subprocess.run(
f"cp sophus_pybind-stubs/*.typed {self.build_lib}", shell=True, check=True,
f"cp sophus_pybind-stubs/*.typed {self.build_lib}",
shell=True,
check=True,
)
# copy .so file to lib
subprocess.run(f"cp {self.build_temp}/*.so {self.build_lib}/", shell=True, check=True,)
subprocess.run(
f"cp {self.build_temp}/*.so {self.build_lib}/",
shell=True,
check=True,
)


def main():
# The information here can also be placed in setup.cfg - better separation of
# logic and declaration, and simpler if you include description/version in a file.
setup(
name="sophus_pybind",
version="1.24.6",
version=Path("SOPHUS_VERSION").read_text(),
description="Sophus python API",
long_description="Python API for sophus library",
url="https://github.com/strasdat/sophus",
Expand Down
109 changes: 54 additions & 55 deletions sophus_pybind-stubs/sophus_pybind.pyi
Original file line number Diff line number Diff line change
@@ -1,73 +1,78 @@
from __future__ import annotations
import numpy
import typing
__all__ = ['SE3', 'SO3', 'interpolate', 'iterativeMean']

__all__ = ["SE3", "SO3", "interpolate", "iterativeMean"]

class SE3:
@staticmethod
@typing.overload
def exp(arg0: numpy.ndarray[numpy.float64[3, 1]], arg1: numpy.ndarray[numpy.float64[3, 1]]) -> SE3:
def exp(
arg0: numpy.ndarray[numpy.float64[3, 1]],
arg1: numpy.ndarray[numpy.float64[3, 1]],
) -> SE3:
"""
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
"""
@staticmethod
@typing.overload
def exp(arg0: numpy.ndarray[numpy.float64[m, 3]], arg1: numpy.ndarray[numpy.float64[m, 3]]) -> SE3:
def exp(
arg0: numpy.ndarray[numpy.float64[m, 3]],
arg1: numpy.ndarray[numpy.float64[m, 3]],
) -> SE3:
"""
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
"""
@staticmethod
@typing.overload
def from_matrix(arg0: numpy.ndarray[numpy.float64[4, 4]]) -> SE3:
...
def from_matrix(arg0: numpy.ndarray[numpy.float64[4, 4]]) -> SE3: ...
@staticmethod
@typing.overload
def from_matrix(arg0: numpy.ndarray[numpy.float64]) -> SE3:
...
def from_matrix(arg0: numpy.ndarray[numpy.float64]) -> SE3: ...
@staticmethod
@typing.overload
def from_matrix3x4(arg0: numpy.ndarray[numpy.float64[3, 4]]) -> SE3:
...
def from_matrix3x4(arg0: numpy.ndarray[numpy.float64[3, 4]]) -> SE3: ...
@staticmethod
@typing.overload
def from_matrix3x4(arg0: numpy.ndarray[numpy.float64]) -> SE3:
...
def __copy__(self) -> SE3:
...
def __getitem__(self, arg0: typing.Any) -> SE3:
...
def __imatmul__(self, arg0: SE3) -> SE3:
...
def from_matrix3x4(arg0: numpy.ndarray[numpy.float64]) -> SE3: ...
def __copy__(self) -> SE3: ...
def __getitem__(self, arg0: typing.Any) -> SE3: ...
def __imatmul__(self, arg0: SE3) -> SE3: ...
@typing.overload
def __init__(self) -> None:
"""
Default Constructor initializing a group containing 1 identity element
Default Constructor initializing a group containing 1 identity element
"""
@typing.overload
def __init__(self, arg0: SE3) -> None:
"""
Copy constructor from single element
"""
def __len__(self) -> int:
...
def __len__(self) -> int: ...
@typing.overload
def __matmul__(self, arg0: SE3) -> SE3:
...
def __matmul__(self, arg0: SE3) -> SE3: ...
@typing.overload
def __matmul__(self, arg0: numpy.ndarray[numpy.float64[3, n]]) -> numpy.ndarray[numpy.float64[3, n]]:
...
def __repr__(self) -> str:
...
def __setitem__(self, arg0: typing.Any, arg1: SE3) -> None:
...
def __str__(self) -> str:
...
def __matmul__(
self, arg0: numpy.ndarray[numpy.float64[3, n]]
) -> numpy.ndarray[numpy.float64[3, n]]: ...
def __repr__(self) -> str: ...
def __setitem__(self, arg0: typing.Any, arg1: SE3) -> None: ...
def __str__(self) -> str: ...
@typing.overload
def from_quat_and_translation(self, arg0: numpy.ndarray[numpy.float64[3, 1]], arg1: numpy.ndarray[numpy.float64[3, 1]]) -> SE3:
def from_quat_and_translation(
self,
arg0: numpy.ndarray[numpy.float64[3, 1]],
arg1: numpy.ndarray[numpy.float64[3, 1]],
) -> SE3:
"""
Create SE3 from a quaternion as w, [x, y, z], and translation vector
"""
@typing.overload
def from_quat_and_translation(self, arg0: numpy.ndarray[numpy.float64[m, 3]], arg1: numpy.ndarray[numpy.float64[m, 3]]) -> SE3:
def from_quat_and_translation(
self,
arg0: numpy.ndarray[numpy.float64[m, 3]],
arg1: numpy.ndarray[numpy.float64[m, 3]],
) -> SE3:
"""
Create SE3 from a list of quaternion as w_vec: Nx1, xyz_vec: Nx3, and a list of translation vectors: Nx3
"""
Expand Down Expand Up @@ -99,6 +104,7 @@ class SE3:
"""
Get the translation component of the transformation.
"""

class SO3:
@staticmethod
def exp(arg0: numpy.ndarray[numpy.float64[m, 3]]) -> SO3:
Expand All @@ -107,12 +113,10 @@ class SO3:
"""
@staticmethod
@typing.overload
def from_matrix(arg0: numpy.ndarray[numpy.float64[3, 3]]) -> SO3:
...
def from_matrix(arg0: numpy.ndarray[numpy.float64[3, 3]]) -> SO3: ...
@staticmethod
@typing.overload
def from_matrix(arg0: numpy.ndarray[numpy.float64]) -> SO3:
...
def from_matrix(arg0: numpy.ndarray[numpy.float64]) -> SO3: ...
@staticmethod
@typing.overload
def from_quat(arg0: float, arg1: numpy.ndarray[numpy.float64[3, 1]]) -> SO3:
Expand All @@ -125,36 +129,29 @@ class SO3:
"""
Create rotations from a list of quaternions as w_vec: Nx1, xyz_vec: Nx3
"""
def __copy__(self) -> SO3:
...
def __getitem__(self, arg0: typing.Any) -> SO3:
...
def __imatmul__(self, arg0: SO3) -> SO3:
...
def __copy__(self) -> SO3: ...
def __getitem__(self, arg0: typing.Any) -> SO3: ...
def __imatmul__(self, arg0: SO3) -> SO3: ...
@typing.overload
def __init__(self) -> None:
"""
Default Constructor initializing a group containing 1 identity element
Default Constructor initializing a group containing 1 identity element
"""
@typing.overload
def __init__(self, arg0: SO3) -> None:
"""
Copy constructor from single element
"""
def __len__(self) -> int:
...
def __len__(self) -> int: ...
@typing.overload
def __matmul__(self, arg0: SO3) -> SO3:
...
def __matmul__(self, arg0: SO3) -> SO3: ...
@typing.overload
def __matmul__(self, arg0: numpy.ndarray[numpy.float64[3, n]]) -> numpy.ndarray[numpy.float64[3, n]]:
...
def __repr__(self) -> str:
...
def __setitem__(self, arg0: typing.Any, arg1: SO3) -> None:
...
def __str__(self) -> str:
...
def __matmul__(
self, arg0: numpy.ndarray[numpy.float64[3, n]]
) -> numpy.ndarray[numpy.float64[3, n]]: ...
def __repr__(self) -> str: ...
def __setitem__(self, arg0: typing.Any, arg1: SO3) -> None: ...
def __str__(self) -> str: ...
def inverse(self) -> SO3:
"""
Compute the inverse of the rotations.
Expand All @@ -171,10 +168,12 @@ class SO3:
"""
Return quaternion as Nx4 vectors with the order [w x y z].
"""

def interpolate(arg0: SE3, arg1: SE3, arg2: float) -> SE3:
"""
Interpolate two SE3s of size 1.
"""

def iterativeMean(arg0: SE3) -> SE3:
"""
Compute the iterative mean of a sequence.
Expand Down
Loading

0 comments on commit d0b7315

Please sign in to comment.