Skip to content

Commit ccf5661

Browse files
committed
Fix more LGTM alerts
1 parent 2c5856a commit ccf5661

File tree

9 files changed

+48
-84
lines changed

9 files changed

+48
-84
lines changed

spatialmath/DualQuaternion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def SE3(self):
343343

344344
if __name__ == "__main__": # pragma: no cover
345345

346-
from spatialmath import SE3, UnitDualQuaternion, DualQuaternion
346+
from spatialmath import SE3, UnitDualQuaternion
347347

348348
print(UnitDualQuaternion(SE3()))
349349
# import pathlib

spatialmath/base/animate.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
import numpy as np
1313
import matplotlib.pyplot as plt
1414
from matplotlib import animation
15-
from numpy.lib.arraysetops import isin
1615
from spatialmath import base
17-
from collections.abc import Iterable, Generator, Iterator
18-
import time
16+
from collections.abc import Iterable, Iterator
1917

2018
# global variable holds reference to FuncAnimation object, this is essential
2119
# for animatiion to work

spatialmath/base/graphics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def plot_text(pos, text=None, ax=None, color=None, **kwargs):
7171
if ax is None:
7272
ax = plt.gca()
7373

74-
handle = plt.text(pos[0], pos[1], text, color=color, **kwargs)
74+
handle = ax.text(pos[0], pos[1], text, color=color, **kwargs)
7575
return [handle]
7676

7777

@@ -168,9 +168,9 @@ def plot_point(pos, marker="bs", text=None, ax=None, textargs=None, textcolor=No
168168
handles = []
169169
if isinstance(marker, (list, tuple)):
170170
for m in marker:
171-
handles.append(plt.plot(x, y, m, **kwargs))
171+
handles.append(ax.plot(x, y, m, **kwargs))
172172
else:
173-
handles.append(plt.plot(x, y, marker, **kwargs))
173+
handles.append(ax.plot(x, y, marker, **kwargs))
174174
if text is not None:
175175
try:
176176
xy = zip(x, y)
@@ -179,11 +179,11 @@ def plot_point(pos, marker="bs", text=None, ax=None, textargs=None, textcolor=No
179179
if isinstance(text, str):
180180
# simple string, but might have format chars
181181
for i, (x, y) in enumerate(xy):
182-
handles.append(plt.text(x, y, " " + text.format(i), **textopts))
182+
handles.append(ax.text(x, y, " " + text.format(i), **textopts))
183183
elif isinstance(text, (tuple, list)):
184184
for i, (x, y) in enumerate(xy):
185185
handles.append(
186-
plt.text(
186+
ax.text(
187187
x,
188188
y,
189189
" " + text[0].format(i, *[d[i] for d in text[1:]]),

spatialmath/base/numeric.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22
from spatialmath import base
3-
from functools import reduce
43

54
# this is a collection of useful algorithms, not otherwise categorized
65

@@ -176,8 +175,6 @@ def bresenham(p0, p1, array=None):
176175

177176
if array is not None:
178177
_ = array[y0, x0] + array[y1, x1]
179-
180-
line = []
181178

182179
dx = x1 - x0
183180
dy = y1 - y0

spatialmath/base/symbolic.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
try: # pragma: no cover
1717
# print('Using SymPy')
1818
import sympy
19-
from sympy import S
2019

2120
_symbolics = True
2221
symtype = (sympy.Expr,)
@@ -197,7 +196,7 @@ def zero():
197196
198197
:seealso: :func:`sympy.S.Zero`
199198
"""
200-
return S.Zero
199+
return sympy.S.Zero
201200

202201

203202
def one():
@@ -216,7 +215,7 @@ def one():
216215
217216
:seealso: :func:`sympy.S.One`
218217
"""
219-
return S.One
218+
return sympy.S.One
220219

221220

222221
def negative_one():
@@ -235,7 +234,7 @@ def negative_one():
235234
236235
:seealso: :func:`sympy.S.NegativeOne`
237236
"""
238-
return S.NegativeOne
237+
return sympy.S.NegativeOne
239238

240239

241240
def pi():
@@ -254,7 +253,7 @@ def pi():
254253
255254
:seealso: :func:`sympy.S.Pi`
256255
"""
257-
return S.Pi
256+
return sympy.S.Pi
258257

259258

260259
def simplify(x):

spatialmath/base/transforms2d.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,6 @@ def points2tr2(p1, p2):
783783
# hack below to use points2tr above
784784
# use ClayFlannigan's improved data association
785785
from scipy.spatial import KDTree
786-
import numpy as np
787786

788787
# reference or target 2xN
789788
# source 2xN

spatialmath/baseposematrix.py

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import spatialmath.base as base
1717
from spatialmath.baseposelist import BasePoseList
18-
from spatialmath.base import symbolic as sym
1918

2019
_eps = np.finfo(np.float64).eps
2120

@@ -572,7 +571,7 @@ def simplify(self):
572571
:SymPy: supported
573572
"""
574573

575-
vf = np.vectorize(sym.simplify)
574+
vf = np.vectorize(base.sym.simplify)
576575
return self.__class__([vf(x) for x in self.data], check=False)
577576

578577
def stack(self):
@@ -904,7 +903,7 @@ def mformat(self, X):
904903
rowstr = " "
905904
# format the columns
906905
for colnum, element in enumerate(row):
907-
if sym.issymbol(element):
906+
if base.sym.issymbol(element):
908907
s = "{:<12s}".format(str(element))
909908
else:
910909
if (
@@ -1075,9 +1074,7 @@ def __pow__(self, n):
10751074

10761075
# ----------------------- arithmetic
10771076

1078-
def __mul__(
1079-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1080-
):
1077+
def __mul__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
10811078
"""
10821079
Overloaded ``*`` operator (superclass method)
10831080
@@ -1243,9 +1240,7 @@ def __mul__(
12431240
else:
12441241
return NotImplemented
12451242

1246-
def __matmul__(
1247-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1248-
):
1243+
def __matmul__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
12491244
"""
12501245
Overloaded ``@`` operator (superclass method)
12511246
@@ -1271,9 +1266,7 @@ def __matmul__(
12711266
else:
12721267
raise TypeError("@ only applies to pose composition")
12731268

1274-
def __rmul__(
1275-
right, left # lgtm[py/not-named-self] pylint: disable=no-self-argument
1276-
):
1269+
def __rmul__(right, left): # lgtm[py/not-named-self] pylint: disable=no-self-argument
12771270
"""
12781271
Overloaded ``*`` operator (superclass method)
12791272
@@ -1299,9 +1292,7 @@ def __rmul__(
12991292
# return NotImplemented
13001293
return right.__mul__(left)
13011294

1302-
def __imul__(
1303-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1304-
):
1295+
def __imul__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
13051296
"""
13061297
Overloaded ``*=`` operator (superclass method)
13071298
@@ -1317,9 +1308,7 @@ def __imul__(
13171308
"""
13181309
return left.__mul__(right)
13191310

1320-
def __truediv__(
1321-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1322-
):
1311+
def __truediv__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
13231312
"""
13241313
Overloaded ``/`` operator (superclass method)
13251314
@@ -1372,9 +1361,7 @@ def __truediv__(
13721361
else:
13731362
raise ValueError("bad operands")
13741363

1375-
def __itruediv__(
1376-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1377-
):
1364+
def __itruediv__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
13781365
"""
13791366
Overloaded ``/=`` operator (superclass method)
13801367
@@ -1390,9 +1377,7 @@ def __itruediv__(
13901377
"""
13911378
return left.__truediv__(right)
13921379

1393-
def __add__(
1394-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1395-
):
1380+
def __add__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
13961381
"""
13971382
Overloaded ``+`` operator (superclass method)
13981383
@@ -1442,9 +1427,7 @@ def __add__(
14421427
# results is not in the group, return an array, not a class
14431428
return left._op2(right, lambda x, y: x + y)
14441429

1445-
def __radd__(
1446-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1447-
):
1430+
def __radd__(right, left): # lgtm[py/not-named-self] pylint: disable=no-self-argument
14481431
"""
14491432
Overloaded ``+`` operator (superclass method)
14501433
@@ -1458,11 +1441,9 @@ def __radd__(
14581441
14591442
:seealso: :meth:`__add__`
14601443
"""
1461-
return left.__add__(right)
1444+
return right.__add__(left)
14621445

1463-
def __iadd__(
1464-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1465-
):
1446+
def __iadd__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
14661447
"""
14671448
Overloaded ``+=`` operator (superclass method)
14681449
@@ -1478,9 +1459,7 @@ def __iadd__(
14781459
"""
14791460
return left.__add__(right)
14801461

1481-
def __sub__(
1482-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1483-
):
1462+
def __sub__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
14841463
"""
14851464
Overloaded ``-`` operator (superclass method)
14861465
@@ -1530,9 +1509,7 @@ def __sub__(
15301509
# TODO allow class +/- a conformant array
15311510
return left._op2(right, lambda x, y: x - y)
15321511

1533-
def __rsub__(
1534-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1535-
):
1512+
def __rsub__(right, left): # lgtm[py/not-named-self] pylint: disable=no-self-argument
15361513
"""
15371514
Overloaded ``-`` operator (superclass method)
15381515
@@ -1546,11 +1523,9 @@ def __rsub__(
15461523
15471524
:seealso: :meth:`__sub__`
15481525
"""
1549-
return -left.__sub__(right)
1526+
return -right.__sub__(left)
15501527

1551-
def __isub__(
1552-
left, right # lgtm[py/not-named-self] pylint: disable=no-self-argument
1553-
):
1528+
def __isub__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
15541529
"""
15551530
Overloaded ``-=`` operator (superclass method)
15561531
@@ -1623,9 +1598,7 @@ def __ne__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argu
16231598
eq = left == right
16241599
return (not eq if isinstance(eq, bool) else [not x for x in eq])
16251600

1626-
def _op2(
1627-
left, right, op # lgtm[py/not-named-self] pylint: disable=no-self-argument
1628-
):
1601+
def _op2(left, right, op): # lgtm[py/not-named-self] pylint: disable=no-self-argument
16291602
"""
16301603
Perform binary operation
16311604

spatialmath/geom2d.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
@author: corkep
77
"""
88
from functools import reduce
9-
from spatialmath.base.graphics import axes_logic
109
from spatialmath import base, SE2
1110
import matplotlib.pyplot as plt
1211
from matplotlib.path import Path
1312
from matplotlib.patches import PathPatch
1413
from matplotlib.transforms import Affine2D
15-
from matplotlib.collections import PatchCollection
1614
import numpy as np
1715

1816

spatialmath/geom3d.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,30 +1192,30 @@ def __init__(self, v=None, w=None):
11921192
import pathlib
11931193
import os.path
11941194

1195-
L = Line3.TwoPoints((1,2,0), (1,2,1))
1196-
print(L)
1197-
print(L.intersect_plane([0, 0, 1, 0]))
1195+
# L = Line3.TwoPoints((1,2,0), (1,2,1))
1196+
# print(L)
1197+
# print(L.intersect_plane([0, 0, 1, 0]))
11981198

1199-
z = np.eye(6) * L
1199+
# z = np.eye(6) * L
12001200

1201-
L2 = SE3(2, 1, 10) * L
1202-
print(L2)
1203-
print(L2.intersect_plane([0, 0, 1, 0]))
1201+
# L2 = SE3(2, 1, 10) * L
1202+
# print(L2)
1203+
# print(L2.intersect_plane([0, 0, 1, 0]))
12041204

1205-
print('rx')
1206-
L2 = SE3.Rx(np.pi/4) * L
1207-
print(L2)
1208-
print(L2.intersect_plane([0, 0, 1, 0]))
1205+
# print('rx')
1206+
# L2 = SE3.Rx(np.pi/4) * L
1207+
# print(L2)
1208+
# print(L2.intersect_plane([0, 0, 1, 0]))
12091209

1210-
print('ry')
1211-
L2 = SE3.Ry(np.pi/4) * L
1212-
print(L2)
1213-
print(L2.intersect_plane([0, 0, 1, 0]))
1210+
# print('ry')
1211+
# L2 = SE3.Ry(np.pi/4) * L
1212+
# print(L2)
1213+
# print(L2.intersect_plane([0, 0, 1, 0]))
12141214

1215-
print('rz')
1216-
L2 = SE3.Rz(np.pi/4) * L
1217-
print(L2)
1218-
print(L2.intersect_plane([0, 0, 1, 0]))
1215+
# print('rz')
1216+
# L2 = SE3.Rz(np.pi/4) * L
1217+
# print(L2)
1218+
# print(L2.intersect_plane([0, 0, 1, 0]))
12191219

12201220
# base.plotvol3(10)
12211221
# S = Twist3.UnitRevolute([0, 0, 1], [2, 3, 2], 0.5);
@@ -1229,4 +1229,4 @@ def __init__(self, v=None, w=None):
12291229

12301230
# a = SE3.Exp([2,0,0,0,0,0])
12311231

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

0 commit comments

Comments
 (0)