Larch-0.9.24 with Python2
Dear mailing list user, When running an example file of Larch-0.9.24 with Python2 on Ubuntu x86_64, the following error was reported. File "Py_usinglarch.py", line 32, in <module> autobk(xafsdat.energy, xafsdat.mu, rbkg=1.0, _larch=my_larch) File "/usr/local/lib/python2.7/dist-packages/larch/__init__.py", line 37, in wrapper return fcn(*args, **keywords) File "/usr/share/larch/plugins/xafs/autobk.py", line 187, in autobk fit.leastsq() File "/usr/local/lib/python2.7/dist-packages/larch/fitting/minimizer.py", line 395, in leastsq lsout = leastsq(self.__residual, self.vars, **lskws) File "/usr/local/lib/python2.7/dist-packages/larch/fitting/minimizer.py", line 222, in leastsq shape, dtype = _check_func('leastsq', 'func', func, x0, args, n) ValueError: need more than 1 value to unpack Is Larch-0.9.24 compatible with Python2 on Ubuntu x86_64? If not, what packages and dependencies could we install to make it work on Python2? Or is Larch-0.9.24 only compatible with Python3? Many thanks in advance, Matthias
On Tue, Nov 4, 2014 at 4:39 AM, Matthias Filez
Dear mailing list user,
When running an example file of Larch-0.9.24 with Python2 on Ubuntu x86_64, the following error was reported. File "Py_usinglarch.py", line 32, in <module> autobk(xafsdat.energy, xafsdat.mu, rbkg=1.0, _larch=my_larch) File "/usr/local/lib/python2.7/dist-packages/larch/__init__.py", line 37, in wrapper return fcn(*args, **keywords) File "/usr/share/larch/plugins/xafs/autobk.py", line 187, in autobk fit.leastsq() File "/usr/local/lib/python2.7/dist-packages/larch/fitting/minimizer.py", line 395, in leastsq lsout = leastsq(self.__residual, self.vars, **lskws) File "/usr/local/lib/python2.7/dist-packages/larch/fitting/minimizer.py", line 222, in leastsq shape, dtype = _check_func('leastsq', 'func', func, x0, args, n) ValueError: need more than 1 value to unpack
Is Larch-0.9.24 compatible with Python2 on Ubuntu x86_64? If not, what packages and dependencies could we install to make it work on Python2? Or is Larch-0.9.24 only compatible with Python3?
Many thanks in advance, Matthias
_______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
It would be helpful to post the full example script. Larch definitely runs with Python2 on all Linux platforms (and Windows and Mac OSX). Testing with Python3 is minimal, and the graphics libraries will probably need significant work to get working with Python3. So, it *should* work. I can't tell what might be wrong just from the traceback (perhaps there is no actual data in those arrays?). But, the script below does work for me. --Matt # from larch import Interpreter, use_plugin_path use_plugin_path('xafs') from pre_edge import pre_edge from autobk import autobk use_plugin_path('io') from columnfile import _read_ascii my_larch = Interpreter() fname = 'examples/xafsdata/cu_rt01.xmu' cu = _read_ascii(fname, labels='energy mu i0', _larch=my_larch) print 'Read ASCII File:', cu print dir(cu) pre_edge(cu, _larch=my_larch) print 'After pre-edge:' print dir(cu) autobk(cu, rbkg=1.0, kweight=1, _larch=my_larch) # or # autobk(cu.energy, cu.mu, group=cu, rbkg=1.0, kweight=1, _larch=my_larch) print 'After autobk:' print dir(cu) print cu.chi ##########
Dear Matt,
Thanks for your reply.
I included the following line at the beginning of the example you just posted (after use_plugin_path('xafs')): use_plugin_path('wx')
and this is what I get if I run it:
Read ASCII File:
Dear mailing list user,
When running an example file of Larch-0.9.24 with Python2 on Ubuntu x86_64, the following error was reported. File "Py_usinglarch.py", line 32, in <module> autobk(xafsdat.energy, xafsdat.mu, rbkg=1.0, _larch=my_larch) File "/usr/local/lib/python2.7/dist-packages/larch/__init__.py", line 37, in wrapper return fcn(*args, **keywords) File "/usr/share/larch/plugins/xafs/autobk.py", line 187, in autobk fit.leastsq() File "/usr/local/lib/python2.7/dist-packages/larch/fitting/minimizer.py", line 395, in leastsq lsout = leastsq(self.__residual, self.vars, **lskws) File "/usr/local/lib/python2.7/dist-packages/larch/fitting/minimizer.py", line 222, in leastsq shape, dtype = _check_func('leastsq', 'func', func, x0, args, n) ValueError: need more than 1 value to unpack
Is Larch-0.9.24 compatible with Python2 on Ubuntu x86_64? If not, what packages and dependencies could we install to make it work on Python2? Or is Larch-0.9.24 only compatible with Python3?
Many thanks in advance, Matthias
_______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
It would be helpful to post the full example script. Larch definitely runs with Python2 on all Linux platforms (and Windows and Mac OSX). Testing with Python3 is minimal, and the graphics libraries will probably need significant work to get working with Python3. So, it *should* work. I can't tell what might be wrong just from the traceback (perhaps there is no actual data in those arrays?). But, the script below does work for me. --Matt # from larch import Interpreter, use_plugin_path use_plugin_path('xafs') from pre_edge import pre_edge from autobk import autobk use_plugin_path('io') from columnfile import _read_ascii my_larch = Interpreter() fname = 'examples/xafsdata/cu_rt01.xmu' cu = _read_ascii(fname, labels='energy mu i0', _larch=my_larch) print 'Read ASCII File:', cu print dir(cu) pre_edge(cu, _larch=my_larch) print 'After pre-edge:' print dir(cu) autobk(cu, rbkg=1.0, kweight=1, _larch=my_larch) # or # autobk(cu.energy, cu.mu, group=cu, rbkg=1.0, kweight=1, _larch=my_larch) print 'After autobk:' print dir(cu) print cu.chi ########## _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
On 11/04/2014 12:07 PM, Matthias Filez wrote:
I included the following line at the beginning of the example you just posted (after use_plugin_path('xafs')): use_plugin_path('wx') and this is what I get if I run it:
Matthias, I agree with Matt. His script works just fine for me on my Ubuntu machine. Are you sure that you have pulled the very latest from Matt's github site? My suspicion is that you have not done so recently enough.... B -- Bruce Ravel ------------------------------------ bravel@bnl.gov National Institute of Standards and Technology Synchrotron Science Group at NSLS-II Building 535A Upton NY, 11973 Homepage: http://bruceravel.github.io/home/ Software: https://github.com/bruceravel Demeter: http://bruceravel.github.io/demeter/
Hi Matthias, Hmm, looking at this more closely, my guess is that you're using an older version scipy than I am. Can you verify what scipy version you have? That is, I do see that the return value for this call did change sometime in the past 2 years, though I'm not sure exactly which version. I'll try to commit a patch to allow this older version to github today. But, I suspect that older scipy versions might cause other problems. I should probably put in a more exact check for required scipy version. --Matt
Dear Matt, Bruce, I verified the scipy version: 0.9.0. The installed numpy version is 1.6.1. What versions are required? Thanks a lot! Matthias ________________________________________ Van: ifeffit-bounces@millenia.cars.aps.anl.gov [ifeffit-bounces@millenia.cars.aps.anl.gov] namens Matt Newville [newville@cars.uchicago.edu] Verzonden: dinsdag 4 november 2014 18:59 Aan: XAFS Analysis using Ifeffit Onderwerp: Re: [Ifeffit] Larch-0.9.24 with Python2 Hi Matthias, Hmm, looking at this more closely, my guess is that you're using an older version scipy than I am. Can you verify what scipy version you have? That is, I do see that the return value for this call did change sometime in the past 2 years, though I'm not sure exactly which version. I'll try to commit a patch to allow this older version to github today. But, I suspect that older scipy versions might cause other problems. I should probably put in a more exact check for required scipy version. --Matt _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
Hi Matthias,
OK, having scipy 0.9.0 is almost certainly the problem. I'm not
entirely sure how far back in scipy versions would be supported, but I
believe that version 0.12 will work, and am certain that 0.13 will
work. In fact, I'm pretty sure that version 0.13 is made several
changes to the minimization package. I believe I may be relying on
some of those changes for being able to use minimization method other
than the default Levenberg-Marquardt least-squares algorithm (not
that this is recommended for autobk() or feffit(), but it can
sometimes be useful in other fitting problems).
The version of numpy you have should be not be a problem.
I'll set the required versions of scipy to 0.13 and numpy to 1.5.
On Wed, Nov 5, 2014 at 1:39 AM, Matthias Filez
Dear Matt, Bruce,
I verified the scipy version: 0.9.0. The installed numpy version is 1.6.1.
What versions are required?
Thanks a lot!
Matthias ________________________________________ Van: ifeffit-bounces@millenia.cars.aps.anl.gov [ifeffit-bounces@millenia.cars.aps.anl.gov] namens Matt Newville [newville@cars.uchicago.edu] Verzonden: dinsdag 4 november 2014 18:59 Aan: XAFS Analysis using Ifeffit Onderwerp: Re: [Ifeffit] Larch-0.9.24 with Python2
Hi Matthias,
Hmm, looking at this more closely, my guess is that you're using an older version scipy than I am. Can you verify what scipy version you have?
That is, I do see that the return value for this call did change sometime in the past 2 years, though I'm not sure exactly which version. I'll try to commit a patch to allow this older version to github today. But, I suspect that older scipy versions might cause other problems.
I should probably put in a more exact check for required scipy version.
--Matt _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
--Matt
Dear Matt,
We have upgraded to scipy 0.14.0 and this is what I get now when I run the script:
Read ASCII File:
Dear Matt, Bruce,
I verified the scipy version: 0.9.0. The installed numpy version is 1.6.1.
What versions are required?
Thanks a lot!
Matthias ________________________________________ Van: ifeffit-bounces@millenia.cars.aps.anl.gov [ifeffit-bounces@millenia.cars.aps.anl.gov] namens Matt Newville [newville@cars.uchicago.edu] Verzonden: dinsdag 4 november 2014 18:59 Aan: XAFS Analysis using Ifeffit Onderwerp: Re: [Ifeffit] Larch-0.9.24 with Python2
Hi Matthias,
Hmm, looking at this more closely, my guess is that you're using an older version scipy than I am. Can you verify what scipy version you have?
That is, I do see that the return value for this call did change sometime in the past 2 years, though I'm not sure exactly which version. I'll try to commit a patch to allow this older version to github today. But, I suspect that older scipy versions might cause other problems.
I should probably put in a more exact check for required scipy version.
--Matt _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
--Matt _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
Hi Matthias,
Yes, that looks correct. I also fixed the code so that it can work
with scipy 0.11 and later. I will work on changing the installation
to check for minimal version numbers.
On Wed, Nov 5, 2014 at 10:03 AM, Matthias Filez
Dear Matt,
We have upgraded to scipy 0.14.0 and this is what I get now when I run the script:
Read ASCII File:
['array_labels', 'attrs', 'column_labels', 'data', 'energy', 'filename', 'header', 'i0', 'mu'] After pre-edge: ['array_labels', 'attrs', 'column_labels', 'data', 'dmude', 'e0', 'edge_step', 'energy', 'filename', 'flat', 'header', 'i0', 'mu', 'nnorm', 'norm', 'norm1', 'norm2', 'norm_c0', 'norm_c1', 'norm_c2', 'norm_c3', 'nvict', 'post_edge', 'pre1', 'pre2', 'pre_edge', 'pre_offset', 'pre_slope'] After autobk: ['array_labels', 'attrs', 'autobk_details', 'bkg', 'chi', 'chie', 'column_labels', 'data', 'dmude', 'e0', 'edge_step', 'energy', 'filename', 'flat', 'header', 'i0', 'k', 'mu', 'nnorm', 'norm', 'norm1', 'norm2', 'norm_c0', 'norm_c1', 'norm_c2', 'norm_c3', 'nvict', 'post_edge', 'pre1', 'pre2', 'pre_edge', 'pre_offset', 'pre_slope'] [ 5.22014125e-01 4.68863165e-01 4.23387732e-01 3.84601353e-01 3.51517555e-01 3.23149862e-01 2.98511802e-01 2.76616899e-01 2.56478680e-01 2.37110672e-01 2.17526399e-01 1.96774248e-01 1.74202338e-01 1.49312809e-01 1.21645288e-01 9.07843838e-02 5.63993015e-02 1.85571728e-02 -2.03243717e-02 -5.75444687e-02 -9.14850299e-02 -1.18154030e-01 -1.36108084e-01 -1.45468821e-01 -1.47073697e-01 -1.50934997e-01 -1.54219769e-01 -1.56582731e-01 -1.55007074e-01 -1.50082523e-01 -1.35737843e-01 -1.13771275e-01 -8.25087559e-02 -4.62194044e-02 9.36626084e-04 4.42260206e-02 8.89877045e-02 1.27496716e-01 1.50717679e-01 1.52846156e-01 1.34118361e-01 1.02181582e-01 6.49568133e-02 3.22399885e-02 6.46113335e-03 -6.98123272e-03 -4.09343210e-03 1.83744265e-02 5.17624756e-02 8.65303295e-02 9.62396887e-02 7.69122752e-02 4.26727610e-02 7.49257701e-03 -1.81363351e-02 -3.96258643e-02 -6.15635768e-02 -7.97519898e-02 -8.77310666e-02 -8.66687826e-02 -8.15835644e-02 -7.32081259e-02 -6.02706951e-02 -4.24399368e-02 -2.10497270e-02 5.08304985e-04 2.06241750e-02 3.91292189e-02 5.77145097e-02 7.15135419e-02 7.45516578e-02 6.38238728e-02 4.35580179e-02 2.02712305e-02 -4.46692821e-03 -2.41242981e-02 -3.66799760e-02 -4.33587597e-02 -4.46705006e-02 -4.05827015e-02 -3.30819589e-02 -2.70683602e-02 -2.59245042e-02 -2.90609922e-02 -2.95609304e-02 -2.38858773e-02 -1.50880484e-02 -9.19969595e-03 -8.33417313e-03 -7.93651142e-03 -3.05461694e-03 7.13301998e-03 1.82026094e-02 2.66824286e-02 3.30622138e-02 4.00340894e-02 4.90608443e-02 6.02648286e-02 7.00942393e-02 7.31115967e-02 6.75011510e-02 5.35389324e-02 3.48700770e-02 1.69745209e-02 1.72454146e-03 -1.20611024e-02 -2.27968218e-02 -2.76882865e-02 -3.34147477e-02 -4.57197498e-02 -6.05078349e-02 -7.24893051e-02 -7.70420692e-02 -7.26272010e-02 -6.11005811e-02 -4.55265529e-02 -3.00707518e-02 -1.68398434e-02 -7.56863503e-03 -3.68954861e-03 -3.43061853e-03 -3.06004774e-03 2.55862832e-03 1.71655046e-02 4.20159830e-02 6.75693679e-02 8.23617564e-02 8.56835153e-02 8.13427954e-02 7.37373718e-02 6.28271473e-02 4.67098172e-02 2.60081154e-02 2.82900268e-03 -2.26376028e-02 -4.78755329e-02 -6.99617777e-02 -8.35343661e-02 -8.44844001e-02 -7.18198681e-02 -5.08207746e-02 -2.73111366e-02 -8.63745041e-03 2.79708853e-03 8.16043004e-03 7.92863690e-03 5.11229300e-03 3.49449875e-03 3.87115590e-03 2.85022886e-03 -1.51356430e-04 -2.71617609e-03 7.99093220e-04 1.28770189e-02 2.97511624e-02 4.23481503e-02 4.61655216e-02 4.49878002e-02 4.16959342e-02 3.51358326e-02 2.30338982e-02 7.71870254e-03 -6.49914172e-03 -1.95979278e-02 -2.91442689e-02 -3.34105565e-02 -3.22190201e-02 -2.83765449e-02 -2.52463396e-02 -2.32145504e-02 -2.10720714e-02 -1.84390441e-02 -1.47681365e-02 -1.01599056e-02 -4.95494275e-03 -3.16814647e-04 4.11336090e-03 7.87342088e-03 1.02960668e-02 1.29127543e-02 1.55124154e-02 1.78762099e-02 1.96778316e-02 2.12245457e-02 1.92318426e-02 1.52708347e-02 1.00532965e-02 3.93556366e-03 -2.00861226e-04 -3.92225374e-03 -5.30239979e-03 -4.82306995e-03 -4.47717083e-03 -6.19650760e-03 -1.00134814e-02 -1.42494639e-02 -1.54978616e-02 -1.35397676e-02 -1.13623819e-02 -9.41262041e-03 -7.58206760e-03 -5.06296458e-03 -2.48585060e-03 -4.00416183e-04 1.87050218e-03 3.62541073e-03 6.07766518e-03 7.21786016e-03 8.77502787e-03 9.95603332e-03 1.03558434e-02 9.73912155e-03 7.63280475e-03 5.35276100e-03 2.20653640e-03 -9.84994816e-05 -1.37884146e-03 -1.12248811e-03 -8.47538380e-04 -6.26076861e-04 -5.87386385e-04 -8.97700051e-04 -2.24337187e-03 -3.92268068e-03 -4.69266928e-03 -4.80954070e-03 -4.76843389e-03 -5.05903965e-03 -4.98518712e-03 -4.01197097e-03 -3.00891314e-03 -1.46903844e-03 3.53683094e-05 1.59446778e-03 3.12390382e-03 4.76890345e-03 5.59846498e-03 5.63295324e-03 5.09371953e-03 3.49773838e-03 1.79393075e-03 4.66522098e-04 -1.52569918e-04 -7.15600312e-04 -9.34996770e-04 -1.13022725e-03 -8.06959189e-04 -8.41610248e-04 -1.14800547e-03 -1.28965094e-03 -1.24884820e-03 -1.44400047e-03 -2.04579669e-03 -2.17836113e-03 -2.08363191e-03 -1.81376431e-03 -1.41088949e-03 -8.75421280e-04 -4.54586404e-04 8.29150513e-05 6.78654789e-04 1.04647304e-03 1.59651631e-03 1.75850262e-03 1.71743579e-03 1.72121567e-03 1.67674127e-03 1.26223831e-03 1.09938217e-03 6.79160864e-04 2.74810773e-04 2.51510300e-04 -1.81502999e-05 -2.49024384e-04 -6.74164538e-04 -7.71579948e-04 -8.51008782e-04 -7.46019036e-04 -7.91883682e-04 -1.02615516e-03 -1.27411149e-03 -1.14412599e-03 -1.10888173e-03 -1.24436555e-03 -5.70511174e-04 -2.67727213e-04 -5.10544602e-05 -7.44585105e-05 3.32434599e-04 6.16025534e-04 4.60911522e-04 4.52806510e-04 5.17149268e-04 8.86203824e-04 8.06249536e-04 7.62364216e-04 6.89168671e-04 6.48290053e-04 5.50507466e-04 5.00420100e-04 4.91031520e-04 1.90660816e-04 1.42033309e-04 7.11215401e-05 -4.54097265e-05 -3.46351385e-05 -3.10631849e-05 -9.24403309e-05 -1.47993095e-04 -2.10994331e-04 -2.82751339e-04 -2.75720314e-04 -2.00919076e-04 -1.47717375e-04 -6.51029766e-05 -3.22735306e-05 -1.15212367e-04 -1.80394605e-04 -1.91644236e-04 -2.09229079e-04 -2.87571537e-04 -2.91770309e-04 -3.03029185e-04 -3.65472126e-04 -2.40079196e-04 -2.57480565e-04 -2.13293922e-04 -2.23895882e-04 -2.05898811e-04 -2.51361361e-04 -2.15835935e-04 -3.26122661e-04 -3.60578368e-04 -3.48674339e-04 -2.51265522e-04 -9.42783246e-05 1.05407722e-05 1.35324496e-04 1.32768084e-04 2.38054795e-04 2.37051097e-04 2.60387811e-04 3.17263146e-04 4.05326800e-04 5.37145496e-04 6.98105861e-04 8.02577998e-04 8.44690107e-04 8.42747086e-04 9.18552333e-04] It seems to work! For certainty, is this consistent with what you obtain?
Many thanks for your help, Matthias
________________________________________ Van: ifeffit-bounces@millenia.cars.aps.anl.gov [ifeffit-bounces@millenia.cars.aps.anl.gov] namens Matt Newville [newville@cars.uchicago.edu] Verzonden: woensdag 5 november 2014 14:23 Aan: XAFS Analysis using Ifeffit Onderwerp: Re: [Ifeffit] Larch-0.9.24 with Python2
Hi Matthias,
OK, having scipy 0.9.0 is almost certainly the problem. I'm not entirely sure how far back in scipy versions would be supported, but I believe that version 0.12 will work, and am certain that 0.13 will work. In fact, I'm pretty sure that version 0.13 is made several changes to the minimization package. I believe I may be relying on some of those changes for being able to use minimization method other than the default Levenberg-Marquardt least-squares algorithm (not that this is recommended for autobk() or feffit(), but it can sometimes be useful in other fitting problems).
The version of numpy you have should be not be a problem.
I'll set the required versions of scipy to 0.13 and numpy to 1.5.
On Wed, Nov 5, 2014 at 1:39 AM, Matthias Filez
wrote: Dear Matt, Bruce,
I verified the scipy version: 0.9.0. The installed numpy version is 1.6.1.
What versions are required?
Thanks a lot!
Matthias ________________________________________ Van: ifeffit-bounces@millenia.cars.aps.anl.gov [ifeffit-bounces@millenia.cars.aps.anl.gov] namens Matt Newville [newville@cars.uchicago.edu] Verzonden: dinsdag 4 november 2014 18:59 Aan: XAFS Analysis using Ifeffit Onderwerp: Re: [Ifeffit] Larch-0.9.24 with Python2
Hi Matthias,
Hmm, looking at this more closely, my guess is that you're using an older version scipy than I am. Can you verify what scipy version you have?
That is, I do see that the return value for this call did change sometime in the past 2 years, though I'm not sure exactly which version. I'll try to commit a patch to allow this older version to github today. But, I suspect that older scipy versions might cause other problems.
I should probably put in a more exact check for required scipy version.
--Matt _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
--Matt _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit _______________________________________________ Ifeffit mailing list Ifeffit@millenia.cars.aps.anl.gov http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
--Matt
participants (3)
-
Bruce Ravel
-
Matt Newville
-
Matthias Filez