8000 fix issues detected by LGTM · mzahana/spatialmath-python@5e4f3d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e4f3d7

Browse files
committed
fix issues detected by LGTM
1 parent 4625ee8 commit 5e4f3d7

File tree

8 files changed

+67
-77
lines changed

8 files changed

+67
-77
lines changed

spatialmath/DualQuaternion.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,20 +302,16 @@ def __init__(self, real=None, dual=None):
302302
and :math:`q_t` is a pure quaternion formed from the translational part
303303
:math:`t`.
304304
"""
305-
if real is None and dual is None:
306-
self.real = None
307-
self.dual = None
308-
return
309-
elif real is not None and dual is not None:
310-
self.real = real # quaternion, real part
311-
self.dual = dual # quaternion, dual part
312-
elif dual is None and isinstance(real, SE3):
305+
306+
if dual is None and isinstance(real, SE3):
313307
T = real
314308
S = UnitQuaternion(T.R)
315309
D = Quaternion.Pure(T.t)
316310

317-
self.real = S
318-
self.dual = 0.5 * D * S
311+
real = S
312+
dual = 0.5 * D * S
313+
314+
super().__init__(real, dual)
319315

320316
def SE3(self):
321317
"""
@@ -347,6 +343,9 @@ def SE3(self):
347343

348344
if __name__ == "__main__": # pragma: no cover
349345

350-
import pathlib
346+
from spatialmath import SE3, UnitDualQuaternion, DualQuaternion
347+
348+
print(UnitDualQuaternion(SE3()))
349+
# import pathlib
351350

352-
exec(open(pathlib.Path(__file__).parent.parent.absolute() / "tests" / "test_dualquaternion.py").read()) # pylint: disable=exec-used
351+
# exec(open(pathlib.Path(__file__).parent.parent.absolute() / "tests" / "test_dualquaternion.py").read()) # pylint: disable=exec-used

spatialmath/base/animate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,8 @@ def set_ylabel(self, *args, **kwargs):
818818

819819
from spatialmath import base
820820

821-
T = base.rpy2r(0.3, 0.4, 0.5)
821+
# T = base.rpy2r(0.3, 0.4, 0.5)
822822
# base.tranimate(T, wait=True)
823823

824824
T = base.rot2(2)
825825
base.tranimate2(T, wait=True)
826-
pass

spatialmath/base/graphics.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import math
22
from itertools import product
3-
from collections.abc import Iterable
43
import warnings
54
import numpy as np
65
import scipy as sp
@@ -1097,10 +1096,10 @@ def _render3D(ax, X, Y, Z, pose=None, filled=False, color=None, **kwargs):
10971096
X, Y, Z = np.squeeze(np.dsplit(xyz.T.reshape(X.shape + (3,)), 3))
10981097

10991098
if filled:
1100-
ax.plot_surface(X, Y, Z, color=color, **kwargs)
1099+
return ax.plot_surface(X, Y, Z, color=color, **kwargs)
11011100
else:
11021101
kwargs["colors"] = color
1103-
ax.plot_wireframe(X, Y, Z, **kwargs)
1102+
return ax.plot_wireframe(X, Y, Z, **kwargs)
11041103

11051104

11061105
def _axes_dimensions(ax):

spatialmath/base/transforms3d.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,8 +3049,7 @@ def tranimate(T, **kwargs):
30493049
:seealso: `trplot`, `plotvol3`
30503050
"""
30513051

3052-
block = kwargs.get("block", False)
3053-
kwargs["block"] = False
3052+
kwargs["block"] = kwargs.get("block", False)
30543053

30553054
anim = smb.animate.Animate(**kwargs)
30563055
try:

spatialmath/baseposematrix.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,8 +1076,8 @@ def __pow__(self, n):
10761076
# ----------------------- arithmetic
10771077

10781078
def __mul__(
1079-
left, right
1080-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1079+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1080+
):
10811081
"""
10821082
Overloaded ``*`` operator (superclass method)
10831083
@@ -1244,8 +1244,8 @@ def __mul__(
12441244
return NotImplemented
12451245

12461246
def __matmul__(
1247-
left, right
1248-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1247+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1248+
):
12491249
"""
12501250
Overloaded ``@`` operator (superclass method)
12511251
@@ -1272,8 +1272,8 @@ def __matmul__(
12721272
raise TypeError("@ only applies to pose composition")
12731273

12741274
def __rmul__(
1275-
right, left
1276-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1275+
right, left # lgtm[py/not-named-self] pylint: disable=no-self-argument
1276+
):
12771277
"""
12781278
Overloaded ``*`` operator (superclass method)
12791279
@@ -1300,8 +1300,8 @@ def __rmul__(
13001300
return right.__mul__(left)
13011301

13021302
def __imul__(
1303-
left, right
1304-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1303+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1304+
):
13051305
"""
13061306
Overloaded ``*=`` operator (superclass method)
13071307
@@ -1318,8 +1318,8 @@ def __imul__(
13181318
return left.__mul__(right)
13191319

13201320
def __truediv__(
1321-
left, right
1322-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1321+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1322+
):
13231323
"""
13241324
Overloaded ``/`` operator (superclass method)
13251325
@@ -1373,8 +1373,8 @@ def __truediv__(
13731373
raise ValueError("bad operands")
13741374

13751375
def __itruediv__(
1376-
left, right
1377-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1376+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1377+
):
13781378
"""
13791379
Overloaded ``/=`` operator (superclass method)
13801380
@@ -1391,8 +1391,8 @@ def __itruediv__(
13911391
return left.__truediv__(right)
13921392

13931393
def __add__(
1394-
left, right
1395-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1394+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1395+
):
13961396
"""
13971397
Overloaded ``+`` operator (superclass method)
13981398
@@ -1443,8 +1443,8 @@ def __add__(
14431443
return left._op2(right, lambda x, y: x + y)
14441444

14451445
def __radd__(
1446-
left, right
1447-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1446+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1447+
):
14481448
"""
14491449
Overloaded ``+`` operator (superclass method)
14501450
@@ -1461,8 +1461, F987 8 @@ def __radd__(
14611461
return left.__add__(right)
14621462

14631463
def __iadd__(
1464-
left, right
1465-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1464+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1465+
):
14661466
"""
14671467
Overloaded ``+=`` operator (superclass method)
14681468
@@ -1479,8 +1479,8 @@ def __iadd__(
14791479
return left.__add__(right)
14801480

14811481
def __sub__(
1482-
left, right
1483-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1482+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1483+
):
14841484
"""
14851485
Overloaded ``-`` operator (superclass method)
14861486
@@ -1531,8 +1531,8 @@ def __sub__(
15311531
return left._op2(right, lambda x, y: x - y)
15321532

15331533
def __rsub__(
1534-
left, right
1535-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1534+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1535+
):
15361536
"""
15371537
Overloaded ``-`` operator (superclass method)
15381538
@@ -1549,8 +1549,8 @@ def __rsub__(
15491549
return -left.__sub__(right)
15501550

15511551
def __isub__(
1552-
left, right
1553-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1552+
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1553+
):
15541554
"""
15551555
Overloaded ``-=`` operator (superclass method)
15561556
@@ -1624,8 +1624,8 @@ def __ne__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argu
16241624
return (not eq if isinstance(eq, bool) else [not x for x in eq])
16251625

16261626
def _op2(
1627-
left, right, op
1628-
): # lgtm[py/not-named-self] pylint: disable=no-self-argument
1627+
left, right, op # lgtm[py/not-named-self] pylint: disable=no-self-argument
1628+
):
16291629
"""
16301630
Perform binary operation
16311631

spatialmath/geom3d.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import spatialmath.base as base
1010
from spatialmath import SE3
1111
from spatialmath.baseposelist import BasePoseList
12-
from itertools import product
1312

1413
_eps = np.finfo(np.float64).eps
1514

@@ -564,7 +563,7 @@ def contains(self, x, tol=50*_eps):
564563
else:
565564
raise ValueError('bad argument')
566565

567-
def __eq__(l1, l2): # pylint: disable=no-self-argument
566+
def __eq__(l1, l2): # lgtm[py/not-named-self] pylint: disable=no-self-argument
568567
"""
569568
Test if two lines are equivalent
570569
@@ -581,7 +580,7 @@ def __eq__(l1, l2): # pylint: disable=no-self-argument
581580
"""
582581
return abs( 1 - np.dot(base.unitvec(l1.vec), base.unitvec(l2.vec))) < 10*_eps
583582

584-
def __ne__(l1, l2): # pylint: disable=no-self-argument
583+
def __ne__(l1, l2): # lgtm[py/not-named-self] pylint: disable=no-self-argument
585584
"""
586585
Test if two lines are not equivalent
587586
@@ -598,7 +597,7 @@ def __ne__(l1, l2): # pylint: disable=no-self-argument
598597
"""
599598
return not l1.__eq__(l2)
600599

601-
def isparallel(l1, l2, tol=10*_eps): # pylint: disable=no-self-argument
600+
def isparallel(l1, l2, tol=10*_eps): # lgtm[py/not-named-self] pylint: disable=no-self-argument
602601
"""
603602
Test if lines are parallel
604603
@@ -616,7 +615,7 @@ def isparallel(l1, l2, tol=10*_eps): # pylint: disable=no-self-argument
616615
return np.linalg.norm(np.cross(l1.w, l2.w) ) < tol
617616

618617

619-
def __or__(l1, l2): # pylint: disable=no-self-argument
618+
def __or__(l1, l2): # lgtm[py/not-named-self] pylint: disable=no-self-argument
620619
"""
621620
Overloaded ``|`` operator tests for parallelism
622621
@@ -633,7 +632,7 @@ def __or__(l1, l2): # pylint: disable=no-self-argument
633632
"""
634633
return l1.isparallel(l2)
635634

636-
def __xor__(l1, l2): # pylint: disable=no-self-argument
635+
def __xor__(l1, l2): # lgtm[py/not-named-self] pylint: disable=no-self-argument
637636

638637
"""
639638
Overloaded ``^`` operator tests for intersection
@@ -660,7 +659,7 @@ def __xor__(l1, l2): # pylint: disable=no-self-argument
660659
# ------------------------------------------------------------------------- #
661660

662661

663-
def intersects(l1, l2): # pylint: disable=no-self-argument
662+
def intersects(l1, l2): # lgtm[py/not-named-self] pylint: disable=no-self-argument
664663
"""
665664
Intersection point of two lines
666665
@@ -683,7 +682,7 @@ def intersects(l1, l2): # pylint: disable=no-self-argument
683682
# lines don't intersect
684683
return None
685684

686-
def distance(l1, l2): # pylint: disable=no-self-argument
685+
def distance(l1, l2): # lgtm[py/not-named-self] pylint: disable=no-self-argument
687686
"""
688687
Minimum distance between lines
689688
@@ -836,7 +835,7 @@ def closest_to_point(self, x):
836835
return p, d
837836

838837

839-
def commonperp(l1, l2): # pylint: disable=no-self-argument
838+
def commonperp(l1, l2): # lgtm[py/not-named-self] pylint: disable=no-self-argument
840839
"""
841840
Common perpendicular to two lines
842841
@@ -862,7 +861,7 @@ def commonperp(l1, l2): # pylint: disable=no-self-argument
862861
return l1.__class__(v, w)
863862

864863

865-
def __mul__(left, right): # pylint: disable=no-self-argument
864+
def __mul__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
866865
r"""
867866
Reciprocal product
868867
@@ -888,7 +887,7 @@ def __mul__(left, right): # pylint: disable=no-self-argument
888887
else:
889888
raise ValueError('bad arguments')
890889

891-
def __rmul__(right, left): # pylint: disable=no-self-argument
890+
def __rmul__(right, left): # lgtm[py/not-named-self] pylint: disable=no-self-argument
892891
"""
893892
Rigid-body transformation of 3D line
894893
@@ -913,7 +912,7 @@ def __rmul__(right, left): # pylint: disable=no-self-argument
913912
# PLUCKER LINE DISTANCE AND INTERSECTION
914913
# ------------------------------------------------------------------------- #
915914

916-
def intersect_plane(self, plane): # pylint: disable=no-self-argument
915+
def intersect_plane(self, plane): # lgtm[py/not-named-self] pylint: disable=no-self-argument
917916
r"""
918917
Line intersection with a plane
919918
@@ -1193,8 +1192,6 @@ def __init__(self, v=None, w=None):
11931192
import pathlib
11941193
import os.path
11951194

1196-
from spatialmath import Twist3
1197-
11981195
L = Line3.TwoPoints((1,2,0), (1,2,1))
11991196
print(L)
12001197
print(L.intersect_plane([0, 0, 1, 0]))
@@ -1220,7 +1217,6 @@ def __init__(self, v=None, w=None):
12201217
print(L2)
12211218
print(L2.intersect_plane([0, 0, 1, 0]))
12221219

1223-
pass
12241220
# base.plotvol3(10)
12251221
# S = Twist3.UnitRevolute([0, 0, 1], [2, 3, 2], 0.5);
12261222
# L = S.line()

0 commit comments

Comments
 (0)
0