37from visp.core
import ArrayDouble2D, RotationMatrix, Matrix, HomogeneousMatrix, PoseVector, ColVector, RowVector
54 with pytest.raises(RuntimeError):
56 with pytest.raises(RuntimeError):
61 assert m.getRows() == a.shape[0]
and m.getCols() == a.shape[1]
63 with pytest.raises(RuntimeError):
69 assert v.getRows() == a.shape[0]
75 assert v.getCols() == a.shape[0]
99 n_invalid = np.array([1, 2, 3])
100 with pytest.raises(RuntimeError):
101 a = ArrayDouble2D(n_invalid)
102 n_valid = np.array([[1, 2, 3], [4, 5, 6]])
103 a = ArrayDouble2D(n_valid)
104 assert np.all(np.equal(a.numpy(), n_valid))
161 a = ArrayDouble2D(h, w, 5)
171 for i
in range(a.getCols()):
177 for i
in range(a.getRows()):
178 for j
in range(a.getCols()):
184 for i
in range(a.getRows()):
185 v = 5
if i % 2 == 1
else 20
186 for j
in range(a.getCols()):
191 for i
in range(a.getRows()):
192 v = 5
if i % 2 == 1
or i >= a.getRows() - 2
or i < 2
else 20
193 for j
in range(a.getCols()):
197 for i
in range(a.getRows()):
198 for j
in range(a.getCols()):
203 for i
in range(a.getRows()):
204 is_v = i >= 2
and i % 2 == 0
and i < a.getRows() - 2
205 for j
in range(a.getCols()):
206 is_vj = is_v
and j >= 3
and j < a.getCols() - 3
207 v = 20
if is_vj
else 5
213 with pytest.raises(RuntimeError):
215 with pytest.raises(RuntimeError):
219 with pytest.raises(RuntimeError):
221 with pytest.raises(RuntimeError):
225 a = ArrayDouble2D(h, w, 0.0)
226 single_row = np.ones((w, ), dtype=np.double) * 20
229 assert not np.any(np.equal(a.numpy()[list(set(range(h)) - {2})], single_row))
230 assert np.all(np.equal(a.numpy()[2], single_row))
234 assert np.all(np.equal(a.numpy()[list(set(range(h)) - {0, h - 2, h - 1})], single_row))
235 assert np.all(np.equal(a.numpy()[[0, h - 2, h - 1]], 0))
237 multi_rows = np.asarray([[i * w + j
for j
in range(w)]
for i
in range(h - 5)])
240 assert np.all(np.equal(a.numpy()[:-5], multi_rows))