(self)
| 26 | self.assertLess(max_error1, eps) |
| 27 | |
| 28 | def test_gradient(self): |
| 29 | for device in DEVICES: |
| 30 | f, y0, t_points, sol = construct_problem(device=device) |
| 31 | tuple_f = lambda t, y: (f(t, y[0]), f(t, y[1])) |
| 32 | for method in ADAPTIVE_METHODS: |
| 33 | if method == "scipy_solver": |
| 34 | continue |
| 35 | |
| 36 | with self.subTest(device=device, method=method): |
| 37 | for i in range(2): |
| 38 | func = lambda y0, t_points: torchdiffeq.odeint(tuple_f, (y0, y0), t_points, method=method)[i] |
| 39 | self.assertTrue(torch.autograd.gradcheck(func, (y0, t_points))) |
| 40 | |
| 41 | |
| 42 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected