hgrecco / numbakit-ode

Leveraging numba to speed up ODE integration
Other
68 stars 3 forks source link

Cannot pass rtol in latest version #16

Closed astrojuanlu closed 3 years ago

astrojuanlu commented 3 years ago

In numbakit-ode 0.3 I could do this:

In [4]: import numpy as np

In [5]: >>> import nbkode
   ...: >>> def func(t, y):
   ...: ...     return -0.1 * y
   ...: >>> t0 = 0.
   ...: >>> y0 = np.array([1.])
   ...: >>> solver = nbkode.DOP853(func, t0, y0, rtol=1e-3)
   ...: >>> ts, ys = solver.run([0., 5., 10.])

In [6]: ys
Out[6]: 
array([[1.        ],
       [0.66453789],
       [0.52767336]])

But in 0.4, I get an error:

In [1]: import numpy as np

In [2]: >>> import nbkode
   ...: >>> def func(t, y):
   ...: ...     return -0.1 * y
   ...: >>> t0 = 0.
   ...: >>> y0 = np.array([1.])
   ...: >>> solver = nbkode.DOP853(func, t0, y0, rtol=1e-3)
   ...: >>> ts, ys = solver.run([0., 5., 10.])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-1c36adfd1eb8> in <module>
      4 t0 = 0.
      5 y0 = np.array([1.])
----> 6 solver = nbkode.DOP853(func, t0, y0, rtol=1e-3)
      7 ts, ys = solver.run([0., 5., 10.])

~/.pyenv/versions/poliastro38/lib/python3.8/site-packages/nbkode/core.py in __init__(self, *args, **kwargs)
    575 
    576     def __init__(self, *args, **kwargs):
--> 577         super().__init__(*args, **kwargs)
    578         self.options = VariableStepOptions(
    579             **{k: kwargs.pop(k) for k in variable_step_options if k in kwargs}

~/.pyenv/versions/poliastro38/lib/python3.8/site-packages/nbkode/runge_kutta/core.py in __init__(self, *args, **kwargs)
     24 
     25     def __init__(self, *args, **kwargs):
---> 26         super().__init__(*args, **kwargs)
     27         self.K = np.empty((self.stages, self.y.size))
     28 

TypeError: __init__() got an unexpected keyword argument 'rtol'
hgrecco commented 3 years ago

This was fixed in 2c3b0c03a787615076316351f8417d58e73af40b

astrojuanlu commented 3 years ago

Thanks! Sorry for the noise, I'll have a look at the main branch before reporting next time