|
11 | 11 | import numpy.testing as nt |
12 | 12 |
|
13 | 13 | from spatialmath.base.argcheck import * |
| 14 | +from spatialmath.base.transformsNd import e2h, h2e |
14 | 15 |
|
15 | 16 |
|
16 | 17 | class Test_check(unittest.TestCase): |
@@ -212,10 +213,30 @@ def test_isvector(self): |
212 | 213 | self.assertFalse(isvector(np.array([[1, 2, 3]]), 4)) |
213 | 214 | self.assertFalse(isvector(np.array([[1], [2], [3]]), 4)) |
214 | 215 |
|
215 | | - def test_isvector(self): |
| 216 | + def test_assertvector(self): |
216 | 217 | l = [1, 2, 3] |
217 | 218 | nt.assert_raises(ValueError, assertvector, l, 4) |
218 | 219 |
|
| 220 | + def test_isvector_unsupported_array_shapes(self): |
| 221 | + for shape in [(), (2, 3), (1, 3, 2), (3, 1, 2), (1, 1, 1), (1, 3, 0)]: |
| 222 | + with self.subTest(shape=shape): |
| 223 | + value = np.ones(shape) |
| 224 | + self.assertFalse(isvector(value)) |
| 225 | + with self.assertRaises(ValueError): |
| 226 | + assertvector(value) |
| 227 | + |
| 228 | + def test_isvector_empty_arrays(self): |
| 229 | + for shape in [(0,), (1, 0), (0, 1), (0, 0)]: |
| 230 | + with self.subTest(shape=shape): |
| 231 | + self.assertFalse(isvector(np.empty(shape))) |
| 232 | + |
| 233 | + def test_homogeneous_conversion_unsupported_array_shapes(self): |
| 234 | + for convert in [e2h, h2e]: |
| 235 | + for shape in [(), (1, 3, 2), (3, 1, 2), (1, 1, 1)]: |
| 236 | + with self.subTest(convert=convert.__name__, shape=shape): |
| 237 | + with self.assertRaises(ValueError): |
| 238 | + convert(np.ones(shape)) |
| 239 | + |
219 | 240 | def test_getvector(self): |
220 | 241 | l = [1, 2, 3] |
221 | 242 | t = (1, 2, 3) |
|
0 commit comments