dkriegner / xrayutilities

xrayutilities - a package with useful scripts for X-ray diffraction physicists
http://xrayutilities.sourceforge.io
GNU General Public License v2.0
81 stars 29 forks source link

TypeError: leastsq() got an unexpected keyword argument 'max_nfev' #119

Closed picca closed 2 years ago

picca commented 3 years ago

Hello, I am preparing the xraypackage for Debian stable (buster)

but during the build, I have this error message.

test_simpack_powdermodel (tests.test_examples.TestExampleScripts) ... Traceback (most recent call last):
  File "simpack_powdermodel.py", line 129, in <module>
    main()
  File "simpack_powdermodel.py", line 100, in main
    fitres1 = pm.fit(p, tt[mask], det[mask], std=sig[mask], maxfev=50)
  File "/usr/local/propellor/build-prolellor/xrayutilities-1.7.1/.pybuild/cpython3_3.7_xrayutilities/build/xrayutilities/simpack/powdermodel.py", line 320, in fit
    fitres = self.minimizer.minimize(max_nfev=maxfev)
  File "/usr/lib/python3/dist-packages/lmfit/minimizer.py", line 1811, in minimize
    return function(**kwargs)
  File "/usr/lib/python3/dist-packages/lmfit/minimizer.py", line 1364, in leastsq
    lsout = scipy_leastsq(self.__residual, variables, **lskws)
TypeError: leastsq() got an unexpected keyword argument 'max_nfev'
ERROR

This is an issue with lmfit available

$ dpkg -l | grep lmfit
ii  python-lmfit                                  0.9.11+dfsg-2                                all          Least-Squares Minimization with Constraints (Python 2)
ii  python3-lmfit                                 0.9.11+dfsg-2                                all          Least-Squares Minimization with Constraints (Python 3)

so my question, is will you support older lmfit, or should I backport lmfit-py also in order to use the latest xrayutilities.

cheers

Frederic

dkriegner commented 3 years ago

xrayutilities can be easily patched to support old lmfit. in fact the only change relevant seems to be this keyword arguments name. If on Debian only older lmfit version are available I propose to patch it locally.

On xrayutilities master I see no reason to support the older version. I would not like to include some

if lmfit_version < X.Y : 
 code
else:
 code

sections. If there are more elegant versions to support both which I am missing I am eager to learn

dkriegner commented 2 years ago

On Debian Bullseye now lmfit 1.0.1 is available. This should fix this issue