Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
# python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
python-version: [3.7, 3.8, 3.9, 3.11]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies = [
"Homepage" = "https://github.com/petercorke/spatialmath-python"
"Bug Tracker" = "https://github.com/petercorke/spatialmath-python/issues"
"Documentation" = "https://petercorke.github.io/petercorke/spatialmath-python"
"Source" = "https://github.com/petercorke/petercorke/spatialmath-python"
"Source" = "https://github.com/petercorke/spatialmath-python"

[project.optional-dependencies]

Expand Down
41 changes: 41 additions & 0 deletions tests/base/test_graphics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import unittest
import numpy as np
import matplotlib.pyplot as plt
import pytest
import sys
from spatialmath.base import *

# test graphics primitives
Expand All @@ -11,22 +13,37 @@ class TestGraphics(unittest.TestCase):
def teardown_method(self, method):
plt.close("all")

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plotvol2(self):
plotvol2(5)

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plotvol3(self):
plotvol3(5)

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plot_point(self):
plot_point((2, 3))
plot_point(np.r_[2, 3])
plot_point((2, 3), "x")
plot_point((2, 3), "x", text="foo")

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plot_text(self):
plot_text((2, 3), "foo")
plot_text(np.r_[2, 3], "foo")

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plot_box(self):
plot_box("r--", centre=(-2, -3), wh=(1, 1))
plot_box(lt=(1, 1), rb=(2, 0), filled=True, color="b")
Expand All @@ -36,38 +53,59 @@ def test_plot_box(self):
plot_box(lbwh=(1, 2, 3, 4))
plot_box(centre=(1, 2), wh=(2, 3))

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plot_circle(self):
plot_circle(1, (0, 0), "r") # red circle
plot_circle(2, (0, 0), "b--") # blue dashed circle
plot_circle(0.5, (0, 0), filled=True, color="y") # yellow filled circle

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_ellipse(self):
plot_ellipse(np.diag((1, 2)), (0, 0), "r") # red ellipse
plot_ellipse(np.diag((1, 2)), (0, 0), "b--") # blue dashed ellipse
plot_ellipse(
np.diag((1, 2)), centre=(1, 1), filled=True, color="y"
) # yellow filled ellipse

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plot_homline(self):
plot_homline((1, 2, 3))
plot_homline((2, 1, 3))
plot_homline((1, -2, 3), "k--")

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_cuboid(self):
plot_cuboid((1, 2, 3), color="g")
plot_cuboid((1, 2, 3), centre=(2, 3, 4), color="g")
plot_cuboid((1, 2, 3), filled=True, color="y")

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_sphere(self):
plot_sphere(0.3, color="r")
plot_sphere(1, centre=(1, 1, 1), filled=True, color="b")

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_ellipsoid(self):
plot_ellipsoid(np.diag((1, 2, 3)), color="r") # red ellipsoid
plot_ellipsoid(
np.diag((1, 2, 3)), centre=(1, 2, 3), filled=True, color="y"
) # yellow filled ellipsoid

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_cylinder(self):
plot_cylinder(radius=0.2, centre=(0.5, 0.5, 0), height=[-0.2, 0.2])
plot_cylinder(
Expand All @@ -79,6 +117,9 @@ def test_cylinder(self):
color="red",
)

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_cone(self):
plot_cone(radius=0.2, centre=(0.5, 0.5, 0), height=0.3)
plot_cone(
Expand Down
5 changes: 5 additions & 0 deletions tests/base/test_transforms2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from math import pi
import math
from scipy.linalg import logm, expm
import pytest
import sys

from spatialmath.base.transforms2d import *
from spatialmath.base.transformsNd import (
Expand Down Expand Up @@ -259,6 +261,9 @@ def test_trinterp2(self):
trinterp2(start=None, end=T1, s=0.5), xyt2tr([0.5, 1, 0.15])
)

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plot(self):
plt.figure()
trplot2(transl2(1, 2), block=False, frame="A", rviz=True, width=1)
Expand Down
15 changes: 7 additions & 8 deletions tests/base/test_transforms3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,20 +514,19 @@ def test_tr2angvec(self):
eps = 1e-08

# show that tr2angvec works on true rotation matrix
R = SO3.Ry(true_ang)
ang, vec = t3d.tr2angvec(R.A, check=True)
nt.assert_equal(ang, true_ang)
nt.assert_equal(vec, true_vec)
ang, vec = tr2angvec(roty(true_ang), check=True)
nt.assert_almost_equal(ang, true_ang)
nt.assert_almost_equal(vec, true_vec)

# check a rotation matrix that should fail
badR = SO3.Ry(true_ang).A[:, :] + eps
badR = roty(true_ang) + eps
with self.assertRaises(ValueError):
t3d.tr2angvec(badR, check=True)
tr2angvec(badR, check=True)

# run without check
ang, vec = t3d.tr2angvec(badR, check=False)
ang, vec = tr2angvec(badR, check=False)
nt.assert_almost_equal(ang, true_ang)
nt.assert_equal(vec, true_vec)
nt.assert_almost_equal(vec, true_vec)

def test_print(self):
R = rotx(0.3) @ roty(0.4)
Expand Down
8 changes: 8 additions & 0 deletions tests/base/test_transforms3d_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from math import pi
import math
from scipy.linalg import logm, expm
import pytest
import sys

from spatialmath.base.transforms3d import *
from spatialmath.base.transformsNd import isR, t2r, r2t, rt2tr
Expand All @@ -22,6 +24,9 @@


class Test3D(unittest.TestCase):
@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plot(self):
plt.figure()
# test options
Expand Down Expand Up @@ -65,6 +70,9 @@ def test_plot(self):

plt.close("all")

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_animate(self):
tranimate(transl(1, 2, 3), repeat=False, wait=True)

Expand Down
5 changes: 5 additions & 0 deletions tests/test_geom2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from spatialmath.pose2d import SE2

import unittest
import pytest
import sys
import numpy.testing as nt
import spatialmath.base as smb

Expand Down Expand Up @@ -85,6 +87,9 @@ def test_intersect_line(self):
l = Line2.Join((-10, 1.1), (10, 1.1))
self.assertFalse(p.intersects(l))

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plot(self):
p = Polygon2(np.array([[-1, 1, 1, -1], [-1, -1, 1, 1]]))
p.plot()
Expand Down
5 changes: 5 additions & 0 deletions tests/test_geom3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import unittest
import numpy.testing as nt
import spatialmath.base as base
import pytest
import sys


class Line3Test(unittest.TestCase):
Expand Down Expand Up @@ -123,6 +125,9 @@ def test_closest(self):
nt.assert_array_almost_equal(p, [5, 1, 2])
self.assertAlmostEqual(d, 2)

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_plot(self):
P = [2, 3, 7]
Q = [2, 1, 0]
Expand Down
7 changes: 7 additions & 0 deletions tests/test_pose2d.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy.testing as nt
import matplotlib.pyplot as plt
import unittest
import sys
import pytest

"""
we will assume that the primitives rotx,trotx, etc. all work
Expand Down Expand Up @@ -227,6 +229,7 @@ def test_printline(self):
# self.assertIsInstance(s, str)
# self.assertEqual(s.count('\n'), 2)

@pytest.mark.skipif(sys.platform.startswith("darwin"), reason="tkinter bug with mac")
def test_plot(self):
plt.close('all')

Expand Down Expand Up @@ -493,12 +496,16 @@ def test_display(self):

T1.printline()

@pytest.mark.skipif(
sys.platform.startswith("darwin"), reason="tkinter bug with mac"
)
def test_graphics(self):

plt.close('all')
T1 = SE2.Rand()
T2 = SE2.Rand()


T1.plot(block=False, dims=[-2,2])

T1.animate(repeat=False, dims=[-2,2], nframes=10)
Expand Down
14 changes: 7 additions & 7 deletions tests/test_pose3d.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import numpy.testing as nt
import matplotlib.pyplot as plt
import unittest
import sys
import pytest

"""
we will assume that the primitives rotx,trotx, etc. all work
"""
from math import pi
from spatialmath import SE3, SO3, SE2
import numpy as np
# from spatialmath import super_pose as sp
from spatialmath.base import *
from spatialmath.base import argcheck
import spatialmath as sm
from spatialmath.baseposematrix import BasePoseMatrix
from spatialmath.twist import BaseTwist

Expand Down Expand Up @@ -225,21 +224,21 @@ def test_constructor_TwoVec(self):
# x and y given
R = SO3.TwoVectors(x=v1, y=v2)
self.assertIsInstance(R, SO3)
nt.assert_almost_equal(np.linalg.det(R), 1, 5)
nt.assert_almost_equal(R.det(), 1, 5)
# x axis should equal normalized x vector
nt.assert_almost_equal(R.R[:, 0], v1 / np.linalg.norm(v1), 5)

# y and z given
R = SO3.TwoVectors(y=v2, z=v3)
self.assertIsInstance(R, SO3)
nt.assert_almost_equal(np.linalg.det(R), 1, 5)
nt.assert_almost_equal(R.det(), 1, 5)
# y axis should equal normalized y vector
nt.assert_almost_equal(R.R[:, 1], v2 / np.linalg.norm(v2), 5)

# x and z given
R = SO3.TwoVectors(x=v3, z=v1)
self.assertIsInstance(R, SO3)
nt.assert_almost_equal(np.linalg.det(R), 1, 5)
nt.assert_almost_equal(R.det(), 1, 5)
# x axis should equal normalized x vector
nt.assert_almost_equal(R.R[:, 0], v3 / np.linalg.norm(v3), 5)

Expand Down Expand Up @@ -274,7 +273,8 @@ def test_printline(self):
s = R.printline(file=None)
# self.assertIsInstance(s, str)
# self.assertEqual(s.count('\n'), 2)


@pytest.mark.skipif(sys.platform.startswith("darwin"), reason="tkinter bug with mac")
def test_plot(self):
plt.close('all')

Expand Down
Empty file removed zz
Empty file.