22
33from typing import Union , Callable
44
5- import numpy as np
6- from jax .experimental .host_callback import id_tap
7-
85import brainpy .math as bm
96from brainpy import check
107from brainpy .dyn .base import NeuGroup
8+ from brainpy .dyn .others .noises import OUProcess
119from brainpy .initialize import Initializer , Uniform , init_param , ZeroInit
12- from brainpy .integrators .dde import ddeint
1310from brainpy .integrators .joint_eq import JointEq
1411from brainpy .integrators .ode import odeint
1512from brainpy .tools .checking import check_float , check_initializer
13+ from brainpy .tools .errors import check_error_in_jit
1614from brainpy .types import Shape , Tensor
17- from brainpy .dyn .others .noises import OUProcess
1815
1916__all__ = [
2017 'Population' ,
@@ -307,7 +304,7 @@ def __init__(
307304 method = sde_method )
308305
309306 # integral
310- self .integral = ddeint (method = method ,
307+ self .integral = odeint (method = method ,
311308 f = JointEq ([self .dx , self .dy ]),
312309 state_delays = {'V' : self .x_delay })
313310
@@ -327,15 +324,14 @@ def dx(self, x, t, y, x_ext):
327324 def dy (self , y , t , x , y_ext ):
328325 return (x + self .a - self .b * y + y_ext ) / self .tau
329326
330- def _check_dt (self , dt , * args ):
331- if np .absolute (dt - self .dt ) > 1e-6 :
332- raise ValueError (f'The "dt" { dt } used in model running is '
333- f'not consistent with the "dt" { self .dt } '
334- f'used in model definition.' )
327+ def _check_dt (self , dt ):
328+ raise ValueError (f'The "dt" { dt } used in model running is '
329+ f'not consistent with the "dt" { self .dt } '
330+ f'used in model definition.' )
335331
336332 def update (self , t , dt ):
337333 if check .is_checking ():
338- id_tap ( self ._check_dt , dt )
334+ check_error_in_jit ( not bm . isclose ( dt , self . dt ), self ._check_dt , dt )
339335 if self .x_ou is not None :
340336 self .input += self .x_ou .x
341337 self .x_ou .update (t , dt )
@@ -882,5 +878,3 @@ def update(self, t, dt):
882878 self .i .value = bm .maximum (self .i + di * dt , 0. )
883879 self .Ie [:] = 0.
884880 self .Ii [:] = 0.
885-
886-
0 commit comments