(self)
| 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 | |
| 395 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected