MCPcopy Create free account
hub / github.com/rtqichen/torchdiffeq / test_wrong_callback

Method test_wrong_callback

tests/odeint_tests.py:290–308  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

288
289class TestCallbacks(unittest.TestCase):
290 def test_wrong_callback(self):
291 x0 = torch.tensor([1.0, 2.0])
292 t = torch.tensor([0., 1.0])
293
294 for method in FIXED_METHODS:
295 for callback_name in ('callback_accept_step', 'callback_reject_step'):
296 with self.subTest(method=method):
297 f = _NeuralF(width=10, oscillate=False)
298 setattr(f, callback_name, lambda t0, y0, dt: None)
299 with self.assertWarns(Warning):
300 torchdiffeq.odeint(f, x0, t, method=method)
301
302 for method in SCIPY_METHODS:
303 for callback_name in ('callback_step', 'callback_accept_step', 'callback_reject_step'):
304 with self.subTest(method=method):
305 f = _NeuralF(width=10, oscillate=False)
306 setattr(f, callback_name, lambda t0, y0, dt: None)
307 with self.assertWarns(Warning):
308 torchdiffeq.odeint(f, x0, t, method=method)
309
310 def test_steps(self):
311 for forward, adjoint in ((False, True), (True, False), (True, True)):

Callers

nothing calls this directly

Calls 1

_NeuralFClass · 0.70

Tested by

no test coverage detected