MCPcopy Create free account
hub / github.com/casadi/casadi / test_Callback_dimcheck

Method test_Callback_dimcheck

test/python/function.py:1380–1430  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1378 f.reverse(1)
1379
1380 def test_Callback_dimcheck(self):
1381 class Fun(Callback):
1382 def __init__(self):
1383 Callback.__init__(self)
1384 self.construct("Fun")
1385 def get_n_in(self): return 2
1386 def get_n_out(self): return 1
1387
1388 def eval(self,arg):
1389 return [2, 1]
1390 f = Fun()
1391
1392 s = ""
1393 try:
1394 f(2)
1395 except Exception as e:
1396 s = str(e)
1397 self.assertTrue("Incorrect number of inputs" in s)
1398 class Fun(Callback):
1399 def __init__(self):
1400 Callback.__init__(self)
1401 self.construct("Fun")
1402 def get_n_in(self): return 2
1403 def get_n_out(self): return 1
1404
1405 def eval(self,arg):
1406 return [2, 1]
1407 f = Fun()
1408
1409 s = ""
1410 try:
1411 f(2,3)
1412 except Exception as e:
1413 s = str(e)
1414 self.assertTrue("Expected 1 output" in s)
1415 s = ""
1416 class Fun(Callback):
1417 def __init__(self):
1418 Callback.__init__(self)
1419 self.construct("Fun")
1420 def get_n_in(self): return 2
1421 def get_n_out(self): return 1
1422
1423 def eval(self,arg):
1424 return [DM.zeros(2,2)]
1425 f = Fun()
1426 try:
1427 f(2,3)
1428 except Exception as e:
1429 s = str(e)
1430 self.assertTrue("Shape mismatch" in s)
1431
1432 def test_Callback_sens(self):
1433 x = MX.sym("x")

Callers

nothing calls this directly

Calls 3

FunClass · 0.85
strFunction · 0.85
fFunction · 0.50

Tested by

no test coverage detected