Skip to content

Commit

Permalink
Import self from typing extensions for compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
jhavl committed Jun 26, 2024
1 parent e9ff465 commit baa2fd3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
6 changes: 4 additions & 2 deletions spatialmath/baseposelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import copy
import numpy as np
from spatialmath.base.argcheck import isnumberlist, isscalar
from typing_extensions import Self
from spatialmath.base.types import *

_numtypes = (int, np.int64, float, np.float64)
Expand Down Expand Up @@ -667,11 +668,12 @@ def unop(
else:
return [op(x) for x in self.data]


if __name__ == "__main__":
from spatialmath import SO3, SO2

R = SO3([[1,0,0],[0,1,0],[0,0,1]])
R = SO3([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
print(R.eulervec())

R = SO2([0.3, 0.4, 0.5])
pass
pass
18 changes: 15 additions & 3 deletions spatialmath/baseposematrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# _symbolics = False

import spatialmath.base as smb
from typing_extensions import Self
from spatialmath.base.types import *
from spatialmath.baseposelist import BasePoseList

Expand Down Expand Up @@ -377,7 +378,12 @@ def log(self, twist: Optional[bool] = False) -> Union[NDArray, List[NDArray]]:
else:
return log

def interp(self, end: Optional[bool] = None, s: Union[int, float] = None, shortest: bool = True) -> Self:
def interp(
self,
end: Optional[bool] = None,
s: Union[int, float] = None,
shortest: bool = True,
) -> Self:
"""
Interpolate between poses (superclass method)
Expand Down Expand Up @@ -434,13 +440,19 @@ def interp(self, end: Optional[bool] = None, s: Union[int, float] = None, shorte
if self.N == 2:
# SO(2) or SE(2)
return self.__class__(
[smb.trinterp2(start=self.A, end=end, s=_s, shortest=shortest) for _s in s]
[
smb.trinterp2(start=self.A, end=end, s=_s, shortest=shortest)
for _s in s
]
)

elif self.N == 3:
# SO(3) or SE(3)
return self.__class__(
[smb.trinterp(start=self.A, end=end, s=_s, shortest=shortest) for _s in s]
[
smb.trinterp(start=self.A, end=end, s=_s, shortest=shortest)
for _s in s
]
)

def interp1(self, s: float = None) -> Self:
Expand Down
1 change: 1 addition & 0 deletions spatialmath/geom2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""
from __future__ import annotations

from typing_extensions import Self
from functools import reduce
import warnings
import matplotlib.pyplot as plt
Expand Down
3 changes: 2 additions & 1 deletion spatialmath/geom3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
)
from spatialmath.baseposelist import BasePoseList
import warnings
from typing import Union, Tuple, Optional, List, cast, overload, Self
from typing import Union, Tuple, Optional, List, cast, overload
from typing_extensions import Self
from numpy.typing import NDArray

_eps = np.finfo(np.float64).eps
Expand Down
3 changes: 2 additions & 1 deletion spatialmath/pose3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
from spatialmath.baseposematrix import BasePoseMatrix
from spatialmath.pose2d import SE2
from spatialmath.twist import Twist3
from typing import TYPE_CHECKING, List, Tuple, Union, overload, Self, Optional, cast
from typing import TYPE_CHECKING, List, Tuple, Union, overload, Optional, cast
from typing_extensions import Self
from numpy.typing import NDArray

if TYPE_CHECKING:
Expand Down

0 comments on commit baa2fd3

Please sign in to comment.