MCPcopy Create free account
hub / github.com/Rhoban/placo / test_stacking

Method test_stacking

python/tests/problem_test.py:53–70  ·  view source on GitHub ↗

The operator / allow to stack expressions

(self)

Source from the content-addressed store, hash-verified

51 self.assertEqual(y.expr(0, 1).A.shape, (4,))
52
53 def test_stacking(self):
54 """
55 The operator / allow to stack expressions
56 """
57 problem = placo.Problem()
58
59 x = problem.add_variable(8)
60 e = x.expr(0, 1) / x.expr(2, 1) / x.expr(4, 1) / x.expr(6, 1)
61
62 A = np.zeros((4, 8))
63 A[0, 0] = 1
64 A[1, 2] = 1
65 A[2, 4] = 1
66 A[3, 6] = 1
67 self.assertNumpyEqual(A, e.A, msg="Expected matrix obtained by stacking")
68
69 b = np.zeros(4)
70 self.assertNumpyEqual(b, e.b, msg="Expected vector obtained by stacking")
71
72 def test_simple_solve(self):
73 problem = placo.Problem()

Callers

nothing calls this directly

Calls 3

assertNumpyEqualMethod · 0.95
ProblemMethod · 0.80
exprMethod · 0.45

Tested by

no test coverage detected