Skip to content

Commit

Permalink
model: remove scipy.misc.derivative dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesGaessler committed Jan 11, 2025
1 parent 2a4d717 commit b221b57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions kafe2/fit/indexed/model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from scipy.misc import derivative
import numdifftools as nd

from .._base import ModelFunctionBase, ParametricModelBaseMixin
from .container import IndexedContainer
Expand Down Expand Up @@ -108,6 +108,6 @@ def _chipped_func(par):
_chipped_pars[_par_idx] = par
return self._model_function_object(*_chipped_pars)

_der_val = derivative(_chipped_func, _par_val, dx=_par_dx)
_ret.append(_der_val)
_first_derivative = nd.Derivative(_chipped_func, step=_par_dx, order=4, n=1)
_ret.append(_first_derivative(_par_val))
return np.array(_ret)
6 changes: 3 additions & 3 deletions kafe2/fit/xy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pass
import numpy # help IDEs with type-hinting inside docstrings
import numpy as np
from scipy.misc import derivative
import numdifftools as nd

from .._base import ParametricModelBaseMixin
from ..util import function_library
Expand Down Expand Up @@ -137,8 +137,8 @@ def _chipped_func(par):
_chipped_pars[_par_idx] = par
return self._model_function_object(_x, *_chipped_pars)

_der_val = np.array(derivative(_chipped_func, _par_val, dx=_par_dx))
_ret[_par_idx] = _der_val
_first_derivative = nd.Derivative(_chipped_func, step=_par_dx, order=4, n=1)
_ret[_par_idx] = _first_derivative(_par_val)
return _ret

def eval_model_function_derivative_by_x(self, x=None, model_parameters=None, dx=None):
Expand Down

0 comments on commit b221b57

Please sign in to comment.