()
| 220 | |
| 221 | |
| 222 | def test_stack_error(): |
| 223 | # Should raise RuntimeError due to wrong use. |
| 224 | nx = 2 |
| 225 | nu = 2 |
| 226 | space = manifolds.VectorSpace(nx) |
| 227 | cost_stack = CostStack(space, nu) |
| 228 | Q = np.eye(nx) |
| 229 | R = np.eye(nu) |
| 230 | R[range(nu), range(nu)] = np.random.rand(nu) * 2.0 |
| 231 | rcost = QuadraticCost(Q, R) |
| 232 | cost_stack.addCost(rcost) # optional |
| 233 | |
| 234 | if eigenpy.__version__ >= "3.9.1": |
| 235 | print(cost_stack.components.todict()) |
| 236 | |
| 237 | rc2 = QuadraticCost(np.eye(3), np.eye(nu)) |
| 238 | rc3 = QuadraticCost(np.eye(nx), np.eye(nu * 2)) |
| 239 | |
| 240 | if eigenpy.__version__ >= "3.9.1": |
| 241 | cost_data = cost_stack.createData() |
| 242 | print(cost_data.sub_cost_data.todict()) |
| 243 | |
| 244 | with pytest.raises(Exception) as e_info: |
| 245 | cost_stack.addCost(rc2) |
| 246 | print(e_info) |
| 247 | |
| 248 | with pytest.raises(Exception) as e_info: |
| 249 | cost_stack.addCost(rc3) |
| 250 | print(e_info) |
| 251 | |
| 252 | with pytest.raises(Exception) as e_info: |
| 253 | CostStack(space, nu, [rcost, rc2], [1.0, 1.0]) |
| 254 | print(e_info) |
| 255 | |
| 256 | with pytest.raises(Exception) as e_info: |
| 257 | CostStack(space, nu, [rcost], [1.0, 1.0]) |
| 258 | print(e_info) |
| 259 | |
| 260 | |
| 261 | @pytest.mark.skipif( |
nothing calls this directly
no test coverage detected