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

Method test_problem_polynom

python/tests/problem_test.py:374–392  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

372 self.assertNumpyEqual(y.value, 0.5)
373
374 def test_problem_polynom(self):
375 problem = placo.Problem()
376
377 coeffs = problem.add_variable(4)
378 pp = placo.ProblemPolynom(coeffs)
379
380 problem.add_constraint(pp.expr(0, 0) == 0)
381 problem.add_constraint(pp.expr(0, 1) == 0)
382 problem.add_constraint(pp.expr(1, 0) == 1)
383 problem.add_constraint(pp.expr(1, 1) == 0)
384
385 problem.solve()
386
387 polynom = pp.get_polynom()
388 self.assertEqual(len(polynom.coefficients), 4)
389 self.assertNumpyEqual(polynom.value(0, 0), 0)
390 self.assertNumpyEqual(polynom.value(0, 1), 0)
391 self.assertNumpyEqual(polynom.value(1, 0), 1)
392 self.assertNumpyEqual(polynom.value(1, 1), 0)
393
394
395if __name__ == "__main__":

Callers

nothing calls this directly

Calls 8

exprMethod · 0.95
solveMethod · 0.95
get_polynomMethod · 0.95
assertNumpyEqualMethod · 0.95
ProblemMethod · 0.80
ProblemPolynomMethod · 0.80
add_constraintMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected