This example looks at the printme method
View output (PDF) | source (python)
- See also
Callback function functionality.
MX attachAssert(const MX &y, const std::string &fail_message="") const
returns itself, but with an assertion attached
35 f = Function(
"f", [x], [z])
45 y = y.attachAssert(y>0,
"bummer")
48 f = Function(
"f", [x],[z])
52 except Exception
as e:
53 print(
"An exception was raised here:")
59 class Dummy(Callback):
60 def __init__(self, name, opts={}):
61 Callback.__init__(self)
62 self.construct(name, opts)
63 def get_n_in(self):
return 1
64 def get_n_out(self):
return 1
68 m = max(numpy.real(numpy.linalg.eig(blockcat([[x,-1],[-1,2]]))[0]))
76 y = y.attachAssert(foo(y),
"you are in trouble")
79 f = Function(
"f", [x],[z])