diff --git a/gen/python/sym/atan_camera_cal.py b/gen/python/sym/atan_camera_cal.py index 59815ac9..fb91766b 100644 --- a/gen/python/sym/atan_camera_cal.py +++ b/gen/python/sym/atan_camera_cal.py @@ -4,6 +4,8 @@ # Do NOT modify by hand. # ----------------------------------------------------------------------------- +from __future__ import annotations + import typing as T import numpy @@ -29,11 +31,15 @@ class ATANCameraCal(object): # This is because of an issue where mypy doesn't recognize attributes defined in __slots__ # See https://github.com/python/mypy/issues/5941 if T.TYPE_CHECKING: - data = [] # type: T.List[float] - - def __init__(self, focal_length, principal_point, omega): - # type: (T.Union[T.Sequence[float], numpy.ndarray], T.Union[T.Sequence[float], numpy.ndarray], float) -> None - self.data = [] + data: T.List[float] = [] + + def __init__( + self, + focal_length: T.Union[T.Sequence[float], numpy.ndarray], + principal_point: T.Union[T.Sequence[float], numpy.ndarray], + omega: float, + ) -> None: + self.data: T.List[float] = [] if isinstance(focal_length, numpy.ndarray): if focal_length.shape in {(2, 1), (1, 2)}: focal_length = focal_length.flatten() @@ -69,32 +75,30 @@ def __init__(self, focal_length, principal_point, omega): self.data.extend(principal_point) self.data.append(omega) - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # CameraOps # -------------------------------------------------------------------------- - def focal_length(self): - # type: (ATANCameraCal) -> numpy.ndarray + def focal_length(self: ATANCameraCal) -> numpy.ndarray: """ Return the focal length. """ return ops.CameraOps.focal_length(self) - def principal_point(self): - # type: (ATANCameraCal) -> numpy.ndarray + def principal_point(self: ATANCameraCal) -> numpy.ndarray: """ Return the principal point. """ return ops.CameraOps.principal_point(self) - def pixel_from_camera_point(self, point, epsilon): - # type: (ATANCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: ATANCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -105,8 +109,9 @@ def pixel_from_camera_point(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point(self, point, epsilon) - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (ATANCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: ATANCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -119,8 +124,9 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point_with_jacobians(self, point, epsilon) - def camera_ray_from_pixel(self, pixel, epsilon): - # type: (ATANCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def camera_ray_from_pixel( + self: ATANCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -131,8 +137,9 @@ def camera_ray_from_pixel(self, pixel, epsilon): return ops.CameraOps.camera_ray_from_pixel(self, pixel, epsilon) - def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): - # type: (ATANCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def camera_ray_from_pixel_with_jacobians( + self: ATANCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -150,17 +157,14 @@ def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 5 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> ATANCameraCal + def from_storage(cls, vec: T.Sequence[float]) -> ATANCameraCal: instance = cls.__new__(cls) if isinstance(vec, list): @@ -180,13 +184,11 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 5 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> ATANCameraCal + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> ATANCameraCal: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -195,12 +197,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> ATANCameraCal + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> ATANCameraCal: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -209,19 +209,16 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (ATANCameraCal, float) -> numpy.ndarray + def local_coordinates(self, b: ATANCameraCal, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (ATANCameraCal, float, float) -> ATANCameraCal + def interpolate(self, b: ATANCameraCal, alpha: float, epsilon: float = 1e-8) -> ATANCameraCal: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, ATANCameraCal): return self.data == other.data else: diff --git a/gen/python/sym/double_sphere_camera_cal.py b/gen/python/sym/double_sphere_camera_cal.py index ee02b8fd..51ab3a3c 100644 --- a/gen/python/sym/double_sphere_camera_cal.py +++ b/gen/python/sym/double_sphere_camera_cal.py @@ -4,6 +4,8 @@ # Do NOT modify by hand. # ----------------------------------------------------------------------------- +from __future__ import annotations + import typing as T import numpy @@ -41,11 +43,16 @@ class DoubleSphereCameraCal(object): # This is because of an issue where mypy doesn't recognize attributes defined in __slots__ # See https://github.com/python/mypy/issues/5941 if T.TYPE_CHECKING: - data = [] # type: T.List[float] - - def __init__(self, focal_length, principal_point, xi, alpha): - # type: (T.Union[T.Sequence[float], numpy.ndarray], T.Union[T.Sequence[float], numpy.ndarray], float, float) -> None - self.data = [] + data: T.List[float] = [] + + def __init__( + self, + focal_length: T.Union[T.Sequence[float], numpy.ndarray], + principal_point: T.Union[T.Sequence[float], numpy.ndarray], + xi: float, + alpha: float, + ) -> None: + self.data: T.List[float] = [] if isinstance(focal_length, numpy.ndarray): if focal_length.shape in {(2, 1), (1, 2)}: focal_length = focal_length.flatten() @@ -82,32 +89,30 @@ def __init__(self, focal_length, principal_point, xi, alpha): self.data.append(xi) self.data.append(alpha) - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # CameraOps # -------------------------------------------------------------------------- - def focal_length(self): - # type: (DoubleSphereCameraCal) -> numpy.ndarray + def focal_length(self: DoubleSphereCameraCal) -> numpy.ndarray: """ Return the focal length. """ return ops.CameraOps.focal_length(self) - def principal_point(self): - # type: (DoubleSphereCameraCal) -> numpy.ndarray + def principal_point(self: DoubleSphereCameraCal) -> numpy.ndarray: """ Return the principal point. """ return ops.CameraOps.principal_point(self) - def pixel_from_camera_point(self, point, epsilon): - # type: (DoubleSphereCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: DoubleSphereCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -118,8 +123,9 @@ def pixel_from_camera_point(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point(self, point, epsilon) - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (DoubleSphereCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: DoubleSphereCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -132,8 +138,9 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point_with_jacobians(self, point, epsilon) - def camera_ray_from_pixel(self, pixel, epsilon): - # type: (DoubleSphereCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def camera_ray_from_pixel( + self: DoubleSphereCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -144,8 +151,9 @@ def camera_ray_from_pixel(self, pixel, epsilon): return ops.CameraOps.camera_ray_from_pixel(self, pixel, epsilon) - def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): - # type: (DoubleSphereCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def camera_ray_from_pixel_with_jacobians( + self: DoubleSphereCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -163,17 +171,14 @@ def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 6 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> DoubleSphereCameraCal + def from_storage(cls, vec: T.Sequence[float]) -> DoubleSphereCameraCal: instance = cls.__new__(cls) if isinstance(vec, list): @@ -193,13 +198,11 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 6 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> DoubleSphereCameraCal + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> DoubleSphereCameraCal: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -208,12 +211,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> DoubleSphereCameraCal + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> DoubleSphereCameraCal: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -222,19 +223,18 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (DoubleSphereCameraCal, float) -> numpy.ndarray + def local_coordinates(self, b: DoubleSphereCameraCal, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (DoubleSphereCameraCal, float, float) -> DoubleSphereCameraCal + def interpolate( + self, b: DoubleSphereCameraCal, alpha: float, epsilon: float = 1e-8 + ) -> DoubleSphereCameraCal: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, DoubleSphereCameraCal): return self.data == other.data else: diff --git a/gen/python/sym/equirectangular_camera_cal.py b/gen/python/sym/equirectangular_camera_cal.py index 2cd22f16..7250833f 100644 --- a/gen/python/sym/equirectangular_camera_cal.py +++ b/gen/python/sym/equirectangular_camera_cal.py @@ -4,6 +4,8 @@ # Do NOT modify by hand. # ----------------------------------------------------------------------------- +from __future__ import annotations + import typing as T import numpy @@ -25,11 +27,14 @@ class EquirectangularCameraCal(object): # This is because of an issue where mypy doesn't recognize attributes defined in __slots__ # See https://github.com/python/mypy/issues/5941 if T.TYPE_CHECKING: - data = [] # type: T.List[float] - - def __init__(self, focal_length, principal_point): - # type: (T.Union[T.Sequence[float], numpy.ndarray], T.Union[T.Sequence[float], numpy.ndarray]) -> None - self.data = [] + data: T.List[float] = [] + + def __init__( + self, + focal_length: T.Union[T.Sequence[float], numpy.ndarray], + principal_point: T.Union[T.Sequence[float], numpy.ndarray], + ) -> None: + self.data: T.List[float] = [] if isinstance(focal_length, numpy.ndarray): if focal_length.shape in {(2, 1), (1, 2)}: focal_length = focal_length.flatten() @@ -64,32 +69,30 @@ def __init__(self, focal_length, principal_point): self.data.extend(focal_length) self.data.extend(principal_point) - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # CameraOps # -------------------------------------------------------------------------- - def focal_length(self): - # type: (EquirectangularCameraCal) -> numpy.ndarray + def focal_length(self: EquirectangularCameraCal) -> numpy.ndarray: """ Return the focal length. """ return ops.CameraOps.focal_length(self) - def principal_point(self): - # type: (EquirectangularCameraCal) -> numpy.ndarray + def principal_point(self: EquirectangularCameraCal) -> numpy.ndarray: """ Return the principal point. """ return ops.CameraOps.principal_point(self) - def pixel_from_camera_point(self, point, epsilon): - # type: (EquirectangularCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: EquirectangularCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -100,8 +103,9 @@ def pixel_from_camera_point(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point(self, point, epsilon) - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (EquirectangularCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: EquirectangularCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -114,8 +118,9 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point_with_jacobians(self, point, epsilon) - def camera_ray_from_pixel(self, pixel, epsilon): - # type: (EquirectangularCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def camera_ray_from_pixel( + self: EquirectangularCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -126,8 +131,9 @@ def camera_ray_from_pixel(self, pixel, epsilon): return ops.CameraOps.camera_ray_from_pixel(self, pixel, epsilon) - def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): - # type: (EquirectangularCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def camera_ray_from_pixel_with_jacobians( + self: EquirectangularCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -145,17 +151,14 @@ def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 4 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> EquirectangularCameraCal + def from_storage(cls, vec: T.Sequence[float]) -> EquirectangularCameraCal: instance = cls.__new__(cls) if isinstance(vec, list): @@ -175,13 +178,11 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 4 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> EquirectangularCameraCal + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> EquirectangularCameraCal: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -190,12 +191,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> EquirectangularCameraCal + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> EquirectangularCameraCal: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -204,19 +203,20 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (EquirectangularCameraCal, float) -> numpy.ndarray + def local_coordinates( + self, b: EquirectangularCameraCal, epsilon: float = 1e-8 + ) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (EquirectangularCameraCal, float, float) -> EquirectangularCameraCal + def interpolate( + self, b: EquirectangularCameraCal, alpha: float, epsilon: float = 1e-8 + ) -> EquirectangularCameraCal: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, EquirectangularCameraCal): return self.data == other.data else: diff --git a/gen/python/sym/linear_camera_cal.py b/gen/python/sym/linear_camera_cal.py index ddf162df..3815ec15 100644 --- a/gen/python/sym/linear_camera_cal.py +++ b/gen/python/sym/linear_camera_cal.py @@ -4,6 +4,8 @@ # Do NOT modify by hand. # ----------------------------------------------------------------------------- +from __future__ import annotations + import typing as T import numpy @@ -25,11 +27,14 @@ class LinearCameraCal(object): # This is because of an issue where mypy doesn't recognize attributes defined in __slots__ # See https://github.com/python/mypy/issues/5941 if T.TYPE_CHECKING: - data = [] # type: T.List[float] - - def __init__(self, focal_length, principal_point): - # type: (T.Union[T.Sequence[float], numpy.ndarray], T.Union[T.Sequence[float], numpy.ndarray]) -> None - self.data = [] + data: T.List[float] = [] + + def __init__( + self, + focal_length: T.Union[T.Sequence[float], numpy.ndarray], + principal_point: T.Union[T.Sequence[float], numpy.ndarray], + ) -> None: + self.data: T.List[float] = [] if isinstance(focal_length, numpy.ndarray): if focal_length.shape in {(2, 1), (1, 2)}: focal_length = focal_length.flatten() @@ -64,32 +69,30 @@ def __init__(self, focal_length, principal_point): self.data.extend(focal_length) self.data.extend(principal_point) - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # CameraOps # -------------------------------------------------------------------------- - def focal_length(self): - # type: (LinearCameraCal) -> numpy.ndarray + def focal_length(self: LinearCameraCal) -> numpy.ndarray: """ Return the focal length. """ return ops.CameraOps.focal_length(self) - def principal_point(self): - # type: (LinearCameraCal) -> numpy.ndarray + def principal_point(self: LinearCameraCal) -> numpy.ndarray: """ Return the principal point. """ return ops.CameraOps.principal_point(self) - def pixel_from_camera_point(self, point, epsilon): - # type: (LinearCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: LinearCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -100,8 +103,9 @@ def pixel_from_camera_point(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point(self, point, epsilon) - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (LinearCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: LinearCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -114,8 +118,9 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point_with_jacobians(self, point, epsilon) - def camera_ray_from_pixel(self, pixel, epsilon): - # type: (LinearCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def camera_ray_from_pixel( + self: LinearCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -126,8 +131,9 @@ def camera_ray_from_pixel(self, pixel, epsilon): return ops.CameraOps.camera_ray_from_pixel(self, pixel, epsilon) - def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): - # type: (LinearCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def camera_ray_from_pixel_with_jacobians( + self: LinearCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -145,17 +151,14 @@ def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 4 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> LinearCameraCal + def from_storage(cls, vec: T.Sequence[float]) -> LinearCameraCal: instance = cls.__new__(cls) if isinstance(vec, list): @@ -175,13 +178,11 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 4 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> LinearCameraCal + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> LinearCameraCal: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -190,12 +191,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> LinearCameraCal + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> LinearCameraCal: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -204,19 +203,18 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (LinearCameraCal, float) -> numpy.ndarray + def local_coordinates(self, b: LinearCameraCal, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (LinearCameraCal, float, float) -> LinearCameraCal + def interpolate( + self, b: LinearCameraCal, alpha: float, epsilon: float = 1e-8 + ) -> LinearCameraCal: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, LinearCameraCal): return self.data == other.data else: diff --git a/gen/python/sym/ops/atan_camera_cal/camera_ops.py b/gen/python/sym/ops/atan_camera_cal/camera_ops.py index 8f56a5af..7ad9cf30 100644 --- a/gen/python/sym/ops/atan_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/atan_camera_cal/camera_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,8 +22,7 @@ class CameraOps(object): """ @staticmethod - def focal_length(self): - # type: (sym.ATANCameraCal) -> numpy.ndarray + def focal_length(self: sym.ATANCameraCal) -> numpy.ndarray: """ Return the focal length. """ @@ -40,8 +41,7 @@ def focal_length(self): return _focal_length @staticmethod - def principal_point(self): - # type: (sym.ATANCameraCal) -> numpy.ndarray + def principal_point(self: sym.ATANCameraCal) -> numpy.ndarray: """ Return the principal point. """ @@ -60,8 +60,9 @@ def principal_point(self): return _principal_point @staticmethod - def pixel_from_camera_point(self, point, epsilon): - # type: (sym.ATANCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: sym.ATANCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -97,8 +98,9 @@ def pixel_from_camera_point(self, point, epsilon): return _pixel, _is_valid @staticmethod - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (sym.ATANCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: sym.ATANCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -199,8 +201,9 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): return _pixel, _is_valid, _pixel_D_cal, _pixel_D_point @staticmethod - def camera_ray_from_pixel(self, pixel, epsilon): - # type: (sym.ATANCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def camera_ray_from_pixel( + self: sym.ATANCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -245,8 +248,9 @@ def camera_ray_from_pixel(self, pixel, epsilon): return _camera_ray, _is_valid @staticmethod - def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): - # type: (sym.ATANCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def camera_ray_from_pixel_with_jacobians( + self: sym.ATANCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. diff --git a/gen/python/sym/ops/atan_camera_cal/group_ops.py b/gen/python/sym/ops/atan_camera_cal/group_ops.py index 88fd1261..b5fd9605 100644 --- a/gen/python/sym/ops/atan_camera_cal/group_ops.py +++ b/gen/python/sym/ops/atan_camera_cal/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.ATANCameraCal - + def identity() -> sym.ATANCameraCal: # Total ops: 0 # Input arrays @@ -39,9 +39,7 @@ def identity(): return sym.ATANCameraCal.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.ATANCameraCal) -> sym.ATANCameraCal - + def inverse(a: sym.ATANCameraCal) -> sym.ATANCameraCal: # Total ops: 5 # Input arrays @@ -59,9 +57,7 @@ def inverse(a): return sym.ATANCameraCal.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.ATANCameraCal, sym.ATANCameraCal) -> sym.ATANCameraCal - + def compose(a: sym.ATANCameraCal, b: sym.ATANCameraCal) -> sym.ATANCameraCal: # Total ops: 5 # Input arrays @@ -80,9 +76,7 @@ def compose(a, b): return sym.ATANCameraCal.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.ATANCameraCal, sym.ATANCameraCal) -> sym.ATANCameraCal - + def between(a: sym.ATANCameraCal, b: sym.ATANCameraCal) -> sym.ATANCameraCal: # Total ops: 5 # Input arrays @@ -101,9 +95,7 @@ def between(a, b): return sym.ATANCameraCal.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.ATANCameraCal) -> T.Tuple[sym.ATANCameraCal, numpy.ndarray] - + def inverse_with_jacobian(a: sym.ATANCameraCal) -> T.Tuple[sym.ATANCameraCal, numpy.ndarray]: # Total ops: 5 # Input arrays @@ -147,9 +139,9 @@ def inverse_with_jacobian(a): return sym.ATANCameraCal.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.ATANCameraCal, sym.ATANCameraCal) -> T.Tuple[sym.ATANCameraCal, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.ATANCameraCal, b: sym.ATANCameraCal + ) -> T.Tuple[sym.ATANCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 5 # Input arrays @@ -220,9 +212,9 @@ def compose_with_jacobians(a, b): return sym.ATANCameraCal.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.ATANCameraCal, sym.ATANCameraCal) -> T.Tuple[sym.ATANCameraCal, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.ATANCameraCal, b: sym.ATANCameraCal + ) -> T.Tuple[sym.ATANCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 5 # Input arrays diff --git a/gen/python/sym/ops/atan_camera_cal/lie_group_ops.py b/gen/python/sym/ops/atan_camera_cal/lie_group_ops.py index 159b170b..d9a5b502 100644 --- a/gen/python/sym/ops/atan_camera_cal/lie_group_ops.py +++ b/gen/python/sym/ops/atan_camera_cal/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.ATANCameraCal - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.ATANCameraCal: # Total ops: 0 # Input arrays @@ -47,9 +47,7 @@ def from_tangent(vec, epsilon): return sym.ATANCameraCal.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.ATANCameraCal, float) -> numpy.ndarray - + def to_tangent(a: sym.ATANCameraCal, epsilon: float) -> numpy.ndarray: # Total ops: 0 # Input arrays @@ -67,9 +65,7 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.ATANCameraCal, numpy.ndarray, float) -> sym.ATANCameraCal - + def retract(a: sym.ATANCameraCal, vec: numpy.ndarray, epsilon: float) -> sym.ATANCameraCal: # Total ops: 5 # Input arrays @@ -95,9 +91,9 @@ def retract(a, vec, epsilon): return sym.ATANCameraCal.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.ATANCameraCal, sym.ATANCameraCal, float) -> numpy.ndarray - + def local_coordinates( + a: sym.ATANCameraCal, b: sym.ATANCameraCal, epsilon: float + ) -> numpy.ndarray: # Total ops: 5 # Input arrays @@ -116,9 +112,9 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.ATANCameraCal, sym.ATANCameraCal, float, float) -> sym.ATANCameraCal - + def interpolate( + a: sym.ATANCameraCal, b: sym.ATANCameraCal, alpha: float, epsilon: float + ) -> sym.ATANCameraCal: # Total ops: 15 # Input arrays diff --git a/gen/python/sym/ops/double_sphere_camera_cal/camera_ops.py b/gen/python/sym/ops/double_sphere_camera_cal/camera_ops.py index 204a330c..a5a0a48a 100644 --- a/gen/python/sym/ops/double_sphere_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/double_sphere_camera_cal/camera_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,8 +22,7 @@ class CameraOps(object): """ @staticmethod - def focal_length(self): - # type: (sym.DoubleSphereCameraCal) -> numpy.ndarray + def focal_length(self: sym.DoubleSphereCameraCal) -> numpy.ndarray: """ Return the focal length. """ @@ -40,8 +41,7 @@ def focal_length(self): return _focal_length @staticmethod - def principal_point(self): - # type: (sym.DoubleSphereCameraCal) -> numpy.ndarray + def principal_point(self: sym.DoubleSphereCameraCal) -> numpy.ndarray: """ Return the principal point. """ @@ -60,8 +60,9 @@ def principal_point(self): return _principal_point @staticmethod - def pixel_from_camera_point(self, point, epsilon): - # type: (sym.DoubleSphereCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: sym.DoubleSphereCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -149,8 +150,9 @@ def pixel_from_camera_point(self, point, epsilon): return _pixel, _is_valid @staticmethod - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (sym.DoubleSphereCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: sym.DoubleSphereCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -281,8 +283,9 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): return _pixel, _is_valid, _pixel_D_cal, _pixel_D_point @staticmethod - def camera_ray_from_pixel(self, pixel, epsilon): - # type: (sym.DoubleSphereCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def camera_ray_from_pixel( + self: sym.DoubleSphereCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -332,8 +335,9 @@ def camera_ray_from_pixel(self, pixel, epsilon): return _camera_ray, _is_valid @staticmethod - def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): - # type: (sym.DoubleSphereCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def camera_ray_from_pixel_with_jacobians( + self: sym.DoubleSphereCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. diff --git a/gen/python/sym/ops/double_sphere_camera_cal/group_ops.py b/gen/python/sym/ops/double_sphere_camera_cal/group_ops.py index e82bd942..b7d85560 100644 --- a/gen/python/sym/ops/double_sphere_camera_cal/group_ops.py +++ b/gen/python/sym/ops/double_sphere_camera_cal/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.DoubleSphereCameraCal - + def identity() -> sym.DoubleSphereCameraCal: # Total ops: 0 # Input arrays @@ -40,9 +40,7 @@ def identity(): return sym.DoubleSphereCameraCal.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.DoubleSphereCameraCal) -> sym.DoubleSphereCameraCal - + def inverse(a: sym.DoubleSphereCameraCal) -> sym.DoubleSphereCameraCal: # Total ops: 6 # Input arrays @@ -61,9 +59,9 @@ def inverse(a): return sym.DoubleSphereCameraCal.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.DoubleSphereCameraCal, sym.DoubleSphereCameraCal) -> sym.DoubleSphereCameraCal - + def compose( + a: sym.DoubleSphereCameraCal, b: sym.DoubleSphereCameraCal + ) -> sym.DoubleSphereCameraCal: # Total ops: 6 # Input arrays @@ -83,9 +81,9 @@ def compose(a, b): return sym.DoubleSphereCameraCal.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.DoubleSphereCameraCal, sym.DoubleSphereCameraCal) -> sym.DoubleSphereCameraCal - + def between( + a: sym.DoubleSphereCameraCal, b: sym.DoubleSphereCameraCal + ) -> sym.DoubleSphereCameraCal: # Total ops: 6 # Input arrays @@ -105,9 +103,9 @@ def between(a, b): return sym.DoubleSphereCameraCal.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.DoubleSphereCameraCal) -> T.Tuple[sym.DoubleSphereCameraCal, numpy.ndarray] - + def inverse_with_jacobian( + a: sym.DoubleSphereCameraCal, + ) -> T.Tuple[sym.DoubleSphereCameraCal, numpy.ndarray]: # Total ops: 6 # Input arrays @@ -163,9 +161,9 @@ def inverse_with_jacobian(a): return sym.DoubleSphereCameraCal.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.DoubleSphereCameraCal, sym.DoubleSphereCameraCal) -> T.Tuple[sym.DoubleSphereCameraCal, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.DoubleSphereCameraCal, b: sym.DoubleSphereCameraCal + ) -> T.Tuple[sym.DoubleSphereCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 6 # Input arrays @@ -259,9 +257,9 @@ def compose_with_jacobians(a, b): return sym.DoubleSphereCameraCal.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.DoubleSphereCameraCal, sym.DoubleSphereCameraCal) -> T.Tuple[sym.DoubleSphereCameraCal, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.DoubleSphereCameraCal, b: sym.DoubleSphereCameraCal + ) -> T.Tuple[sym.DoubleSphereCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 6 # Input arrays diff --git a/gen/python/sym/ops/double_sphere_camera_cal/lie_group_ops.py b/gen/python/sym/ops/double_sphere_camera_cal/lie_group_ops.py index f12af964..b102e1b5 100644 --- a/gen/python/sym/ops/double_sphere_camera_cal/lie_group_ops.py +++ b/gen/python/sym/ops/double_sphere_camera_cal/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.DoubleSphereCameraCal - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.DoubleSphereCameraCal: # Total ops: 0 # Input arrays @@ -48,9 +48,7 @@ def from_tangent(vec, epsilon): return sym.DoubleSphereCameraCal.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.DoubleSphereCameraCal, float) -> numpy.ndarray - + def to_tangent(a: sym.DoubleSphereCameraCal, epsilon: float) -> numpy.ndarray: # Total ops: 0 # Input arrays @@ -69,9 +67,9 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.DoubleSphereCameraCal, numpy.ndarray, float) -> sym.DoubleSphereCameraCal - + def retract( + a: sym.DoubleSphereCameraCal, vec: numpy.ndarray, epsilon: float + ) -> sym.DoubleSphereCameraCal: # Total ops: 6 # Input arrays @@ -98,9 +96,9 @@ def retract(a, vec, epsilon): return sym.DoubleSphereCameraCal.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.DoubleSphereCameraCal, sym.DoubleSphereCameraCal, float) -> numpy.ndarray - + def local_coordinates( + a: sym.DoubleSphereCameraCal, b: sym.DoubleSphereCameraCal, epsilon: float + ) -> numpy.ndarray: # Total ops: 6 # Input arrays @@ -120,9 +118,9 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.DoubleSphereCameraCal, sym.DoubleSphereCameraCal, float, float) -> sym.DoubleSphereCameraCal - + def interpolate( + a: sym.DoubleSphereCameraCal, b: sym.DoubleSphereCameraCal, alpha: float, epsilon: float + ) -> sym.DoubleSphereCameraCal: # Total ops: 18 # Input arrays diff --git a/gen/python/sym/ops/equirectangular_camera_cal/camera_ops.py b/gen/python/sym/ops/equirectangular_camera_cal/camera_ops.py index cb75ad16..437e0b13 100644 --- a/gen/python/sym/ops/equirectangular_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/equirectangular_camera_cal/camera_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,8 +22,7 @@ class CameraOps(object): """ @staticmethod - def focal_length(self): - # type: (sym.EquirectangularCameraCal) -> numpy.ndarray + def focal_length(self: sym.EquirectangularCameraCal) -> numpy.ndarray: """ Return the focal length. """ @@ -40,8 +41,7 @@ def focal_length(self): return _focal_length @staticmethod - def principal_point(self): - # type: (sym.EquirectangularCameraCal) -> numpy.ndarray + def principal_point(self: sym.EquirectangularCameraCal) -> numpy.ndarray: """ Return the principal point. """ @@ -60,8 +60,9 @@ def principal_point(self): return _principal_point @staticmethod - def pixel_from_camera_point(self, point, epsilon): - # type: (sym.EquirectangularCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: sym.EquirectangularCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -101,8 +102,9 @@ def pixel_from_camera_point(self, point, epsilon): return _pixel, _is_valid @staticmethod - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (sym.EquirectangularCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: sym.EquirectangularCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -163,8 +165,9 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): return _pixel, _is_valid, _pixel_D_cal, _pixel_D_point @staticmethod - def camera_ray_from_pixel(self, pixel, epsilon): - # type: (sym.EquirectangularCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def camera_ray_from_pixel( + self: sym.EquirectangularCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -210,8 +213,9 @@ def camera_ray_from_pixel(self, pixel, epsilon): return _camera_ray, _is_valid @staticmethod - def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): - # type: (sym.EquirectangularCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def camera_ray_from_pixel_with_jacobians( + self: sym.EquirectangularCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. diff --git a/gen/python/sym/ops/equirectangular_camera_cal/group_ops.py b/gen/python/sym/ops/equirectangular_camera_cal/group_ops.py index 078f140e..e1399f10 100644 --- a/gen/python/sym/ops/equirectangular_camera_cal/group_ops.py +++ b/gen/python/sym/ops/equirectangular_camera_cal/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.EquirectangularCameraCal - + def identity() -> sym.EquirectangularCameraCal: # Total ops: 0 # Input arrays @@ -38,9 +38,7 @@ def identity(): return sym.EquirectangularCameraCal.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.EquirectangularCameraCal) -> sym.EquirectangularCameraCal - + def inverse(a: sym.EquirectangularCameraCal) -> sym.EquirectangularCameraCal: # Total ops: 4 # Input arrays @@ -57,9 +55,9 @@ def inverse(a): return sym.EquirectangularCameraCal.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.EquirectangularCameraCal, sym.EquirectangularCameraCal) -> sym.EquirectangularCameraCal - + def compose( + a: sym.EquirectangularCameraCal, b: sym.EquirectangularCameraCal + ) -> sym.EquirectangularCameraCal: # Total ops: 4 # Input arrays @@ -77,9 +75,9 @@ def compose(a, b): return sym.EquirectangularCameraCal.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.EquirectangularCameraCal, sym.EquirectangularCameraCal) -> sym.EquirectangularCameraCal - + def between( + a: sym.EquirectangularCameraCal, b: sym.EquirectangularCameraCal + ) -> sym.EquirectangularCameraCal: # Total ops: 4 # Input arrays @@ -97,9 +95,9 @@ def between(a, b): return sym.EquirectangularCameraCal.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.EquirectangularCameraCal) -> T.Tuple[sym.EquirectangularCameraCal, numpy.ndarray] - + def inverse_with_jacobian( + a: sym.EquirectangularCameraCal, + ) -> T.Tuple[sym.EquirectangularCameraCal, numpy.ndarray]: # Total ops: 4 # Input arrays @@ -133,9 +131,9 @@ def inverse_with_jacobian(a): return sym.EquirectangularCameraCal.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.EquirectangularCameraCal, sym.EquirectangularCameraCal) -> T.Tuple[sym.EquirectangularCameraCal, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.EquirectangularCameraCal, b: sym.EquirectangularCameraCal + ) -> T.Tuple[sym.EquirectangularCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 4 # Input arrays @@ -187,9 +185,9 @@ def compose_with_jacobians(a, b): return sym.EquirectangularCameraCal.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.EquirectangularCameraCal, sym.EquirectangularCameraCal) -> T.Tuple[sym.EquirectangularCameraCal, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.EquirectangularCameraCal, b: sym.EquirectangularCameraCal + ) -> T.Tuple[sym.EquirectangularCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 4 # Input arrays diff --git a/gen/python/sym/ops/equirectangular_camera_cal/lie_group_ops.py b/gen/python/sym/ops/equirectangular_camera_cal/lie_group_ops.py index 4f84d36a..26da61f1 100644 --- a/gen/python/sym/ops/equirectangular_camera_cal/lie_group_ops.py +++ b/gen/python/sym/ops/equirectangular_camera_cal/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.EquirectangularCameraCal - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.EquirectangularCameraCal: # Total ops: 0 # Input arrays @@ -46,9 +46,7 @@ def from_tangent(vec, epsilon): return sym.EquirectangularCameraCal.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.EquirectangularCameraCal, float) -> numpy.ndarray - + def to_tangent(a: sym.EquirectangularCameraCal, epsilon: float) -> numpy.ndarray: # Total ops: 0 # Input arrays @@ -65,9 +63,9 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.EquirectangularCameraCal, numpy.ndarray, float) -> sym.EquirectangularCameraCal - + def retract( + a: sym.EquirectangularCameraCal, vec: numpy.ndarray, epsilon: float + ) -> sym.EquirectangularCameraCal: # Total ops: 4 # Input arrays @@ -92,9 +90,9 @@ def retract(a, vec, epsilon): return sym.EquirectangularCameraCal.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.EquirectangularCameraCal, sym.EquirectangularCameraCal, float) -> numpy.ndarray - + def local_coordinates( + a: sym.EquirectangularCameraCal, b: sym.EquirectangularCameraCal, epsilon: float + ) -> numpy.ndarray: # Total ops: 4 # Input arrays @@ -112,9 +110,12 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.EquirectangularCameraCal, sym.EquirectangularCameraCal, float, float) -> sym.EquirectangularCameraCal - + def interpolate( + a: sym.EquirectangularCameraCal, + b: sym.EquirectangularCameraCal, + alpha: float, + epsilon: float, + ) -> sym.EquirectangularCameraCal: # Total ops: 12 # Input arrays diff --git a/gen/python/sym/ops/linear_camera_cal/camera_ops.py b/gen/python/sym/ops/linear_camera_cal/camera_ops.py index d4d1f59c..aec76441 100644 --- a/gen/python/sym/ops/linear_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/linear_camera_cal/camera_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,8 +22,7 @@ class CameraOps(object): """ @staticmethod - def focal_length(self): - # type: (sym.LinearCameraCal) -> numpy.ndarray + def focal_length(self: sym.LinearCameraCal) -> numpy.ndarray: """ Return the focal length. """ @@ -40,8 +41,7 @@ def focal_length(self): return _focal_length @staticmethod - def principal_point(self): - # type: (sym.LinearCameraCal) -> numpy.ndarray + def principal_point(self: sym.LinearCameraCal) -> numpy.ndarray: """ Return the principal point. """ @@ -60,8 +60,9 @@ def principal_point(self): return _principal_point @staticmethod - def pixel_from_camera_point(self, point, epsilon): - # type: (sym.LinearCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: sym.LinearCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -94,8 +95,9 @@ def pixel_from_camera_point(self, point, epsilon): return _pixel, _is_valid @staticmethod - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (sym.LinearCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: sym.LinearCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -157,8 +159,9 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): return _pixel, _is_valid, _pixel_D_cal, _pixel_D_point @staticmethod - def camera_ray_from_pixel(self, pixel, epsilon): - # type: (sym.LinearCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def camera_ray_from_pixel( + self: sym.LinearCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. @@ -191,8 +194,9 @@ def camera_ray_from_pixel(self, pixel, epsilon): return _camera_ray, _is_valid @staticmethod - def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): - # type: (sym.LinearCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def camera_ray_from_pixel_with_jacobians( + self: sym.LinearCameraCal, pixel: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Backproject a 2D pixel coordinate into a 3D ray in the camera frame. diff --git a/gen/python/sym/ops/linear_camera_cal/group_ops.py b/gen/python/sym/ops/linear_camera_cal/group_ops.py index f6f7b885..11f4df72 100644 --- a/gen/python/sym/ops/linear_camera_cal/group_ops.py +++ b/gen/python/sym/ops/linear_camera_cal/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.LinearCameraCal - + def identity() -> sym.LinearCameraCal: # Total ops: 0 # Input arrays @@ -38,9 +38,7 @@ def identity(): return sym.LinearCameraCal.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.LinearCameraCal) -> sym.LinearCameraCal - + def inverse(a: sym.LinearCameraCal) -> sym.LinearCameraCal: # Total ops: 4 # Input arrays @@ -57,9 +55,7 @@ def inverse(a): return sym.LinearCameraCal.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.LinearCameraCal, sym.LinearCameraCal) -> sym.LinearCameraCal - + def compose(a: sym.LinearCameraCal, b: sym.LinearCameraCal) -> sym.LinearCameraCal: # Total ops: 4 # Input arrays @@ -77,9 +73,7 @@ def compose(a, b): return sym.LinearCameraCal.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.LinearCameraCal, sym.LinearCameraCal) -> sym.LinearCameraCal - + def between(a: sym.LinearCameraCal, b: sym.LinearCameraCal) -> sym.LinearCameraCal: # Total ops: 4 # Input arrays @@ -97,9 +91,9 @@ def between(a, b): return sym.LinearCameraCal.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.LinearCameraCal) -> T.Tuple[sym.LinearCameraCal, numpy.ndarray] - + def inverse_with_jacobian( + a: sym.LinearCameraCal, + ) -> T.Tuple[sym.LinearCameraCal, numpy.ndarray]: # Total ops: 4 # Input arrays @@ -133,9 +127,9 @@ def inverse_with_jacobian(a): return sym.LinearCameraCal.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.LinearCameraCal, sym.LinearCameraCal) -> T.Tuple[sym.LinearCameraCal, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.LinearCameraCal, b: sym.LinearCameraCal + ) -> T.Tuple[sym.LinearCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 4 # Input arrays @@ -187,9 +181,9 @@ def compose_with_jacobians(a, b): return sym.LinearCameraCal.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.LinearCameraCal, sym.LinearCameraCal) -> T.Tuple[sym.LinearCameraCal, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.LinearCameraCal, b: sym.LinearCameraCal + ) -> T.Tuple[sym.LinearCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 4 # Input arrays diff --git a/gen/python/sym/ops/linear_camera_cal/lie_group_ops.py b/gen/python/sym/ops/linear_camera_cal/lie_group_ops.py index ecccac3b..50196d7a 100644 --- a/gen/python/sym/ops/linear_camera_cal/lie_group_ops.py +++ b/gen/python/sym/ops/linear_camera_cal/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.LinearCameraCal - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.LinearCameraCal: # Total ops: 0 # Input arrays @@ -46,9 +46,7 @@ def from_tangent(vec, epsilon): return sym.LinearCameraCal.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.LinearCameraCal, float) -> numpy.ndarray - + def to_tangent(a: sym.LinearCameraCal, epsilon: float) -> numpy.ndarray: # Total ops: 0 # Input arrays @@ -65,9 +63,7 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.LinearCameraCal, numpy.ndarray, float) -> sym.LinearCameraCal - + def retract(a: sym.LinearCameraCal, vec: numpy.ndarray, epsilon: float) -> sym.LinearCameraCal: # Total ops: 4 # Input arrays @@ -92,9 +88,9 @@ def retract(a, vec, epsilon): return sym.LinearCameraCal.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.LinearCameraCal, sym.LinearCameraCal, float) -> numpy.ndarray - + def local_coordinates( + a: sym.LinearCameraCal, b: sym.LinearCameraCal, epsilon: float + ) -> numpy.ndarray: # Total ops: 4 # Input arrays @@ -112,9 +108,9 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.LinearCameraCal, sym.LinearCameraCal, float, float) -> sym.LinearCameraCal - + def interpolate( + a: sym.LinearCameraCal, b: sym.LinearCameraCal, alpha: float, epsilon: float + ) -> sym.LinearCameraCal: # Total ops: 12 # Input arrays diff --git a/gen/python/sym/ops/orthographic_camera_cal/camera_ops.py b/gen/python/sym/ops/orthographic_camera_cal/camera_ops.py index 31f30878..4355a5f6 100644 --- a/gen/python/sym/ops/orthographic_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/orthographic_camera_cal/camera_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,8 +22,7 @@ class CameraOps(object): """ @staticmethod - def focal_length(self): - # type: (sym.OrthographicCameraCal) -> numpy.ndarray + def focal_length(self: sym.OrthographicCameraCal) -> numpy.ndarray: """ Return the focal length. """ @@ -40,8 +41,7 @@ def focal_length(self): return _focal_length @staticmethod - def principal_point(self): - # type: (sym.OrthographicCameraCal) -> numpy.ndarray + def principal_point(self: sym.OrthographicCameraCal) -> numpy.ndarray: """ Return the principal point. """ @@ -60,8 +60,9 @@ def principal_point(self): return _principal_point @staticmethod - def pixel_from_camera_point(self, point, epsilon): - # type: (sym.OrthographicCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: sym.OrthographicCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -93,8 +94,9 @@ def pixel_from_camera_point(self, point, epsilon): return _pixel, _is_valid @staticmethod - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (sym.OrthographicCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: sym.OrthographicCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. diff --git a/gen/python/sym/ops/orthographic_camera_cal/group_ops.py b/gen/python/sym/ops/orthographic_camera_cal/group_ops.py index 1940ece1..386c703e 100644 --- a/gen/python/sym/ops/orthographic_camera_cal/group_ops.py +++ b/gen/python/sym/ops/orthographic_camera_cal/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.OrthographicCameraCal - + def identity() -> sym.OrthographicCameraCal: # Total ops: 0 # Input arrays @@ -38,9 +38,7 @@ def identity(): return sym.OrthographicCameraCal.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.OrthographicCameraCal) -> sym.OrthographicCameraCal - + def inverse(a: sym.OrthographicCameraCal) -> sym.OrthographicCameraCal: # Total ops: 4 # Input arrays @@ -57,9 +55,9 @@ def inverse(a): return sym.OrthographicCameraCal.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.OrthographicCameraCal, sym.OrthographicCameraCal) -> sym.OrthographicCameraCal - + def compose( + a: sym.OrthographicCameraCal, b: sym.OrthographicCameraCal + ) -> sym.OrthographicCameraCal: # Total ops: 4 # Input arrays @@ -77,9 +75,9 @@ def compose(a, b): return sym.OrthographicCameraCal.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.OrthographicCameraCal, sym.OrthographicCameraCal) -> sym.OrthographicCameraCal - + def between( + a: sym.OrthographicCameraCal, b: sym.OrthographicCameraCal + ) -> sym.OrthographicCameraCal: # Total ops: 4 # Input arrays @@ -97,9 +95,9 @@ def between(a, b): return sym.OrthographicCameraCal.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.OrthographicCameraCal) -> T.Tuple[sym.OrthographicCameraCal, numpy.ndarray] - + def inverse_with_jacobian( + a: sym.OrthographicCameraCal, + ) -> T.Tuple[sym.OrthographicCameraCal, numpy.ndarray]: # Total ops: 4 # Input arrays @@ -133,9 +131,9 @@ def inverse_with_jacobian(a): return sym.OrthographicCameraCal.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.OrthographicCameraCal, sym.OrthographicCameraCal) -> T.Tuple[sym.OrthographicCameraCal, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.OrthographicCameraCal, b: sym.OrthographicCameraCal + ) -> T.Tuple[sym.OrthographicCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 4 # Input arrays @@ -187,9 +185,9 @@ def compose_with_jacobians(a, b): return sym.OrthographicCameraCal.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.OrthographicCameraCal, sym.OrthographicCameraCal) -> T.Tuple[sym.OrthographicCameraCal, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.OrthographicCameraCal, b: sym.OrthographicCameraCal + ) -> T.Tuple[sym.OrthographicCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 4 # Input arrays diff --git a/gen/python/sym/ops/orthographic_camera_cal/lie_group_ops.py b/gen/python/sym/ops/orthographic_camera_cal/lie_group_ops.py index ade6075d..76f548d6 100644 --- a/gen/python/sym/ops/orthographic_camera_cal/lie_group_ops.py +++ b/gen/python/sym/ops/orthographic_camera_cal/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.OrthographicCameraCal - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.OrthographicCameraCal: # Total ops: 0 # Input arrays @@ -46,9 +46,7 @@ def from_tangent(vec, epsilon): return sym.OrthographicCameraCal.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.OrthographicCameraCal, float) -> numpy.ndarray - + def to_tangent(a: sym.OrthographicCameraCal, epsilon: float) -> numpy.ndarray: # Total ops: 0 # Input arrays @@ -65,9 +63,9 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.OrthographicCameraCal, numpy.ndarray, float) -> sym.OrthographicCameraCal - + def retract( + a: sym.OrthographicCameraCal, vec: numpy.ndarray, epsilon: float + ) -> sym.OrthographicCameraCal: # Total ops: 4 # Input arrays @@ -92,9 +90,9 @@ def retract(a, vec, epsilon): return sym.OrthographicCameraCal.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.OrthographicCameraCal, sym.OrthographicCameraCal, float) -> numpy.ndarray - + def local_coordinates( + a: sym.OrthographicCameraCal, b: sym.OrthographicCameraCal, epsilon: float + ) -> numpy.ndarray: # Total ops: 4 # Input arrays @@ -112,9 +110,9 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.OrthographicCameraCal, sym.OrthographicCameraCal, float, float) -> sym.OrthographicCameraCal - + def interpolate( + a: sym.OrthographicCameraCal, b: sym.OrthographicCameraCal, alpha: float, epsilon: float + ) -> sym.OrthographicCameraCal: # Total ops: 12 # Input arrays diff --git a/gen/python/sym/ops/polynomial_camera_cal/camera_ops.py b/gen/python/sym/ops/polynomial_camera_cal/camera_ops.py index 9cf9feb1..6f84ff05 100644 --- a/gen/python/sym/ops/polynomial_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/polynomial_camera_cal/camera_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,8 +22,7 @@ class CameraOps(object): """ @staticmethod - def focal_length(self): - # type: (sym.PolynomialCameraCal) -> numpy.ndarray + def focal_length(self: sym.PolynomialCameraCal) -> numpy.ndarray: """ Return the focal length. """ @@ -40,8 +41,7 @@ def focal_length(self): return _focal_length @staticmethod - def principal_point(self): - # type: (sym.PolynomialCameraCal) -> numpy.ndarray + def principal_point(self: sym.PolynomialCameraCal) -> numpy.ndarray: """ Return the principal point. """ @@ -60,8 +60,9 @@ def principal_point(self): return _principal_point @staticmethod - def pixel_from_camera_point(self, point, epsilon): - # type: (sym.PolynomialCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: sym.PolynomialCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -109,8 +110,9 @@ def pixel_from_camera_point(self, point, epsilon): return _pixel, _is_valid @staticmethod - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (sym.PolynomialCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: sym.PolynomialCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. diff --git a/gen/python/sym/ops/polynomial_camera_cal/group_ops.py b/gen/python/sym/ops/polynomial_camera_cal/group_ops.py index 9bb3c4f9..321541fc 100644 --- a/gen/python/sym/ops/polynomial_camera_cal/group_ops.py +++ b/gen/python/sym/ops/polynomial_camera_cal/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.PolynomialCameraCal - + def identity() -> sym.PolynomialCameraCal: # Total ops: 0 # Input arrays @@ -42,9 +42,7 @@ def identity(): return sym.PolynomialCameraCal.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.PolynomialCameraCal) -> sym.PolynomialCameraCal - + def inverse(a: sym.PolynomialCameraCal) -> sym.PolynomialCameraCal: # Total ops: 8 # Input arrays @@ -65,9 +63,7 @@ def inverse(a): return sym.PolynomialCameraCal.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.PolynomialCameraCal, sym.PolynomialCameraCal) -> sym.PolynomialCameraCal - + def compose(a: sym.PolynomialCameraCal, b: sym.PolynomialCameraCal) -> sym.PolynomialCameraCal: # Total ops: 8 # Input arrays @@ -89,9 +85,7 @@ def compose(a, b): return sym.PolynomialCameraCal.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.PolynomialCameraCal, sym.PolynomialCameraCal) -> sym.PolynomialCameraCal - + def between(a: sym.PolynomialCameraCal, b: sym.PolynomialCameraCal) -> sym.PolynomialCameraCal: # Total ops: 8 # Input arrays @@ -113,9 +107,9 @@ def between(a, b): return sym.PolynomialCameraCal.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.PolynomialCameraCal) -> T.Tuple[sym.PolynomialCameraCal, numpy.ndarray] - + def inverse_with_jacobian( + a: sym.PolynomialCameraCal, + ) -> T.Tuple[sym.PolynomialCameraCal, numpy.ndarray]: # Total ops: 8 # Input arrays @@ -201,9 +195,9 @@ def inverse_with_jacobian(a): return sym.PolynomialCameraCal.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.PolynomialCameraCal, sym.PolynomialCameraCal) -> T.Tuple[sym.PolynomialCameraCal, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.PolynomialCameraCal, b: sym.PolynomialCameraCal + ) -> T.Tuple[sym.PolynomialCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 8 # Input arrays @@ -355,9 +349,9 @@ def compose_with_jacobians(a, b): return sym.PolynomialCameraCal.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.PolynomialCameraCal, sym.PolynomialCameraCal) -> T.Tuple[sym.PolynomialCameraCal, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.PolynomialCameraCal, b: sym.PolynomialCameraCal + ) -> T.Tuple[sym.PolynomialCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 8 # Input arrays diff --git a/gen/python/sym/ops/polynomial_camera_cal/lie_group_ops.py b/gen/python/sym/ops/polynomial_camera_cal/lie_group_ops.py index 64d60f67..382a2c59 100644 --- a/gen/python/sym/ops/polynomial_camera_cal/lie_group_ops.py +++ b/gen/python/sym/ops/polynomial_camera_cal/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.PolynomialCameraCal - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.PolynomialCameraCal: # Total ops: 0 # Input arrays @@ -50,9 +50,7 @@ def from_tangent(vec, epsilon): return sym.PolynomialCameraCal.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.PolynomialCameraCal, float) -> numpy.ndarray - + def to_tangent(a: sym.PolynomialCameraCal, epsilon: float) -> numpy.ndarray: # Total ops: 0 # Input arrays @@ -73,9 +71,9 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.PolynomialCameraCal, numpy.ndarray, float) -> sym.PolynomialCameraCal - + def retract( + a: sym.PolynomialCameraCal, vec: numpy.ndarray, epsilon: float + ) -> sym.PolynomialCameraCal: # Total ops: 8 # Input arrays @@ -104,9 +102,9 @@ def retract(a, vec, epsilon): return sym.PolynomialCameraCal.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.PolynomialCameraCal, sym.PolynomialCameraCal, float) -> numpy.ndarray - + def local_coordinates( + a: sym.PolynomialCameraCal, b: sym.PolynomialCameraCal, epsilon: float + ) -> numpy.ndarray: # Total ops: 8 # Input arrays @@ -128,9 +126,9 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.PolynomialCameraCal, sym.PolynomialCameraCal, float, float) -> sym.PolynomialCameraCal - + def interpolate( + a: sym.PolynomialCameraCal, b: sym.PolynomialCameraCal, alpha: float, epsilon: float + ) -> sym.PolynomialCameraCal: # Total ops: 24 # Input arrays diff --git a/gen/python/sym/ops/pose2/group_ops.py b/gen/python/sym/ops/pose2/group_ops.py index ed118b5b..adbe555f 100644 --- a/gen/python/sym/ops/pose2/group_ops.py +++ b/gen/python/sym/ops/pose2/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.Pose2 - + def identity() -> sym.Pose2: # Total ops: 0 # Input arrays @@ -38,9 +38,7 @@ def identity(): return sym.Pose2.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.Pose2) -> sym.Pose2 - + def inverse(a: sym.Pose2) -> sym.Pose2: # Total ops: 8 # Input arrays @@ -57,9 +55,7 @@ def inverse(a): return sym.Pose2.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.Pose2, sym.Pose2) -> sym.Pose2 - + def compose(a: sym.Pose2, b: sym.Pose2) -> sym.Pose2: # Total ops: 14 # Input arrays @@ -77,9 +73,7 @@ def compose(a, b): return sym.Pose2.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.Pose2, sym.Pose2) -> sym.Pose2 - + def between(a: sym.Pose2, b: sym.Pose2) -> sym.Pose2: # Total ops: 20 # Input arrays @@ -97,9 +91,7 @@ def between(a, b): return sym.Pose2.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.Pose2) -> T.Tuple[sym.Pose2, numpy.ndarray] - + def inverse_with_jacobian(a: sym.Pose2) -> T.Tuple[sym.Pose2, numpy.ndarray]: # Total ops: 14 # Input arrays @@ -131,9 +123,9 @@ def inverse_with_jacobian(a): return sym.Pose2.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.Pose2, sym.Pose2) -> T.Tuple[sym.Pose2, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.Pose2, b: sym.Pose2 + ) -> T.Tuple[sym.Pose2, numpy.ndarray, numpy.ndarray]: # Total ops: 22 # Input arrays @@ -179,9 +171,9 @@ def compose_with_jacobians(a, b): return sym.Pose2.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.Pose2, sym.Pose2) -> T.Tuple[sym.Pose2, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.Pose2, b: sym.Pose2 + ) -> T.Tuple[sym.Pose2, numpy.ndarray, numpy.ndarray]: # Total ops: 35 # Input arrays diff --git a/gen/python/sym/ops/pose2/lie_group_ops.py b/gen/python/sym/ops/pose2/lie_group_ops.py index 21ef9dac..5d708268 100644 --- a/gen/python/sym/ops/pose2/lie_group_ops.py +++ b/gen/python/sym/ops/pose2/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.Pose2 - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.Pose2: # Total ops: 2 # Input arrays @@ -46,9 +46,7 @@ def from_tangent(vec, epsilon): return sym.Pose2.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.Pose2, float) -> numpy.ndarray - + def to_tangent(a: sym.Pose2, epsilon: float) -> numpy.ndarray: # Total ops: 3 # Input arrays @@ -64,9 +62,7 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.Pose2, numpy.ndarray, float) -> sym.Pose2 - + def retract(a: sym.Pose2, vec: numpy.ndarray, epsilon: float) -> sym.Pose2: # Total ops: 10 # Input arrays @@ -93,9 +89,7 @@ def retract(a, vec, epsilon): return sym.Pose2.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.Pose2, sym.Pose2, float) -> numpy.ndarray - + def local_coordinates(a: sym.Pose2, b: sym.Pose2, epsilon: float) -> numpy.ndarray: # Total ops: 11 # Input arrays @@ -113,9 +107,7 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.Pose2, sym.Pose2, float, float) -> sym.Pose2 - + def interpolate(a: sym.Pose2, b: sym.Pose2, alpha: float, epsilon: float) -> sym.Pose2: # Total ops: 24 # Input arrays diff --git a/gen/python/sym/ops/pose3/group_ops.py b/gen/python/sym/ops/pose3/group_ops.py index 266e4378..a39048d6 100644 --- a/gen/python/sym/ops/pose3/group_ops.py +++ b/gen/python/sym/ops/pose3/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.Pose3 - + def identity() -> sym.Pose3: # Total ops: 0 # Input arrays @@ -41,9 +41,7 @@ def identity(): return sym.Pose3.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.Pose3) -> sym.Pose3 - + def inverse(a: sym.Pose3) -> sym.Pose3: # Total ops: 49 # Input arrays @@ -74,9 +72,7 @@ def inverse(a): return sym.Pose3.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.Pose3, sym.Pose3) -> sym.Pose3 - + def compose(a: sym.Pose3, b: sym.Pose3) -> sym.Pose3: # Total ops: 74 # Input arrays @@ -114,9 +110,7 @@ def compose(a, b): return sym.Pose3.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.Pose3, sym.Pose3) -> sym.Pose3 - + def between(a: sym.Pose3, b: sym.Pose3) -> sym.Pose3: # Total ops: 89 # Input arrays @@ -178,9 +172,7 @@ def between(a, b): return sym.Pose3.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.Pose3) -> T.Tuple[sym.Pose3, numpy.ndarray] - + def inverse_with_jacobian(a: sym.Pose3) -> T.Tuple[sym.Pose3, numpy.ndarray]: # Total ops: 115 # Input arrays @@ -285,9 +277,9 @@ def inverse_with_jacobian(a): return sym.Pose3.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.Pose3, sym.Pose3) -> T.Tuple[sym.Pose3, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.Pose3, b: sym.Pose3 + ) -> T.Tuple[sym.Pose3, numpy.ndarray, numpy.ndarray]: # Total ops: 330 # Input arrays @@ -516,9 +508,9 @@ def compose_with_jacobians(a, b): return sym.Pose3.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.Pose3, sym.Pose3) -> T.Tuple[sym.Pose3, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.Pose3, b: sym.Pose3 + ) -> T.Tuple[sym.Pose3, numpy.ndarray, numpy.ndarray]: # Total ops: 306 # Input arrays diff --git a/gen/python/sym/ops/pose3/lie_group_ops.py b/gen/python/sym/ops/pose3/lie_group_ops.py index eb41a62b..e360f4b0 100644 --- a/gen/python/sym/ops/pose3/lie_group_ops.py +++ b/gen/python/sym/ops/pose3/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.Pose3 - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.Pose3: # Total ops: 15 # Input arrays @@ -52,9 +52,7 @@ def from_tangent(vec, epsilon): return sym.Pose3.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.Pose3, float) -> numpy.ndarray - + def to_tangent(a: sym.Pose3, epsilon: float) -> numpy.ndarray: # Total ops: 14 # Input arrays @@ -75,9 +73,7 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.Pose3, numpy.ndarray, float) -> sym.Pose3 - + def retract(a: sym.Pose3, vec: numpy.ndarray, epsilon: float) -> sym.Pose3: # Total ops: 48 # Input arrays @@ -114,9 +110,7 @@ def retract(a, vec, epsilon): return sym.Pose3.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.Pose3, sym.Pose3, float) -> numpy.ndarray - + def local_coordinates(a: sym.Pose3, b: sym.Pose3, epsilon: float) -> numpy.ndarray: # Total ops: 47 # Input arrays @@ -140,9 +134,7 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.Pose3, sym.Pose3, float, float) -> sym.Pose3 - + def interpolate(a: sym.Pose3, b: sym.Pose3, alpha: float, epsilon: float) -> sym.Pose3: # Total ops: 106 # Input arrays diff --git a/gen/python/sym/ops/rot2/group_ops.py b/gen/python/sym/ops/rot2/group_ops.py index 646a7741..4c0d9310 100644 --- a/gen/python/sym/ops/rot2/group_ops.py +++ b/gen/python/sym/ops/rot2/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.Rot2 - + def identity() -> sym.Rot2: # Total ops: 0 # Input arrays @@ -36,9 +36,7 @@ def identity(): return sym.Rot2.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.Rot2) -> sym.Rot2 - + def inverse(a: sym.Rot2) -> sym.Rot2: # Total ops: 1 # Input arrays @@ -53,9 +51,7 @@ def inverse(a): return sym.Rot2.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.Rot2, sym.Rot2) -> sym.Rot2 - + def compose(a: sym.Rot2, b: sym.Rot2) -> sym.Rot2: # Total ops: 6 # Input arrays @@ -71,9 +67,7 @@ def compose(a, b): return sym.Rot2.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.Rot2, sym.Rot2) -> sym.Rot2 - + def between(a: sym.Rot2, b: sym.Rot2) -> sym.Rot2: # Total ops: 6 # Input arrays @@ -89,9 +83,7 @@ def between(a, b): return sym.Rot2.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.Rot2) -> T.Tuple[sym.Rot2, numpy.ndarray] - + def inverse_with_jacobian(a: sym.Rot2) -> T.Tuple[sym.Rot2, numpy.ndarray]: # Total ops: 5 # Input arrays @@ -108,9 +100,9 @@ def inverse_with_jacobian(a): return sym.Rot2.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.Rot2, sym.Rot2) -> T.Tuple[sym.Rot2, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.Rot2, b: sym.Rot2 + ) -> T.Tuple[sym.Rot2, numpy.ndarray, numpy.ndarray]: # Total ops: 11 # Input arrays @@ -135,9 +127,9 @@ def compose_with_jacobians(a, b): return sym.Rot2.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.Rot2, sym.Rot2) -> T.Tuple[sym.Rot2, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.Rot2, b: sym.Rot2 + ) -> T.Tuple[sym.Rot2, numpy.ndarray, numpy.ndarray]: # Total ops: 15 # Input arrays diff --git a/gen/python/sym/ops/rot2/lie_group_ops.py b/gen/python/sym/ops/rot2/lie_group_ops.py index b29b368d..cc8c4637 100644 --- a/gen/python/sym/ops/rot2/lie_group_ops.py +++ b/gen/python/sym/ops/rot2/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.Rot2 - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.Rot2: # Total ops: 2 # Input arrays @@ -44,9 +44,7 @@ def from_tangent(vec, epsilon): return sym.Rot2.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.Rot2, float) -> numpy.ndarray - + def to_tangent(a: sym.Rot2, epsilon: float) -> numpy.ndarray: # Total ops: 3 # Input arrays @@ -60,9 +58,7 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.Rot2, numpy.ndarray, float) -> sym.Rot2 - + def retract(a: sym.Rot2, vec: numpy.ndarray, epsilon: float) -> sym.Rot2: # Total ops: 8 # Input arrays @@ -87,9 +83,7 @@ def retract(a, vec, epsilon): return sym.Rot2.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.Rot2, sym.Rot2, float) -> numpy.ndarray - + def local_coordinates(a: sym.Rot2, b: sym.Rot2, epsilon: float) -> numpy.ndarray: # Total ops: 9 # Input arrays @@ -105,9 +99,7 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.Rot2, sym.Rot2, float, float) -> sym.Rot2 - + def interpolate(a: sym.Rot2, b: sym.Rot2, alpha: float, epsilon: float) -> sym.Rot2: # Total ops: 18 # Input arrays diff --git a/gen/python/sym/ops/rot3/group_ops.py b/gen/python/sym/ops/rot3/group_ops.py index 7cce2241..f6f43c20 100644 --- a/gen/python/sym/ops/rot3/group_ops.py +++ b/gen/python/sym/ops/rot3/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.Rot3 - + def identity() -> sym.Rot3: # Total ops: 0 # Input arrays @@ -38,9 +38,7 @@ def identity(): return sym.Rot3.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.Rot3) -> sym.Rot3 - + def inverse(a: sym.Rot3) -> sym.Rot3: # Total ops: 3 # Input arrays @@ -57,9 +55,7 @@ def inverse(a): return sym.Rot3.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.Rot3, sym.Rot3) -> sym.Rot3 - + def compose(a: sym.Rot3, b: sym.Rot3) -> sym.Rot3: # Total ops: 28 # Input arrays @@ -77,9 +73,7 @@ def compose(a, b): return sym.Rot3.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.Rot3, sym.Rot3) -> sym.Rot3 - + def between(a: sym.Rot3, b: sym.Rot3) -> sym.Rot3: # Total ops: 28 # Input arrays @@ -97,9 +91,7 @@ def between(a, b): return sym.Rot3.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.Rot3) -> T.Tuple[sym.Rot3, numpy.ndarray] - + def inverse_with_jacobian(a: sym.Rot3) -> T.Tuple[sym.Rot3, numpy.ndarray]: # Total ops: 34 # Input arrays @@ -139,9 +131,9 @@ def inverse_with_jacobian(a): return sym.Rot3.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.Rot3, sym.Rot3) -> T.Tuple[sym.Rot3, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.Rot3, b: sym.Rot3 + ) -> T.Tuple[sym.Rot3, numpy.ndarray, numpy.ndarray]: # Total ops: 224 # Input arrays @@ -273,9 +265,9 @@ def compose_with_jacobians(a, b): return sym.Rot3.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.Rot3, sym.Rot3) -> T.Tuple[sym.Rot3, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.Rot3, b: sym.Rot3 + ) -> T.Tuple[sym.Rot3, numpy.ndarray, numpy.ndarray]: # Total ops: 161 # Input arrays diff --git a/gen/python/sym/ops/rot3/lie_group_ops.py b/gen/python/sym/ops/rot3/lie_group_ops.py index a080e17a..39a95086 100644 --- a/gen/python/sym/ops/rot3/lie_group_ops.py +++ b/gen/python/sym/ops/rot3/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.Rot3 - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.Rot3: # Total ops: 15 # Input arrays @@ -49,9 +49,7 @@ def from_tangent(vec, epsilon): return sym.Rot3.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.Rot3, float) -> numpy.ndarray - + def to_tangent(a: sym.Rot3, epsilon: float) -> numpy.ndarray: # Total ops: 14 # Input arrays @@ -69,9 +67,7 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.Rot3, numpy.ndarray, float) -> sym.Rot3 - + def retract(a: sym.Rot3, vec: numpy.ndarray, epsilon: float) -> sym.Rot3: # Total ops: 45 # Input arrays @@ -105,9 +101,7 @@ def retract(a, vec, epsilon): return sym.Rot3.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.Rot3, sym.Rot3, float) -> numpy.ndarray - + def local_coordinates(a: sym.Rot3, b: sym.Rot3, epsilon: float) -> numpy.ndarray: # Total ops: 42 # Input arrays @@ -127,9 +121,7 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.Rot3, sym.Rot3, float, float) -> sym.Rot3 - + def interpolate(a: sym.Rot3, b: sym.Rot3, alpha: float, epsilon: float) -> sym.Rot3: # Total ops: 94 # Input arrays diff --git a/gen/python/sym/ops/spherical_camera_cal/camera_ops.py b/gen/python/sym/ops/spherical_camera_cal/camera_ops.py index 8bbba16a..f35c2437 100644 --- a/gen/python/sym/ops/spherical_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/spherical_camera_cal/camera_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,8 +22,7 @@ class CameraOps(object): """ @staticmethod - def focal_length(self): - # type: (sym.SphericalCameraCal) -> numpy.ndarray + def focal_length(self: sym.SphericalCameraCal) -> numpy.ndarray: """ Return the focal length. """ @@ -40,8 +41,7 @@ def focal_length(self): return _focal_length @staticmethod - def principal_point(self): - # type: (sym.SphericalCameraCal) -> numpy.ndarray + def principal_point(self: sym.SphericalCameraCal) -> numpy.ndarray: """ Return the principal point. """ @@ -60,8 +60,9 @@ def principal_point(self): return _principal_point @staticmethod - def pixel_from_camera_point(self, point, epsilon): - # type: (sym.SphericalCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: sym.SphericalCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -117,8 +118,9 @@ def pixel_from_camera_point(self, point, epsilon): return _pixel, _is_valid @staticmethod - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (sym.SphericalCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: sym.SphericalCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. diff --git a/gen/python/sym/ops/spherical_camera_cal/group_ops.py b/gen/python/sym/ops/spherical_camera_cal/group_ops.py index a94ed48e..3d949094 100644 --- a/gen/python/sym/ops/spherical_camera_cal/group_ops.py +++ b/gen/python/sym/ops/spherical_camera_cal/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class GroupOps(object): """ @staticmethod - def identity(): - # type: () -> sym.SphericalCameraCal - + def identity() -> sym.SphericalCameraCal: # Total ops: 0 # Input arrays @@ -45,9 +45,7 @@ def identity(): return sym.SphericalCameraCal.from_storage(_res) @staticmethod - def inverse(a): - # type: (sym.SphericalCameraCal) -> sym.SphericalCameraCal - + def inverse(a: sym.SphericalCameraCal) -> sym.SphericalCameraCal: # Total ops: 11 # Input arrays @@ -71,9 +69,7 @@ def inverse(a): return sym.SphericalCameraCal.from_storage(_res) @staticmethod - def compose(a, b): - # type: (sym.SphericalCameraCal, sym.SphericalCameraCal) -> sym.SphericalCameraCal - + def compose(a: sym.SphericalCameraCal, b: sym.SphericalCameraCal) -> sym.SphericalCameraCal: # Total ops: 11 # Input arrays @@ -98,9 +94,7 @@ def compose(a, b): return sym.SphericalCameraCal.from_storage(_res) @staticmethod - def between(a, b): - # type: (sym.SphericalCameraCal, sym.SphericalCameraCal) -> sym.SphericalCameraCal - + def between(a: sym.SphericalCameraCal, b: sym.SphericalCameraCal) -> sym.SphericalCameraCal: # Total ops: 11 # Input arrays @@ -125,9 +119,9 @@ def between(a, b): return sym.SphericalCameraCal.from_storage(_res) @staticmethod - def inverse_with_jacobian(a): - # type: (sym.SphericalCameraCal) -> T.Tuple[sym.SphericalCameraCal, numpy.ndarray] - + def inverse_with_jacobian( + a: sym.SphericalCameraCal, + ) -> T.Tuple[sym.SphericalCameraCal, numpy.ndarray]: # Total ops: 11 # Input arrays @@ -273,9 +267,9 @@ def inverse_with_jacobian(a): return sym.SphericalCameraCal.from_storage(_res), _res_D_a @staticmethod - def compose_with_jacobians(a, b): - # type: (sym.SphericalCameraCal, sym.SphericalCameraCal) -> T.Tuple[sym.SphericalCameraCal, numpy.ndarray, numpy.ndarray] - + def compose_with_jacobians( + a: sym.SphericalCameraCal, b: sym.SphericalCameraCal + ) -> T.Tuple[sym.SphericalCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 11 # Input arrays @@ -544,9 +538,9 @@ def compose_with_jacobians(a, b): return sym.SphericalCameraCal.from_storage(_res), _res_D_a, _res_D_b @staticmethod - def between_with_jacobians(a, b): - # type: (sym.SphericalCameraCal, sym.SphericalCameraCal) -> T.Tuple[sym.SphericalCameraCal, numpy.ndarray, numpy.ndarray] - + def between_with_jacobians( + a: sym.SphericalCameraCal, b: sym.SphericalCameraCal + ) -> T.Tuple[sym.SphericalCameraCal, numpy.ndarray, numpy.ndarray]: # Total ops: 11 # Input arrays diff --git a/gen/python/sym/ops/spherical_camera_cal/lie_group_ops.py b/gen/python/sym/ops/spherical_camera_cal/lie_group_ops.py index dad90a54..7c69d83e 100644 --- a/gen/python/sym/ops/spherical_camera_cal/lie_group_ops.py +++ b/gen/python/sym/ops/spherical_camera_cal/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def from_tangent(vec, epsilon): - # type: (numpy.ndarray, float) -> sym.SphericalCameraCal - + def from_tangent(vec: numpy.ndarray, epsilon: float) -> sym.SphericalCameraCal: # Total ops: 0 # Input arrays @@ -53,9 +53,7 @@ def from_tangent(vec, epsilon): return sym.SphericalCameraCal.from_storage(_res) @staticmethod - def to_tangent(a, epsilon): - # type: (sym.SphericalCameraCal, float) -> numpy.ndarray - + def to_tangent(a: sym.SphericalCameraCal, epsilon: float) -> numpy.ndarray: # Total ops: 0 # Input arrays @@ -79,9 +77,9 @@ def to_tangent(a, epsilon): return _res @staticmethod - def retract(a, vec, epsilon): - # type: (sym.SphericalCameraCal, numpy.ndarray, float) -> sym.SphericalCameraCal - + def retract( + a: sym.SphericalCameraCal, vec: numpy.ndarray, epsilon: float + ) -> sym.SphericalCameraCal: # Total ops: 11 # Input arrays @@ -113,9 +111,9 @@ def retract(a, vec, epsilon): return sym.SphericalCameraCal.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.SphericalCameraCal, sym.SphericalCameraCal, float) -> numpy.ndarray - + def local_coordinates( + a: sym.SphericalCameraCal, b: sym.SphericalCameraCal, epsilon: float + ) -> numpy.ndarray: # Total ops: 11 # Input arrays @@ -140,9 +138,9 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.SphericalCameraCal, sym.SphericalCameraCal, float, float) -> sym.SphericalCameraCal - + def interpolate( + a: sym.SphericalCameraCal, b: sym.SphericalCameraCal, alpha: float, epsilon: float + ) -> sym.SphericalCameraCal: # Total ops: 33 # Input arrays diff --git a/gen/python/sym/ops/unit3/group_ops.py b/gen/python/sym/ops/unit3/group_ops.py index 74928cc4..ca372216 100644 --- a/gen/python/sym/ops/unit3/group_ops.py +++ b/gen/python/sym/ops/unit3/group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T diff --git a/gen/python/sym/ops/unit3/lie_group_ops.py b/gen/python/sym/ops/unit3/lie_group_ops.py index da2f4014..a84cc7a1 100644 --- a/gen/python/sym/ops/unit3/lie_group_ops.py +++ b/gen/python/sym/ops/unit3/lie_group_ops.py @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -20,9 +22,7 @@ class LieGroupOps(object): """ @staticmethod - def retract(a, vec, epsilon): - # type: (sym.Unit3, numpy.ndarray, float) -> sym.Unit3 - + def retract(a: sym.Unit3, vec: numpy.ndarray, epsilon: float) -> sym.Unit3: # Total ops: 84 # Input arrays @@ -90,9 +90,7 @@ def retract(a, vec, epsilon): return sym.Unit3.from_storage(_res) @staticmethod - def local_coordinates(a, b, epsilon): - # type: (sym.Unit3, sym.Unit3, float) -> numpy.ndarray - + def local_coordinates(a: sym.Unit3, b: sym.Unit3, epsilon: float) -> numpy.ndarray: # Total ops: 77 # Input arrays @@ -148,9 +146,7 @@ def local_coordinates(a, b, epsilon): return _res @staticmethod - def interpolate(a, b, alpha, epsilon): - # type: (sym.Unit3, sym.Unit3, float, float) -> sym.Unit3 - + def interpolate(a: sym.Unit3, b: sym.Unit3, alpha: float, epsilon: float) -> sym.Unit3: # Total ops: 115 # Input arrays diff --git a/gen/python/sym/orthographic_camera_cal.py b/gen/python/sym/orthographic_camera_cal.py index da33b4b6..bd4942af 100644 --- a/gen/python/sym/orthographic_camera_cal.py +++ b/gen/python/sym/orthographic_camera_cal.py @@ -4,6 +4,8 @@ # Do NOT modify by hand. # ----------------------------------------------------------------------------- +from __future__ import annotations + import typing as T import numpy @@ -33,11 +35,14 @@ class OrthographicCameraCal(object): # This is because of an issue where mypy doesn't recognize attributes defined in __slots__ # See https://github.com/python/mypy/issues/5941 if T.TYPE_CHECKING: - data = [] # type: T.List[float] - - def __init__(self, focal_length, principal_point): - # type: (T.Union[T.Sequence[float], numpy.ndarray], T.Union[T.Sequence[float], numpy.ndarray]) -> None - self.data = [] + data: T.List[float] = [] + + def __init__( + self, + focal_length: T.Union[T.Sequence[float], numpy.ndarray], + principal_point: T.Union[T.Sequence[float], numpy.ndarray], + ) -> None: + self.data: T.List[float] = [] if isinstance(focal_length, numpy.ndarray): if focal_length.shape in {(2, 1), (1, 2)}: focal_length = focal_length.flatten() @@ -72,32 +77,30 @@ def __init__(self, focal_length, principal_point): self.data.extend(focal_length) self.data.extend(principal_point) - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # CameraOps # -------------------------------------------------------------------------- - def focal_length(self): - # type: (OrthographicCameraCal) -> numpy.ndarray + def focal_length(self: OrthographicCameraCal) -> numpy.ndarray: """ Return the focal length. """ return ops.CameraOps.focal_length(self) - def principal_point(self): - # type: (OrthographicCameraCal) -> numpy.ndarray + def principal_point(self: OrthographicCameraCal) -> numpy.ndarray: """ Return the principal point. """ return ops.CameraOps.principal_point(self) - def pixel_from_camera_point(self, point, epsilon): - # type: (OrthographicCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: OrthographicCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -108,8 +111,9 @@ def pixel_from_camera_point(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point(self, point, epsilon) - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (OrthographicCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: OrthographicCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -127,17 +131,14 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 4 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> OrthographicCameraCal + def from_storage(cls, vec: T.Sequence[float]) -> OrthographicCameraCal: instance = cls.__new__(cls) if isinstance(vec, list): @@ -157,13 +158,11 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 4 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> OrthographicCameraCal + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> OrthographicCameraCal: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -172,12 +171,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> OrthographicCameraCal + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> OrthographicCameraCal: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -186,19 +183,18 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (OrthographicCameraCal, float) -> numpy.ndarray + def local_coordinates(self, b: OrthographicCameraCal, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (OrthographicCameraCal, float, float) -> OrthographicCameraCal + def interpolate( + self, b: OrthographicCameraCal, alpha: float, epsilon: float = 1e-8 + ) -> OrthographicCameraCal: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, OrthographicCameraCal): return self.data == other.data else: diff --git a/gen/python/sym/polynomial_camera_cal.py b/gen/python/sym/polynomial_camera_cal.py index 56a34323..ea0ef042 100644 --- a/gen/python/sym/polynomial_camera_cal.py +++ b/gen/python/sym/polynomial_camera_cal.py @@ -4,6 +4,8 @@ # Do NOT modify by hand. # ----------------------------------------------------------------------------- +from __future__ import annotations + import typing as T import numpy @@ -34,13 +36,16 @@ class PolynomialCameraCal(object): # This is because of an issue where mypy doesn't recognize attributes defined in __slots__ # See https://github.com/python/mypy/issues/5941 if T.TYPE_CHECKING: - data = [] # type: T.List[float] + data: T.List[float] = [] def __init__( - self, focal_length, principal_point, critical_undistorted_radius, distortion_coeffs - ): - # type: (T.Union[T.Sequence[float], numpy.ndarray], T.Union[T.Sequence[float], numpy.ndarray], float, T.Union[T.Sequence[float], numpy.ndarray]) -> None - self.data = [] + self, + focal_length: T.Union[T.Sequence[float], numpy.ndarray], + principal_point: T.Union[T.Sequence[float], numpy.ndarray], + critical_undistorted_radius: float, + distortion_coeffs: T.Union[T.Sequence[float], numpy.ndarray], + ) -> None: + self.data: T.List[float] = [] if isinstance(focal_length, numpy.ndarray): if focal_length.shape in {(2, 1), (1, 2)}: focal_length = focal_length.flatten() @@ -92,32 +97,30 @@ def __init__( self.data.append(critical_undistorted_radius) self.data.extend(distortion_coeffs) - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # CameraOps # -------------------------------------------------------------------------- - def focal_length(self): - # type: (PolynomialCameraCal) -> numpy.ndarray + def focal_length(self: PolynomialCameraCal) -> numpy.ndarray: """ Return the focal length. """ return ops.CameraOps.focal_length(self) - def principal_point(self): - # type: (PolynomialCameraCal) -> numpy.ndarray + def principal_point(self: PolynomialCameraCal) -> numpy.ndarray: """ Return the principal point. """ return ops.CameraOps.principal_point(self) - def pixel_from_camera_point(self, point, epsilon): - # type: (PolynomialCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: PolynomialCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -128,8 +131,9 @@ def pixel_from_camera_point(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point(self, point, epsilon) - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (PolynomialCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: PolynomialCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -147,17 +151,14 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 8 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> PolynomialCameraCal + def from_storage(cls, vec: T.Sequence[float]) -> PolynomialCameraCal: instance = cls.__new__(cls) if isinstance(vec, list): @@ -177,13 +178,11 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 8 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> PolynomialCameraCal + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> PolynomialCameraCal: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -192,12 +191,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> PolynomialCameraCal + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> PolynomialCameraCal: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -206,19 +203,18 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (PolynomialCameraCal, float) -> numpy.ndarray + def local_coordinates(self, b: PolynomialCameraCal, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (PolynomialCameraCal, float, float) -> PolynomialCameraCal + def interpolate( + self, b: PolynomialCameraCal, alpha: float, epsilon: float = 1e-8 + ) -> PolynomialCameraCal: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, PolynomialCameraCal): return self.data == other.data else: diff --git a/gen/python/sym/pose2.py b/gen/python/sym/pose2.py index 1bcc5084..770e1e52 100644 --- a/gen/python/sym/pose2.py +++ b/gen/python/sym/pose2.py @@ -7,6 +7,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import random import typing as T @@ -49,16 +51,18 @@ class for more information. __slots__ = ["data"] - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # Handwritten methods included from "custom_methods/pose2.py.jinja" # -------------------------------------------------------------------------- - def __init__(self, R=None, t=None): - # type: (T.Optional[Rot2], T.Union[T.Sequence[float], numpy.ndarray, None]) -> None + def __init__( + self, + R: T.Optional[Rot2] = None, + t: T.Union[T.Sequence[float], numpy.ndarray, None] = None, + ) -> None: rotation = R if R is not None else Rot2() if t is None: t = [0.0, 0.0] @@ -79,31 +83,27 @@ def __init__(self, R=None, t=None): self.data = rotation.to_storage() + list(t) @property - def R(self): - # type: () -> Rot2 + def R(self) -> Rot2: """ Accessor for the rotation component, equivalent to self.rotation() """ return self.rotation() @property - def t(self): - # type: () -> numpy.ndarray + def t(self) -> numpy.ndarray: """ Accessor for the position component, equivalent to self.position() """ return self.position() - def rotation(self): - # type: () -> Rot2 + def rotation(self) -> Rot2: return Rot2.from_storage(list(self.rotation_storage())) # -------------------------------------------------------------------------- # Custom generated methods # -------------------------------------------------------------------------- - def rotation_storage(self): - # type: (Pose2) -> numpy.ndarray + def rotation_storage(self: Pose2) -> numpy.ndarray: """ Returns the rotational component of this pose. """ @@ -121,8 +121,7 @@ def rotation_storage(self): _res[1] = _self[1] return _res - def position(self): - # type: (Pose2) -> numpy.ndarray + def position(self: Pose2) -> numpy.ndarray: """ Returns the positional component of this pose. """ @@ -140,8 +139,7 @@ def position(self): _res[1] = _self[3] return _res - def compose_with_point(self, right): - # type: (Pose2, numpy.ndarray) -> numpy.ndarray + def compose_with_point(self: Pose2, right: numpy.ndarray) -> numpy.ndarray: """ Left-multiply with a compatible quantity. """ @@ -167,8 +165,7 @@ def compose_with_point(self, right): _res[1] = _self[0] * right[1, 0] + _self[1] * right[0, 0] + _self[3] return _res - def inverse_compose(self, point): - # type: (Pose2, numpy.ndarray) -> numpy.ndarray + def inverse_compose(self: Pose2, point: numpy.ndarray) -> numpy.ndarray: """ Returns ``self.inverse() * point`` @@ -207,8 +204,7 @@ def inverse_compose(self, point): ) return _res - def to_homogenous_matrix(self): - # type: (Pose2) -> numpy.ndarray + def to_homogenous_matrix(self: Pose2) -> numpy.ndarray: """ A matrix representation of this element in the Euclidean space that contains it. @@ -241,17 +237,14 @@ def to_homogenous_matrix(self): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 4 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> Pose2 + def from_storage(cls, vec: T.Sequence[float]) -> Pose2: instance = cls.__new__(cls) if isinstance(vec, list): @@ -271,20 +264,16 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @classmethod - def identity(cls): - # type: () -> Pose2 + def identity(cls) -> Pose2: return ops.GroupOps.identity() - def inverse(self): - # type: () -> Pose2 + def inverse(self) -> Pose2: return ops.GroupOps.inverse(self) - def compose(self, b): - # type: (Pose2) -> Pose2 + def compose(self, b: Pose2) -> Pose2: return ops.GroupOps.compose(self, b) - def between(self, b): - # type: (Pose2) -> Pose2 + def between(self, b: Pose2) -> Pose2: return ops.GroupOps.between(self, b) # -------------------------------------------------------------------------- @@ -292,13 +281,11 @@ def between(self, b): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 3 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> Pose2 + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> Pose2: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -307,12 +294,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> Pose2 + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> Pose2: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -321,37 +306,31 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (Pose2, float) -> numpy.ndarray + def local_coordinates(self, b: Pose2, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (Pose2, float, float) -> Pose2 + def interpolate(self, b: Pose2, alpha: float, epsilon: float = 1e-8) -> Pose2: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, Pose2): return self.data == other.data else: return False @T.overload - def __mul__(self, other): # pragma: no cover - # type: (Pose2) -> Pose2 + def __mul__(self, other: Pose2) -> Pose2: # pragma: no cover pass @T.overload - def __mul__(self, other): # pragma: no cover - # type: (numpy.ndarray) -> numpy.ndarray + def __mul__(self, other: numpy.ndarray) -> numpy.ndarray: # pragma: no cover pass - def __mul__(self, other): - # type: (T.Union[Pose2, numpy.ndarray]) -> T.Union[Pose2, numpy.ndarray] + def __mul__(self, other: T.Union[Pose2, numpy.ndarray]) -> T.Union[Pose2, numpy.ndarray]: if isinstance(other, Pose2): return self.compose(other) elif isinstance(other, numpy.ndarray) and hasattr(self, "compose_with_point"): diff --git a/gen/python/sym/pose3.py b/gen/python/sym/pose3.py index 53a9e1cf..9b05a7b6 100644 --- a/gen/python/sym/pose3.py +++ b/gen/python/sym/pose3.py @@ -7,6 +7,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import random import typing as T @@ -49,16 +51,18 @@ class for more information. __slots__ = ["data"] - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # Handwritten methods included from "custom_methods/pose3.py.jinja" # -------------------------------------------------------------------------- - def __init__(self, R=None, t=None): - # type: (T.Optional[Rot3], T.Union[T.Sequence[float], numpy.ndarray, None]) -> None + def __init__( + self, + R: T.Optional[Rot3] = None, + t: T.Union[T.Sequence[float], numpy.ndarray, None] = None, + ) -> None: rotation = R if R is not None else Rot3() if t is None: t = [0.0, 0.0, 0.0] @@ -79,31 +83,27 @@ def __init__(self, R=None, t=None): self.data = rotation.to_storage() + list(t) @property - def R(self): - # type: () -> Rot3 + def R(self) -> Rot3: """ Accessor for the rotation component, equivalent to self.rotation() """ return self.rotation() @property - def t(self): - # type: () -> numpy.ndarray + def t(self) -> numpy.ndarray: """ Accessor for the position component, equivalent to self.position() """ return self.position() - def rotation(self): - # type: () -> Rot3 + def rotation(self) -> Rot3: return Rot3.from_storage(list(self.rotation_storage())) # -------------------------------------------------------------------------- # Custom generated methods # -------------------------------------------------------------------------- - def rotation_storage(self): - # type: (Pose3) -> numpy.ndarray + def rotation_storage(self: Pose3) -> numpy.ndarray: """ Returns the rotational component of this pose. """ @@ -123,8 +123,7 @@ def rotation_storage(self): _res[3] = _self[3] return _res - def position(self): - # type: (Pose3) -> numpy.ndarray + def position(self: Pose3) -> numpy.ndarray: """ Returns the positional component of this pose. """ @@ -143,8 +142,7 @@ def position(self): _res[2] = _self[6] return _res - def compose_with_point(self, right): - # type: (Pose3, numpy.ndarray) -> numpy.ndarray + def compose_with_point(self: Pose3, right: numpy.ndarray) -> numpy.ndarray: """ Left-multiply with a compatible quantity. """ @@ -197,8 +195,7 @@ def compose_with_point(self, right): ) return _res - def inverse_compose(self, point): - # type: (Pose3, numpy.ndarray) -> numpy.ndarray + def inverse_compose(self: Pose3, point: numpy.ndarray) -> numpy.ndarray: """ Returns ``self.inverse() * point`` @@ -269,8 +266,7 @@ def inverse_compose(self, point): ) return _res - def to_homogenous_matrix(self): - # type: (Pose3) -> numpy.ndarray + def to_homogenous_matrix(self: Pose3) -> numpy.ndarray: """ 4x4 matrix representing this pose transform. """ @@ -318,17 +314,14 @@ def to_homogenous_matrix(self): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 7 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> Pose3 + def from_storage(cls, vec: T.Sequence[float]) -> Pose3: instance = cls.__new__(cls) if isinstance(vec, list): @@ -348,20 +341,16 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @classmethod - def identity(cls): - # type: () -> Pose3 + def identity(cls) -> Pose3: return ops.GroupOps.identity() - def inverse(self): - # type: () -> Pose3 + def inverse(self) -> Pose3: return ops.GroupOps.inverse(self) - def compose(self, b): - # type: (Pose3) -> Pose3 + def compose(self, b: Pose3) -> Pose3: return ops.GroupOps.compose(self, b) - def between(self, b): - # type: (Pose3) -> Pose3 + def between(self, b: Pose3) -> Pose3: return ops.GroupOps.between(self, b) # -------------------------------------------------------------------------- @@ -369,13 +358,11 @@ def between(self, b): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 6 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> Pose3 + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> Pose3: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -384,12 +371,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> Pose3 + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> Pose3: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -398,37 +383,31 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (Pose3, float) -> numpy.ndarray + def local_coordinates(self, b: Pose3, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (Pose3, float, float) -> Pose3 + def interpolate(self, b: Pose3, alpha: float, epsilon: float = 1e-8) -> Pose3: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, Pose3): return self.data == other.data else: return False @T.overload - def __mul__(self, other): # pragma: no cover - # type: (Pose3) -> Pose3 + def __mul__(self, other: Pose3) -> Pose3: # pragma: no cover pass @T.overload - def __mul__(self, other): # pragma: no cover - # type: (numpy.ndarray) -> numpy.ndarray + def __mul__(self, other: numpy.ndarray) -> numpy.ndarray: # pragma: no cover pass - def __mul__(self, other): - # type: (T.Union[Pose3, numpy.ndarray]) -> T.Union[Pose3, numpy.ndarray] + def __mul__(self, other: T.Union[Pose3, numpy.ndarray]) -> T.Union[Pose3, numpy.ndarray]: if isinstance(other, Pose3): return self.compose(other) elif isinstance(other, numpy.ndarray) and hasattr(self, "compose_with_point"): diff --git a/gen/python/sym/rot2.py b/gen/python/sym/rot2.py index bf8a07d4..2d42e793 100644 --- a/gen/python/sym/rot2.py +++ b/gen/python/sym/rot2.py @@ -7,6 +7,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import random import typing as T @@ -27,18 +29,16 @@ class Rot2(object): __slots__ = ["data"] - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # Handwritten methods included from "custom_methods/rot2.py.jinja" # -------------------------------------------------------------------------- - def __init__(self, z=None): - # type: (T.Union[T.Sequence[float], numpy.ndarray, None]) -> None + def __init__(self, z: T.Union[T.Sequence[float], numpy.ndarray, None] = None) -> None: if z is None: - self.data = ops.GroupOps.identity().data # type: T.List[float] + self.data: T.List[float] = ops.GroupOps.identity().data else: if isinstance(z, numpy.ndarray): if z.shape in {(2, 1), (1, 2)}: @@ -56,16 +56,14 @@ def __init__(self, z=None): self.data = list(z) @classmethod - def random(cls): - # type: () -> Rot2 + def random(cls) -> Rot2: return Rot2.random_from_uniform_sample(random.uniform(0, 1)) # -------------------------------------------------------------------------- # Custom generated methods # -------------------------------------------------------------------------- - def compose_with_point(self, right): - # type: (Rot2, numpy.ndarray) -> numpy.ndarray + def compose_with_point(self: Rot2, right: numpy.ndarray) -> numpy.ndarray: """ Left-multiplication. Either rotation concatenation or point transform. """ @@ -91,8 +89,7 @@ def compose_with_point(self, right): _res[1] = _self[0] * right[1, 0] + _self[1] * right[0, 0] return _res - def to_angle(self, epsilon): - # type: (Rot2, float) -> float + def to_angle(self: Rot2, epsilon: float) -> float: """ Get the angle of this Rot2 in radians @@ -111,8 +108,7 @@ def to_angle(self, epsilon): return _res @staticmethod - def from_angle(theta): - # type: (float) -> Rot2 + def from_angle(theta: float) -> Rot2: """ Create a Rot2 from an angle ``theta`` in radians @@ -131,8 +127,7 @@ def from_angle(theta): _res[1] = math.sin(theta) return Rot2.from_storage(_res) - def to_rotation_matrix(self): - # type: (Rot2) -> numpy.ndarray + def to_rotation_matrix(self: Rot2) -> numpy.ndarray: """ A matrix representation of this element in the Euclidean space that contains it. """ @@ -153,8 +148,7 @@ def to_rotation_matrix(self): return _res @staticmethod - def from_rotation_matrix(r): - # type: (numpy.ndarray) -> Rot2 + def from_rotation_matrix(r: numpy.ndarray) -> Rot2: """ Create a Rot2 from a 2x2 rotation matrix. @@ -179,8 +173,7 @@ def from_rotation_matrix(r): return Rot2.from_storage(_res) @staticmethod - def random_from_uniform_sample(u1): - # type: (float) -> Rot2 + def random_from_uniform_sample(u1: float) -> Rot2: """ Generate a random element of SO2 from a variable uniformly sampled on [0, 1]. """ @@ -203,17 +196,14 @@ def random_from_uniform_sample(u1): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 2 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> Rot2 + def from_storage(cls, vec: T.Sequence[float]) -> Rot2: instance = cls.__new__(cls) if isinstance(vec, list): @@ -233,20 +223,16 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @classmethod - def identity(cls): - # type: () -> Rot2 + def identity(cls) -> Rot2: return ops.GroupOps.identity() - def inverse(self): - # type: () -> Rot2 + def inverse(self) -> Rot2: return ops.GroupOps.inverse(self) - def compose(self, b): - # type: (Rot2) -> Rot2 + def compose(self, b: Rot2) -> Rot2: return ops.GroupOps.compose(self, b) - def between(self, b): - # type: (Rot2) -> Rot2 + def between(self, b: Rot2) -> Rot2: return ops.GroupOps.between(self, b) # -------------------------------------------------------------------------- @@ -254,13 +240,11 @@ def between(self, b): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 1 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> Rot2 + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> Rot2: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -269,12 +253,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> Rot2 + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> Rot2: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -283,37 +265,31 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (Rot2, float) -> numpy.ndarray + def local_coordinates(self, b: Rot2, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (Rot2, float, float) -> Rot2 + def interpolate(self, b: Rot2, alpha: float, epsilon: float = 1e-8) -> Rot2: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, Rot2): return self.data == other.data else: return False @T.overload - def __mul__(self, other): # pragma: no cover - # type: (Rot2) -> Rot2 + def __mul__(self, other: Rot2) -> Rot2: # pragma: no cover pass @T.overload - def __mul__(self, other): # pragma: no cover - # type: (numpy.ndarray) -> numpy.ndarray + def __mul__(self, other: numpy.ndarray) -> numpy.ndarray: # pragma: no cover pass - def __mul__(self, other): - # type: (T.Union[Rot2, numpy.ndarray]) -> T.Union[Rot2, numpy.ndarray] + def __mul__(self, other: T.Union[Rot2, numpy.ndarray]) -> T.Union[Rot2, numpy.ndarray]: if isinstance(other, Rot2): return self.compose(other) elif isinstance(other, numpy.ndarray) and hasattr(self, "compose_with_point"): diff --git a/gen/python/sym/rot3.py b/gen/python/sym/rot3.py index 50e8f35b..03918413 100644 --- a/gen/python/sym/rot3.py +++ b/gen/python/sym/rot3.py @@ -7,6 +7,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import random import typing as T @@ -27,18 +29,16 @@ class Rot3(object): __slots__ = ["data"] - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # Handwritten methods included from "custom_methods/rot3.py.jinja" # -------------------------------------------------------------------------- - def __init__(self, q=None): - # type: (T.Union[T.Sequence[float], numpy.ndarray, None]) -> None + def __init__(self, q: T.Union[T.Sequence[float], numpy.ndarray, None] = None) -> None: if q is None: - self.data = ops.GroupOps.identity().data # type: T.List[float] + self.data: T.List[float] = ops.GroupOps.identity().data else: if isinstance(q, numpy.ndarray): if q.shape in {(4, 1), (1, 4)}: @@ -56,8 +56,7 @@ def __init__(self, q=None): self.data = list(q) @classmethod - def from_rotation_matrix(cls, R, epsilon=0.0): - # type: (numpy.ndarray, float) -> Rot3 + def from_rotation_matrix(cls, R: numpy.ndarray, epsilon: float = 0.0) -> Rot3: """ This implementation is based on Shepperd's method (1978) https://arc.aiaa.org/doi/abs/10.2514/3.55767b?journalCode=jgc (this is paywalled) @@ -96,8 +95,7 @@ def from_rotation_matrix(cls, R, epsilon=0.0): return Rot3.from_storage([x, y, z, w]) @classmethod - def random(cls): - # type: () -> Rot3 + def random(cls) -> Rot3: return Rot3.random_from_uniform_samples( random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1) ) @@ -106,8 +104,7 @@ def random(cls): # Custom generated methods # -------------------------------------------------------------------------- - def compose_with_point(self, right): - # type: (Rot3, numpy.ndarray) -> numpy.ndarray + def compose_with_point(self: Rot3, right: numpy.ndarray) -> numpy.ndarray: """ Left-multiplication. Either rotation concatenation or point transform. """ @@ -157,8 +154,7 @@ def compose_with_point(self, right): ) return _res - def to_tangent_norm(self, epsilon): - # type: (Rot3, float) -> float + def to_tangent_norm(self: Rot3, epsilon: float) -> float: """ Returns the norm of the tangent vector corresponding to this rotation @@ -179,8 +175,7 @@ def to_tangent_norm(self, epsilon): _res = 2 * math.acos(min(abs(_self[3]), 1 - epsilon)) return _res - def to_rotation_matrix(self): - # type: (Rot3) -> numpy.ndarray + def to_rotation_matrix(self: Rot3) -> numpy.ndarray: """ Converts to a rotation matrix """ @@ -217,8 +212,7 @@ def to_rotation_matrix(self): return _res @staticmethod - def random_from_uniform_samples(u1, u2, u3): - # type: (float, float, float) -> Rot3 + def random_from_uniform_samples(u1: float, u2: float, u3: float) -> Rot3: """ Generate a random element of SO3 from three variables uniformly sampled in [0, 1]. """ @@ -242,8 +236,7 @@ def random_from_uniform_samples(u1, u2, u3): _res[3] = _tmp3 * math.cos(_tmp4) return Rot3.from_storage(_res) - def to_yaw_pitch_roll(self): - # type: (Rot3) -> numpy.ndarray + def to_yaw_pitch_roll(self: Rot3) -> numpy.ndarray: """ Compute the yaw, pitch, and roll Euler angles in radians of this rotation @@ -280,8 +273,7 @@ def to_yaw_pitch_roll(self): return _res @staticmethod - def from_yaw_pitch_roll(yaw, pitch, roll): - # type: (float, float, float) -> Rot3 + def from_yaw_pitch_roll(yaw: float, pitch: float, roll: float) -> Rot3: """ Construct from yaw, pitch, and roll Euler angles in radians """ @@ -314,8 +306,7 @@ def from_yaw_pitch_roll(yaw, pitch, roll): return Rot3.from_storage(_res) @staticmethod - def from_yaw(yaw): - # type: (float) -> Rot3 + def from_yaw(yaw: float) -> Rot3: """Construct from yaw angle in radians""" # Total ops: 5 @@ -334,8 +325,7 @@ def from_yaw(yaw): return Rot3.from_storage(_res) @staticmethod - def from_pitch(pitch): - # type: (float) -> Rot3 + def from_pitch(pitch: float) -> Rot3: """Construct from pitch angle in radians""" # Total ops: 5 @@ -354,8 +344,7 @@ def from_pitch(pitch): return Rot3.from_storage(_res) @staticmethod - def from_roll(roll): - # type: (float) -> Rot3 + def from_roll(roll: float) -> Rot3: """Construct from roll angle in radians""" # Total ops: 5 @@ -374,8 +363,7 @@ def from_roll(roll): return Rot3.from_storage(_res) @staticmethod - def from_angle_axis(angle, axis): - # type: (float, numpy.ndarray) -> Rot3 + def from_angle_axis(angle: float, axis: numpy.ndarray) -> Rot3: """ Construct from an angle in radians and a (normalized) axis as a 3-vector. """ @@ -405,8 +393,7 @@ def from_angle_axis(angle, axis): return Rot3.from_storage(_res) @staticmethod - def from_two_unit_vectors(a, b, epsilon): - # type: (numpy.ndarray, numpy.ndarray, float) -> Rot3 + def from_two_unit_vectors(a: numpy.ndarray, b: numpy.ndarray, epsilon: float) -> Rot3: """ Return a rotation that transforms a to b. Both inputs are three-vectors that are expected to be normalized. @@ -460,17 +447,14 @@ def from_two_unit_vectors(a, b, epsilon): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 4 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> Rot3 + def from_storage(cls, vec: T.Sequence[float]) -> Rot3: instance = cls.__new__(cls) if isinstance(vec, list): @@ -490,20 +474,16 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @classmethod - def identity(cls): - # type: () -> Rot3 + def identity(cls) -> Rot3: return ops.GroupOps.identity() - def inverse(self): - # type: () -> Rot3 + def inverse(self) -> Rot3: return ops.GroupOps.inverse(self) - def compose(self, b): - # type: (Rot3) -> Rot3 + def compose(self, b: Rot3) -> Rot3: return ops.GroupOps.compose(self, b) - def between(self, b): - # type: (Rot3) -> Rot3 + def between(self, b: Rot3) -> Rot3: return ops.GroupOps.between(self, b) # -------------------------------------------------------------------------- @@ -511,13 +491,11 @@ def between(self, b): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 3 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> Rot3 + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> Rot3: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -526,12 +504,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> Rot3 + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> Rot3: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -540,37 +516,31 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (Rot3, float) -> numpy.ndarray + def local_coordinates(self, b: Rot3, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (Rot3, float, float) -> Rot3 + def interpolate(self, b: Rot3, alpha: float, epsilon: float = 1e-8) -> Rot3: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, Rot3): return self.data == other.data else: return False @T.overload - def __mul__(self, other): # pragma: no cover - # type: (Rot3) -> Rot3 + def __mul__(self, other: Rot3) -> Rot3: # pragma: no cover pass @T.overload - def __mul__(self, other): # pragma: no cover - # type: (numpy.ndarray) -> numpy.ndarray + def __mul__(self, other: numpy.ndarray) -> numpy.ndarray: # pragma: no cover pass - def __mul__(self, other): - # type: (T.Union[Rot3, numpy.ndarray]) -> T.Union[Rot3, numpy.ndarray] + def __mul__(self, other: T.Union[Rot3, numpy.ndarray]) -> T.Union[Rot3, numpy.ndarray]: if isinstance(other, Rot3): return self.compose(other) elif isinstance(other, numpy.ndarray) and hasattr(self, "compose_with_point"): diff --git a/gen/python/sym/spherical_camera_cal.py b/gen/python/sym/spherical_camera_cal.py index 89636431..69c52a49 100644 --- a/gen/python/sym/spherical_camera_cal.py +++ b/gen/python/sym/spherical_camera_cal.py @@ -4,6 +4,8 @@ # Do NOT modify by hand. # ----------------------------------------------------------------------------- +from __future__ import annotations + import typing as T import numpy @@ -56,11 +58,16 @@ class SphericalCameraCal(object): # This is because of an issue where mypy doesn't recognize attributes defined in __slots__ # See https://github.com/python/mypy/issues/5941 if T.TYPE_CHECKING: - data = [] # type: T.List[float] - - def __init__(self, focal_length, principal_point, critical_theta, distortion_coeffs): - # type: (T.Union[T.Sequence[float], numpy.ndarray], T.Union[T.Sequence[float], numpy.ndarray], float, T.Union[T.Sequence[float], numpy.ndarray]) -> None - self.data = [] + data: T.List[float] = [] + + def __init__( + self, + focal_length: T.Union[T.Sequence[float], numpy.ndarray], + principal_point: T.Union[T.Sequence[float], numpy.ndarray], + critical_theta: float, + distortion_coeffs: T.Union[T.Sequence[float], numpy.ndarray], + ) -> None: + self.data: T.List[float] = [] if isinstance(focal_length, numpy.ndarray): if focal_length.shape in {(2, 1), (1, 2)}: focal_length = focal_length.flatten() @@ -112,32 +119,30 @@ def __init__(self, focal_length, principal_point, critical_theta, distortion_coe self.data.append(critical_theta) self.data.extend(distortion_coeffs) - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # CameraOps # -------------------------------------------------------------------------- - def focal_length(self): - # type: (SphericalCameraCal) -> numpy.ndarray + def focal_length(self: SphericalCameraCal) -> numpy.ndarray: """ Return the focal length. """ return ops.CameraOps.focal_length(self) - def principal_point(self): - # type: (SphericalCameraCal) -> numpy.ndarray + def principal_point(self: SphericalCameraCal) -> numpy.ndarray: """ Return the principal point. """ return ops.CameraOps.principal_point(self) - def pixel_from_camera_point(self, point, epsilon): - # type: (SphericalCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float] + def pixel_from_camera_point( + self: SphericalCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -148,8 +153,9 @@ def pixel_from_camera_point(self, point, epsilon): return ops.CameraOps.pixel_from_camera_point(self, point, epsilon) - def pixel_from_camera_point_with_jacobians(self, point, epsilon): - # type: (SphericalCameraCal, numpy.ndarray, float) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray] + def pixel_from_camera_point_with_jacobians( + self: SphericalCameraCal, point: numpy.ndarray, epsilon: float + ) -> T.Tuple[numpy.ndarray, float, numpy.ndarray, numpy.ndarray]: """ Project a 3D point in the camera frame into 2D pixel coordinates. @@ -167,17 +173,14 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 11 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> SphericalCameraCal + def from_storage(cls, vec: T.Sequence[float]) -> SphericalCameraCal: instance = cls.__new__(cls) if isinstance(vec, list): @@ -197,13 +200,11 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 11 @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> SphericalCameraCal + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> SphericalCameraCal: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -212,12 +213,10 @@ def from_tangent(cls, vec, epsilon=1e-8): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> SphericalCameraCal + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> SphericalCameraCal: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -226,19 +225,18 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (SphericalCameraCal, float) -> numpy.ndarray + def local_coordinates(self, b: SphericalCameraCal, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (SphericalCameraCal, float, float) -> SphericalCameraCal + def interpolate( + self, b: SphericalCameraCal, alpha: float, epsilon: float = 1e-8 + ) -> SphericalCameraCal: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, SphericalCameraCal): return self.data == other.data else: diff --git a/gen/python/sym/unit3.py b/gen/python/sym/unit3.py index dbaa1e72..fe0a8d3f 100644 --- a/gen/python/sym/unit3.py +++ b/gen/python/sym/unit3.py @@ -7,6 +7,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import random import typing as T @@ -45,16 +47,14 @@ class Unit3(object): __slots__ = ["data"] - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.data) # -------------------------------------------------------------------------- # Handwritten methods included from "custom_methods/unit3.py.jinja" # -------------------------------------------------------------------------- - def __init__(self, vec): - # type: (T.Union[T.Sequence[float], numpy.ndarray]) -> None + def __init__(self, vec: T.Union[T.Sequence[float], numpy.ndarray]) -> None: if isinstance(vec, numpy.ndarray): if vec.shape in {(3, 1), (1, 3)}: vec = vec.flatten() @@ -68,11 +68,10 @@ def __init__(self, vec): raise IndexError( "Expected vec to be a sequence of length 3, was instead length {}.".format(len(vec)) ) - self.data = list(vec) # type: T.List[float] + self.data: T.List[float] = list(vec) @classmethod - def random(cls, epsilon=1e-8): - # type: (float) -> Unit3 + def random(cls, epsilon: float = 1e-8) -> Unit3: """ Return a random :class:`Unit3` object """ @@ -84,8 +83,7 @@ def random(cls, epsilon=1e-8): # Custom generated methods # -------------------------------------------------------------------------- - def basis(self, epsilon): - # type: (Unit3, float) -> numpy.ndarray + def basis(self: Unit3, epsilon: float) -> numpy.ndarray: """ Returns a :class:`Matrix32` with the basis vectors of the tangent space (in R^3) at the current Unit3 direction. @@ -129,8 +127,7 @@ def basis(self, epsilon): _res[2, 1] = _tmp1 * (-_tmp5 * _tmp8 + 1) + _tmp2 * (-_tmp5 * _tmp7 + 1) return _res - def to_unit_vector(self): - # type: (Unit3) -> numpy.ndarray + def to_unit_vector(self: Unit3) -> numpy.ndarray: """ Returns a :class:`Vector3` version of the unit direction. """ @@ -150,8 +147,7 @@ def to_unit_vector(self): return _res @staticmethod - def random_from_uniform_samples(u1, u2, epsilon): - # type: (float, float, float) -> Unit3 + def random_from_uniform_samples(u1: float, u2: float, epsilon: float) -> Unit3: """ Generate a random :class:`Unit3` direction from two variables uniformly sampled in [0, 1]. """ @@ -178,8 +174,7 @@ def random_from_uniform_samples(u1, u2, epsilon): return Unit3.from_storage(_res) @staticmethod - def from_vector(a, epsilon): - # type: (numpy.ndarray, float) -> Unit3 + def from_vector(a: numpy.ndarray, epsilon: float) -> Unit3: """ Return a :class:`Unit3` that points along the direction of vector ``a`` @@ -207,8 +202,7 @@ def from_vector(a, epsilon): return Unit3.from_storage(_res) @staticmethod - def from_unit_vector(a): - # type: (numpy.ndarray) -> Unit3 + def from_unit_vector(a: numpy.ndarray) -> Unit3: """ Return a :class:`Unit3` that points along the direction of vector ``a`` @@ -239,17 +233,14 @@ def from_unit_vector(a): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return 3 - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> Unit3 + def from_storage(cls, vec: T.Sequence[float]) -> Unit3: instance = cls.__new__(cls) if isinstance(vec, list): @@ -269,12 +260,10 @@ def from_storage(cls, vec): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return 2 - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> Unit3 + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> Unit3: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -283,20 +272,17 @@ def retract(self, vec, epsilon=1e-8): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: (Unit3, float) -> numpy.ndarray + def local_coordinates(self, b: Unit3, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: (Unit3, float, float) -> Unit3 + def interpolate(self, b: Unit3, alpha: float, epsilon: float = 1e-8) -> Unit3: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, Unit3): return self.data == other.data else: diff --git a/symforce/codegen/backends/python/templates/cam_package/CLASS.py.jinja b/symforce/codegen/backends/python/templates/cam_package/CLASS.py.jinja index f77e6e3f..ff8c4c5d 100644 --- a/symforce/codegen/backends/python/templates/cam_package/CLASS.py.jinja +++ b/symforce/codegen/backends/python/templates/cam_package/CLASS.py.jinja @@ -3,6 +3,9 @@ # This source code is under the Apache 2.0 license found in the LICENSE file. # ---------------------------------------------------------------------------- #} {%- import "../util/util.jinja" as util with context -%} + +from __future__ import annotations + import typing as T import numpy @@ -26,15 +29,16 @@ class {{ cls.__name__ }}(object): # This is because of an issue where mypy doesn't recognize attributes defined in __slots__ # See https://github.com/python/mypy/issues/5941 if T.TYPE_CHECKING: - data = [] # type: T.List[float] + data: T.List[float] = [] - def __init__(self, + def __init__( + self, {% for arg, size in storage_order %} - {{ arg }}{% if not loop.last %}, {% endif %} + {{ arg }}: {%if size == 1 %}float{% else %}T.Union[T.Sequence[float], numpy.ndarray]{% endif %}{% if not loop.last %},{% endif %} + {% endfor %} - ): - # type: ({% for arg, size in storage_order %}{%if size == 1 %}float{% else %}T.Union[T.Sequence[float], numpy.ndarray]{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}) -> None - self.data = [] + ) -> None: + self.data: T.List[float] = [] {% for arg, size in storage_order %} {% if size != 1 %} {{ util.flatten_if_ndarray(arg, size) | indent(width=8) }} @@ -45,8 +49,7 @@ class {{ cls.__name__ }}(object): self.data.{%if size==1 %}append{% else %}extend{% endif %}({{ arg }}) {% endfor %} - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return '<{} {}>'.format(self.__class__.__name__, self.data) @@ -66,17 +69,14 @@ class {{ cls.__name__ }}(object): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return {{ ops.StorageOps.storage_dim(cls) }} - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> {{ cls.__name__ }} + def from_storage(cls, vec: T.Sequence[float]) -> {{ cls.__name__ }}: instance = cls.__new__(cls) if isinstance(vec, list): @@ -96,13 +96,11 @@ class {{ cls.__name__ }}(object): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return {{ ops.LieGroupOps.tangent_dim(cls) }} @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> {{ cls.__name__ }} + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> {{ cls.__name__ }}: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -111,12 +109,10 @@ class {{ cls.__name__ }}(object): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> {{ cls.__name__ }} + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> {{ cls.__name__ }}: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -125,19 +121,16 @@ class {{ cls.__name__ }}(object): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: ({{ cls.__name__ }}, float) -> numpy.ndarray + def local_coordinates(self, b: {{ cls.__name__ }}, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: ({{ cls.__name__ }}, float, float) -> {{ cls.__name__ }} + def interpolate(self, b: {{ cls.__name__ }}, alpha: float, epsilon: float = 1e-8) -> {{ cls.__name__ }}: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) # -------------------------------------------------------------------------- # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, {{ cls.__name__ }}): return self.data == other.data else: diff --git a/symforce/codegen/backends/python/templates/cam_package/ops/CLASS/camera_ops.py.jinja b/symforce/codegen/backends/python/templates/cam_package/ops/CLASS/camera_ops.py.jinja index c8ba2ac4..28f87d75 100644 --- a/symforce/codegen/backends/python/templates/cam_package/ops/CLASS/camera_ops.py.jinja +++ b/symforce/codegen/backends/python/templates/cam_package/ops/CLASS/camera_ops.py.jinja @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -23,7 +25,6 @@ class CameraOps(object): @staticmethod {{ util.function_declaration(spec) }} {{ util.print_docstring(spec.docstring) | indent(8) }} - {{ util.expr_code(spec) | indent(4) }} {% endfor %} diff --git a/symforce/codegen/backends/python/templates/function/FUNCTION.py.jinja b/symforce/codegen/backends/python/templates/function/FUNCTION.py.jinja index b52c3b68..63044044 100644 --- a/symforce/codegen/backends/python/templates/function/FUNCTION.py.jinja +++ b/symforce/codegen/backends/python/templates/function/FUNCTION.py.jinja @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -28,5 +30,4 @@ import sym {% if spec.docstring %} {{ util.print_docstring(spec.docstring) | indent(4) }} {% endif %} - {{ util.expr_code(spec) }} diff --git a/symforce/codegen/backends/python/templates/geo_package/CLASS.py.jinja b/symforce/codegen/backends/python/templates/geo_package/CLASS.py.jinja index f735a17b..1a4bc8db 100644 --- a/symforce/codegen/backends/python/templates/geo_package/CLASS.py.jinja +++ b/symforce/codegen/backends/python/templates/geo_package/CLASS.py.jinja @@ -5,6 +5,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import random import typing as T @@ -35,8 +37,7 @@ class {{ cls.__name__ }}(object): __slots__ = ['data'] - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return '<{} {}>'.format(self.__class__.__name__, self.data) {% set custom_template_name = "custom_methods/{}.py.jinja".format(cls.__name__.lower()) %} @@ -61,7 +62,6 @@ class {{ cls.__name__ }}(object): {% endif %} {{ util.function_declaration(spec, is_method=True, available_classes=available_classes) | indent(4)}} {{ util.print_docstring(spec.docstring) | indent(8) }} - {{ util.expr_code(spec, available_classes=available_classes) | indent(4) }} {% endfor %} @@ -71,17 +71,14 @@ class {{ cls.__name__ }}(object): # -------------------------------------------------------------------------- @staticmethod - def storage_dim(): - # type: () -> int + def storage_dim() -> int: return {{ ops.StorageOps.storage_dim(cls) }} - def to_storage(self): - # type: () -> T.List[float] + def to_storage(self) -> T.List[float]: return list(self.data) @classmethod - def from_storage(cls, vec): - # type: (T.Sequence[float]) -> {{ cls.__name__ }} + def from_storage(cls, vec: T.Sequence[float]) -> {{ cls.__name__ }}: instance = cls.__new__(cls) if isinstance(vec, list): @@ -102,20 +99,16 @@ class {{ cls.__name__ }}(object): # -------------------------------------------------------------------------- @classmethod - def identity(cls): - # type: () -> {{ cls.__name__ }} + def identity(cls) -> {{ cls.__name__ }}: return ops.GroupOps.identity() - def inverse(self): - # type: () -> {{ cls.__name__ }} + def inverse(self) -> {{ cls.__name__ }}: return ops.GroupOps.inverse(self) - def compose(self, b): - # type: ({{ cls.__name__ }}) -> {{ cls.__name__ }} + def compose(self, b: {{ cls.__name__ }}) -> {{ cls.__name__ }}: return ops.GroupOps.compose(self, b) - def between(self, b): - # type: ({{ cls.__name__ }}) -> {{ cls.__name__ }} + def between(self, b: {{ cls.__name__ }}) -> {{ cls.__name__ }}: return ops.GroupOps.between(self, b) {% endif %} @@ -126,14 +119,12 @@ class {{ cls.__name__ }}(object): # -------------------------------------------------------------------------- @staticmethod - def tangent_dim(): - # type: () -> int + def tangent_dim() -> int: return {{ ops.LieGroupOps.tangent_dim(cls) }} {% if is_lie_group %} @classmethod - def from_tangent(cls, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> {{ cls.__name__ }} + def from_tangent(cls, vec: numpy.ndarray, epsilon: float = 1e-8) -> {{ cls.__name__ }}: if len(vec) != cls.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -142,13 +133,11 @@ class {{ cls.__name__ }}(object): ) return ops.LieGroupOps.from_tangent(vec, epsilon) - def to_tangent(self, epsilon=1e-8): - # type: (float) -> numpy.ndarray + def to_tangent(self, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.to_tangent(self, epsilon) {% endif %} - def retract(self, vec, epsilon=1e-8): - # type: (numpy.ndarray, float) -> {{ cls.__name__ }} + def retract(self, vec: numpy.ndarray, epsilon: float = 1e-8) -> {{ cls.__name__ }}: if len(vec) != self.tangent_dim(): raise ValueError( "Vector dimension ({}) not equal to tangent space dimension ({}).".format( @@ -157,12 +146,10 @@ class {{ cls.__name__ }}(object): ) return ops.LieGroupOps.retract(self, vec, epsilon) - def local_coordinates(self, b, epsilon=1e-8): - # type: ({{ cls.__name__ }}, float) -> numpy.ndarray + def local_coordinates(self, b: {{ cls.__name__ }}, epsilon: float = 1e-8) -> numpy.ndarray: return ops.LieGroupOps.local_coordinates(self, b, epsilon) - def interpolate(self, b, alpha, epsilon=1e-8): - # type: ({{ cls.__name__ }}, float, float) -> {{ cls.__name__ }} + def interpolate(self, b: {{ cls.__name__ }}, alpha: float, epsilon: float = 1e-8) -> {{ cls.__name__ }}: return ops.LieGroupOps.interpolate(self, b, alpha, epsilon) {% endif %} @@ -171,8 +158,7 @@ class {{ cls.__name__ }}(object): # General Helpers # -------------------------------------------------------------------------- - def __eq__(self, other): - # type: (T.Any) -> bool + def __eq__(self, other: T.Any) -> bool: if isinstance(other, {{ cls.__name__ }}): return self.data == other.data else: @@ -180,17 +166,14 @@ class {{ cls.__name__ }}(object): {% if is_group %} @T.overload - def __mul__(self, other): # pragma: no cover - # type: ({{ cls.__name__ }}) -> {{ cls.__name__ }} + def __mul__(self, other: {{ cls.__name__ }}) -> {{ cls.__name__ }}: # pragma: no cover pass @T.overload - def __mul__(self, other): # pragma: no cover - # type: (numpy.ndarray) -> numpy.ndarray + def __mul__(self, other: numpy.ndarray) -> numpy.ndarray: # pragma: no cover pass - def __mul__(self, other): - # type: (T.Union[{{ cls.__name__ }}, numpy.ndarray]) -> T.Union[{{ cls.__name__ }}, numpy.ndarray] + def __mul__(self, other: T.Union[{{ cls.__name__ }}, numpy.ndarray]) -> T.Union[{{ cls.__name__ }}, numpy.ndarray]: if isinstance(other, {{ cls.__name__ }}): return self.compose(other) elif isinstance(other, numpy.ndarray) and hasattr(self, "compose_with_point"): diff --git a/symforce/codegen/backends/python/templates/geo_package/custom_methods/pose2.py.jinja b/symforce/codegen/backends/python/templates/geo_package/custom_methods/pose2.py.jinja index f85b13c9..78fb14b6 100644 --- a/symforce/codegen/backends/python/templates/geo_package/custom_methods/pose2.py.jinja +++ b/symforce/codegen/backends/python/templates/geo_package/custom_methods/pose2.py.jinja @@ -6,8 +6,11 @@ {# Handwritten methods for Pose2 #} {# These will get included into the autogenerated class header. #} - def __init__(self, R=None, t=None): - # type: (T.Optional[Rot2], T.Union[T.Sequence[float], numpy.ndarray, None]) -> None + def __init__( + self, + R: T.Optional[Rot2] = None, + t: T.Union[T.Sequence[float], numpy.ndarray, None] = None, + ) -> None: rotation = R if R is not None else Rot2() if t is None: t = [0., 0.] @@ -18,21 +21,18 @@ self.data = rotation.to_storage() + list(t) @property - def R(self): - # type: () -> Rot2 + def R(self) -> Rot2: """ Accessor for the rotation component, equivalent to self.rotation() """ return self.rotation() @property - def t(self): - # type: () -> numpy.ndarray + def t(self) -> numpy.ndarray: """ Accessor for the position component, equivalent to self.position() """ return self.position() - def rotation(self): - # type: () -> Rot2 + def rotation(self) -> Rot2: return Rot2.from_storage(list(self.rotation_storage())) diff --git a/symforce/codegen/backends/python/templates/geo_package/custom_methods/pose3.py.jinja b/symforce/codegen/backends/python/templates/geo_package/custom_methods/pose3.py.jinja index 0f9b0e5b..14eb5ea5 100644 --- a/symforce/codegen/backends/python/templates/geo_package/custom_methods/pose3.py.jinja +++ b/symforce/codegen/backends/python/templates/geo_package/custom_methods/pose3.py.jinja @@ -6,8 +6,11 @@ {# Handwritten methods for Pose3 #} {# These will get included into the autogenerated class header. #} - def __init__(self, R=None, t=None): - # type: (T.Optional[Rot3], T.Union[T.Sequence[float], numpy.ndarray, None]) -> None + def __init__( + self, + R: T.Optional[Rot3] = None, + t: T.Union[T.Sequence[float], numpy.ndarray, None] = None, + ) -> None: rotation = R if R is not None else Rot3() if t is None: t = [0., 0., 0.] @@ -18,21 +21,18 @@ self.data = rotation.to_storage() + list(t) @property - def R(self): - # type: () -> Rot3 + def R(self) -> Rot3: """ Accessor for the rotation component, equivalent to self.rotation() """ return self.rotation() @property - def t(self): - # type: () -> numpy.ndarray + def t(self) -> numpy.ndarray: """ Accessor for the position component, equivalent to self.position() """ return self.position() - def rotation(self): - # type: () -> Rot3 + def rotation(self) -> Rot3: return Rot3.from_storage(list(self.rotation_storage())) diff --git a/symforce/codegen/backends/python/templates/geo_package/custom_methods/rot2.py.jinja b/symforce/codegen/backends/python/templates/geo_package/custom_methods/rot2.py.jinja index 2a987be0..fd7cca08 100644 --- a/symforce/codegen/backends/python/templates/geo_package/custom_methods/rot2.py.jinja +++ b/symforce/codegen/backends/python/templates/geo_package/custom_methods/rot2.py.jinja @@ -6,15 +6,13 @@ {# Handwritten methods for Rot2 #} {# These will get included into the autogenerated class header. #} - def __init__(self, z=None): - # type: (T.Union[T.Sequence[float], numpy.ndarray, None]) -> None + def __init__(self, z: T.Union[T.Sequence[float], numpy.ndarray, None] = None) -> None: if z is None: - self.data = ops.GroupOps.identity().data # type: T.List[float] + self.data: T.List[float] = ops.GroupOps.identity().data else: {{ util.flatten_if_ndarray("z", 2) | indent(width=12) }} self.data = list(z) @classmethod - def random(cls): - # type: () -> Rot2 + def random(cls) -> Rot2: return Rot2.random_from_uniform_sample(random.uniform(0, 1)) diff --git a/symforce/codegen/backends/python/templates/geo_package/custom_methods/rot3.py.jinja b/symforce/codegen/backends/python/templates/geo_package/custom_methods/rot3.py.jinja index 4daf9ff9..5586703a 100644 --- a/symforce/codegen/backends/python/templates/geo_package/custom_methods/rot3.py.jinja +++ b/symforce/codegen/backends/python/templates/geo_package/custom_methods/rot3.py.jinja @@ -6,17 +6,15 @@ {# Handwritten methods for Rot3 #} {# These will get included into the autogenerated class header. #} - def __init__(self, q=None): - # type: (T.Union[T.Sequence[float], numpy.ndarray, None]) -> None + def __init__(self, q: T.Union[T.Sequence[float], numpy.ndarray, None] = None) -> None: if q is None: - self.data = ops.GroupOps.identity().data # type: T.List[float] + self.data: T.List[float] = ops.GroupOps.identity().data else: {{ util.flatten_if_ndarray("q", 4) | indent(width=12) }} self.data = list(q) @classmethod - def from_rotation_matrix(cls, R, epsilon=0.0): - # type: (numpy.ndarray, float) -> Rot3 + def from_rotation_matrix(cls, R: numpy.ndarray, epsilon: float = 0.0) -> Rot3: """ This implementation is based on Shepperd's method (1978) https://arc.aiaa.org/doi/abs/10.2514/3.55767b?journalCode=jgc (this is paywalled) @@ -56,8 +54,7 @@ return Rot3.from_storage([x, y, z, w]) @classmethod - def random(cls): - # type: () -> Rot3 + def random(cls) -> Rot3: return Rot3.random_from_uniform_samples( random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1) ) diff --git a/symforce/codegen/backends/python/templates/geo_package/custom_methods/unit3.py.jinja b/symforce/codegen/backends/python/templates/geo_package/custom_methods/unit3.py.jinja index b462f6b7..08b34eb2 100644 --- a/symforce/codegen/backends/python/templates/geo_package/custom_methods/unit3.py.jinja +++ b/symforce/codegen/backends/python/templates/geo_package/custom_methods/unit3.py.jinja @@ -6,14 +6,12 @@ {# Handwritten methods for Unit3 #} {# These will get included into the autogenerated class header. #} - def __init__(self, vec): - # type: (T.Union[T.Sequence[float], numpy.ndarray]) -> None + def __init__(self, vec: T.Union[T.Sequence[float], numpy.ndarray]) -> None: {{ util.flatten_if_ndarray("vec", 3) | indent(width=8) }} - self.data = list(vec) # type: T.List[float] + self.data: T.List[float] = list(vec) @classmethod - def random(cls, epsilon=1e-8): - # type: (float) -> Unit3 + def random(cls, epsilon: float = 1e-8) -> Unit3: """ Return a random :class:`Unit3` object """ diff --git a/symforce/codegen/backends/python/templates/ops/CLASS/group_ops.py.jinja b/symforce/codegen/backends/python/templates/ops/CLASS/group_ops.py.jinja index c5de95c2..f1d0aec3 100644 --- a/symforce/codegen/backends/python/templates/ops/CLASS/group_ops.py.jinja +++ b/symforce/codegen/backends/python/templates/ops/CLASS/group_ops.py.jinja @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -22,7 +24,6 @@ class GroupOps(object): {% for spec in specs['GroupOps'] %} @staticmethod {{ util.function_declaration(spec) }} - {{ util.expr_code(spec) | indent(4) }} {% endfor %} diff --git a/symforce/codegen/backends/python/templates/ops/CLASS/lie_group_ops.py.jinja b/symforce/codegen/backends/python/templates/ops/CLASS/lie_group_ops.py.jinja index 3f6e4248..64a1092a 100644 --- a/symforce/codegen/backends/python/templates/ops/CLASS/lie_group_ops.py.jinja +++ b/symforce/codegen/backends/python/templates/ops/CLASS/lie_group_ops.py.jinja @@ -6,6 +6,8 @@ # ruff: noqa: PLR0915, F401, PLW0211, PLR0914 +from __future__ import annotations + import math import typing as T @@ -22,7 +24,6 @@ class LieGroupOps(object): {% for spec in specs['LieGroupOps'] %} @staticmethod {{ util.function_declaration(spec) }} - {{ util.expr_code(spec) | indent(4) }} {% endfor %} diff --git a/symforce/codegen/backends/python/templates/util/util.jinja b/symforce/codegen/backends/python/templates/util/util.jinja index 4347ac4b..c3b799b4 100644 --- a/symforce/codegen/backends/python/templates/util/util.jinja +++ b/symforce/codegen/backends/python/templates/util/util.jinja @@ -111,11 +111,12 @@ {%- if is_method and "self" not in spec.inputs -%} @staticmethod {% endif %} -def {{ function_name_and_args(spec) }}: - # type: ( - {%- for name, type in spec.inputs.items() -%} - {{ format_typename(type, name, is_input=True, available_classes=available_classes) }}{% if not loop.last %}, {% endif %} - {%- endfor -%}) -> {{ get_return_type(spec, available_classes=available_classes) }} +def {{ spec.name }}( +{%- for name, type in spec.inputs.items() %} + {{ name }}: {{ format_typename(type, name, is_input=True, available_classes=available_classes) }}{% if not loop.last %},{% endif %} + +{%- endfor %} +) -> {{ get_return_type(spec, available_classes=available_classes) }}: {%- endmacro -%} {# ------------------------------------------------------------------------- #} diff --git a/test/symforce_function_codegen_test_data/symengine/az_el_from_point.py b/test/symforce_function_codegen_test_data/symengine/az_el_from_point.py index f8573e3e..feb0cc24 100644 --- a/test/symforce_function_codegen_test_data/symengine/az_el_from_point.py +++ b/test/symforce_function_codegen_test_data/symengine/az_el_from_point.py @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -14,8 +16,9 @@ import sym -def az_el_from_point(nav_T_cam, nav_t_point, epsilon): - # type: (sym.Pose3, numpy.ndarray, float) -> numpy.ndarray +def az_el_from_point( + nav_T_cam: sym.Pose3, nav_t_point: numpy.ndarray, epsilon: float +) -> numpy.ndarray: """ Transform a nav point into azimuth / elevation angles in the camera frame. diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_dataclass_in_values_test_data/python/symforce/codegen_test/codegen_dataclass_in_values_test.py b/test/symforce_function_codegen_test_data/symengine/codegen_dataclass_in_values_test_data/python/symforce/codegen_test/codegen_dataclass_in_values_test.py index 61fe88a5..7d3848f3 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_dataclass_in_values_test_data/python/symforce/codegen_test/codegen_dataclass_in_values_test.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_dataclass_in_values_test_data/python/symforce/codegen_test/codegen_dataclass_in_values_test.py @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -14,8 +16,7 @@ import sym -def codegen_dataclass_in_values_test(my_dataclass): - # type: (T.Any) -> sym.Rot3 +def codegen_dataclass_in_values_test(my_dataclass: T.Any) -> sym.Rot3: """ This function was autogenerated. Do not modify by hand. diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py b/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py index 60c0e4e1..93455a15 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -15,20 +17,21 @@ def python_function( - x, - y, - rot, - rot_vec, - scalar_vec, - list_of_lists, - values_vec, - values_vec_2D, - constants, - big_matrix, - small_matrix, - states, -): - # type: (float, float, sym.Rot3, T.Sequence[sym.Rot3], T.Sequence[float], T.Sequence[T.Sequence[sym.Rot3]], T.Sequence[T.Any], T.Sequence[T.Sequence[T.Any]], T.Any, numpy.ndarray, numpy.ndarray, T.Any) -> T.Tuple[float, float, T.List[float], T.List[float], T.List[float], numpy.ndarray, numpy.ndarray] + x: float, + y: float, + rot: sym.Rot3, + rot_vec: T.Sequence[sym.Rot3], + scalar_vec: T.Sequence[float], + list_of_lists: T.Sequence[T.Sequence[sym.Rot3]], + values_vec: T.Sequence[T.Any], + values_vec_2D: T.Sequence[T.Sequence[T.Any]], + constants: T.Any, + big_matrix: numpy.ndarray, + small_matrix: numpy.ndarray, + states: T.Any, +) -> T.Tuple[ + float, float, T.List[float], T.List[float], T.List[float], numpy.ndarray, numpy.ndarray +]: """ This function was autogenerated. Do not modify by hand. diff --git a/test/symforce_function_codegen_test_data/symengine/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py b/test/symforce_function_codegen_test_data/symengine/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py index e0be300f..55934ab7 100644 --- a/test/symforce_function_codegen_test_data/symengine/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py +++ b/test/symforce_function_codegen_test_data/symengine/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -14,8 +16,7 @@ import sym -def buffer_func(buffer, a, b): - # type: (numpy.ndarray, float, float) -> float +def buffer_func(buffer: numpy.ndarray, a: float, b: float) -> float: """ This function was autogenerated. Do not modify by hand. diff --git a/test/symforce_function_codegen_test_data/symengine/numba_test_func.py b/test/symforce_function_codegen_test_data/symengine/numba_test_func.py index b42578ab..cd952543 100644 --- a/test/symforce_function_codegen_test_data/symengine/numba_test_func.py +++ b/test/symforce_function_codegen_test_data/symengine/numba_test_func.py @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -16,8 +18,7 @@ @numba.njit -def numba_test_func(x): - # type: (numpy.ndarray) -> numpy.ndarray +def numba_test_func(x: numpy.ndarray) -> numpy.ndarray: """ This function was autogenerated from a symbolic function. Do not modify by hand. diff --git a/test/symforce_function_codegen_test_data/sympy/az_el_from_point.py b/test/symforce_function_codegen_test_data/sympy/az_el_from_point.py index ce12a703..c55a48ef 100644 --- a/test/symforce_function_codegen_test_data/sympy/az_el_from_point.py +++ b/test/symforce_function_codegen_test_data/sympy/az_el_from_point.py @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -14,8 +16,9 @@ import sym -def az_el_from_point(nav_T_cam, nav_t_point, epsilon): - # type: (sym.Pose3, numpy.ndarray, float) -> numpy.ndarray +def az_el_from_point( + nav_T_cam: sym.Pose3, nav_t_point: numpy.ndarray, epsilon: float +) -> numpy.ndarray: """ Transform a nav point into azimuth / elevation angles in the camera frame. diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_dataclass_in_values_test_data/python/symforce/codegen_test/codegen_dataclass_in_values_test.py b/test/symforce_function_codegen_test_data/sympy/codegen_dataclass_in_values_test_data/python/symforce/codegen_test/codegen_dataclass_in_values_test.py index 61fe88a5..7d3848f3 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_dataclass_in_values_test_data/python/symforce/codegen_test/codegen_dataclass_in_values_test.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_dataclass_in_values_test_data/python/symforce/codegen_test/codegen_dataclass_in_values_test.py @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -14,8 +16,7 @@ import sym -def codegen_dataclass_in_values_test(my_dataclass): - # type: (T.Any) -> sym.Rot3 +def codegen_dataclass_in_values_test(my_dataclass: T.Any) -> sym.Rot3: """ This function was autogenerated. Do not modify by hand. diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py b/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py index 60c0e4e1..93455a15 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -15,20 +17,21 @@ def python_function( - x, - y, - rot, - rot_vec, - scalar_vec, - list_of_lists, - values_vec, - values_vec_2D, - constants, - big_matrix, - small_matrix, - states, -): - # type: (float, float, sym.Rot3, T.Sequence[sym.Rot3], T.Sequence[float], T.Sequence[T.Sequence[sym.Rot3]], T.Sequence[T.Any], T.Sequence[T.Sequence[T.Any]], T.Any, numpy.ndarray, numpy.ndarray, T.Any) -> T.Tuple[float, float, T.List[float], T.List[float], T.List[float], numpy.ndarray, numpy.ndarray] + x: float, + y: float, + rot: sym.Rot3, + rot_vec: T.Sequence[sym.Rot3], + scalar_vec: T.Sequence[float], + list_of_lists: T.Sequence[T.Sequence[sym.Rot3]], + values_vec: T.Sequence[T.Any], + values_vec_2D: T.Sequence[T.Sequence[T.Any]], + constants: T.Any, + big_matrix: numpy.ndarray, + small_matrix: numpy.ndarray, + states: T.Any, +) -> T.Tuple[ + float, float, T.List[float], T.List[float], T.List[float], numpy.ndarray, numpy.ndarray +]: """ This function was autogenerated. Do not modify by hand. diff --git a/test/symforce_function_codegen_test_data/sympy/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py b/test/symforce_function_codegen_test_data/sympy/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py index 14ba4494..9791e6a2 100644 --- a/test/symforce_function_codegen_test_data/sympy/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py +++ b/test/symforce_function_codegen_test_data/sympy/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -14,8 +16,7 @@ import sym -def buffer_func(buffer, a, b): - # type: (numpy.ndarray, float, float) -> float +def buffer_func(buffer: numpy.ndarray, a: float, b: float) -> float: """ This function was autogenerated. Do not modify by hand. diff --git a/test/symforce_function_codegen_test_data/sympy/numba_test_func.py b/test/symforce_function_codegen_test_data/sympy/numba_test_func.py index b42578ab..cd952543 100644 --- a/test/symforce_function_codegen_test_data/sympy/numba_test_func.py +++ b/test/symforce_function_codegen_test_data/sympy/numba_test_func.py @@ -6,6 +6,8 @@ # ruff: noqa: F401, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917, RUF100 +from __future__ import annotations + import math import typing as T @@ -16,8 +18,7 @@ @numba.njit -def numba_test_func(x): - # type: (numpy.ndarray) -> numpy.ndarray +def numba_test_func(x: numpy.ndarray) -> numpy.ndarray: """ This function was autogenerated from a symbolic function. Do not modify by hand.