I'm trying to do a simple 2nd degree polynomial fit to two arrays of 5 entries. I get a runtime error: RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss') in the lstsq module inside numpy.polyfit.
Here's the code snippet: def findPeak(self, ydex, xdex): # take a vertical slice vslice = [] for i in range(-1,10,1) : vslice.append(arcImage[ydex+i][xdex]) vdex = n.where(vslice == max(vslice)) ymax = ydex -1 + vdex[0][0] # approximate gaussian fit by parabolic fit to logs yvalues = n.array([ymax-2, ymax-1, ymax, ymax+1, ymax+2])
svalues=n.array([arcImage[ymax-2][xdex],arcImage[ymax-1][xdex],arcImage[ymax ][xdex],arcImage[ymax+1][xdex], arcImage[ymax+2][xdex]]) avalues = n.log(svalues) ypoly = n.polyfit(yvalues, avalues, 2)
And the traceback: File "/Users/williamcarithers/BOSS/src/calibrationModel.py", line 345, in findPeak ypoly = n.polyfit(yvalues, avalues, 2) File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/lib/polynomial.py", line 503, in polyfit c, resids, rank, s = _lstsq(v, y, rcond) File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/lib/polynomial.py", line 46, in _lstsq return lstsq(X, y, rcond) File "/Library/Python/2.6/site-packages/scipy-0.7.1-py2.6-macosx-10.6-universal.e gg/scipy/linalg/basic.py", line 545, in lstsq lwork = calc_lwork.gelss(gelss.prefix,m,n,nrhs)[1] RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss')
This is such a simple application of polyfit and the error occurs in the guts of lstsq, so I'm completely stumped. Any help would be greatly appreciated.
Thanks, Bill Carithers
Charles H.: is this happening because he's calling the old version of polyfit?
William: try using numpy.polynomial.polyfit instead, see if that works.
DG
On Wed, May 19, 2010 at 11:03 AM, William Carithers wccarithers@lbl.govwrote:
I'm trying to do a simple 2nd degree polynomial fit to two arrays of 5 entries. I get a runtime error: RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss') in the lstsq module inside numpy.polyfit.
Here's the code snippet: def findPeak(self, ydex, xdex): # take a vertical slice vslice = [] for i in range(-1,10,1) : vslice.append(arcImage[ydex+i][xdex]) vdex = n.where(vslice == max(vslice)) ymax = ydex -1 + vdex[0][0] # approximate gaussian fit by parabolic fit to logs yvalues = n.array([ymax-2, ymax-1, ymax, ymax+1, ymax+2])
svalues=n.array([arcImage[ymax-2][xdex],arcImage[ymax-1][xdex],arcImage[ymax ][xdex],arcImage[ymax+1][xdex], arcImage[ymax+2][xdex]]) avalues = n.log(svalues) ypoly = n.polyfit(yvalues, avalues, 2)
And the traceback: File "/Users/williamcarithers/BOSS/src/calibrationModel.py", line 345, in findPeak ypoly = n.polyfit(yvalues, avalues, 2) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/lib/polynomial.py", line 503, in polyfit c, resids, rank, s = _lstsq(v, y, rcond) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/lib/polynomial.py", line 46, in _lstsq return lstsq(X, y, rcond) File
"/Library/Python/2.6/site-packages/scipy-0.7.1-py2.6-macosx-10.6-universal.e gg/scipy/linalg/basic.py", line 545, in lstsq lwork = calc_lwork.gelss(gelss.prefix,m,n,nrhs)[1] RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss')
This is such a simple application of polyfit and the error occurs in the guts of lstsq, so I'm completely stumped. Any help would be greatly appreciated.
Thanks, Bill Carithers
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Wed, May 19, 2010 at 3:18 PM, David Goldsmith d.l.goldsmith@gmail.com wrote:
Charles H.: is this happening because he's calling the old version of polyfit?
William: try using numpy.polynomial.polyfit instead, see if that works.
DG
On Wed, May 19, 2010 at 11:03 AM, William Carithers wccarithers@lbl.gov wrote:
I'm trying to do a simple 2nd degree polynomial fit to two arrays of 5 entries. I get a runtime error: RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss') in the lstsq module inside numpy.polyfit.
Here's the code snippet: def findPeak(self, ydex, xdex): # take a vertical slice vslice = [] for i in range(-1,10,1) : vslice.append(arcImage[ydex+i][xdex]) vdex = n.where(vslice == max(vslice)) ymax = ydex -1 + vdex[0][0] # approximate gaussian fit by parabolic fit to logs yvalues = n.array([ymax-2, ymax-1, ymax, ymax+1, ymax+2])
svalues=n.array([arcImage[ymax-2][xdex],arcImage[ymax-1][xdex],arcImage[ymax ][xdex],arcImage[ymax+1][xdex], arcImage[ymax+2][xdex]]) avalues = n.log(svalues) ypoly = n.polyfit(yvalues, avalues, 2)
And the traceback: File "/Users/williamcarithers/BOSS/src/calibrationModel.py", line 345, in findPeak ypoly = n.polyfit(yvalues, avalues, 2) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/lib/polynomial.py", line 503, in polyfit c, resids, rank, s = _lstsq(v, y, rcond) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/lib/polynomial.py", line 46, in _lstsq return lstsq(X, y, rcond) File
"/Library/Python/2.6/site-packages/scipy-0.7.1-py2.6-macosx-10.6-universal.e gg/scipy/linalg/basic.py", line 545, in lstsq lwork = calc_lwork.gelss(gelss.prefix,m,n,nrhs)[1] RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss')
This is such a simple application of polyfit and the error occurs in the guts of lstsq, so I'm completely stumped. Any help would be greatly appreciated.
which version of numpy and the arguments to polyfit would be useful information,e.g.
print repr(yvalues) print repr(avalues)
before the call to polyfit
Josef
Thanks, Bill Carithers
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Mathematician: noun, someone who disavows certainty when their uncertainty set is non-empty, even if that set has measure zero.
Hope: noun, that delusive spirit which escaped Pandora's jar and, with her lies, prevents mankind from committing a general suicide. (As interpreted by Robert Graves)
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Thanks David and Josef. Replies interspersed below.
On 5/19/10 12:24 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com wrote:
On Wed, May 19, 2010 at 3:18 PM, David Goldsmith d.l.goldsmith@gmail.com wrote:
Charles H.: is this happening because he's calling the old version of polyfit?
William: try using numpy.polynomial.polyfit instead, see if that works.
It says ypoly = n.polynomial.polyfit(yvalues, avalues, 2) AttributeError: 'module' object has no attribute 'polynomial'
Is this because I'm using a relatively old (numpy-1.2.1) version?
DG
On Wed, May 19, 2010 at 11:03 AM, William Carithers wccarithers@lbl.gov wrote:
I'm trying to do a simple 2nd degree polynomial fit to two arrays of 5 entries. I get a runtime error: RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss') in the lstsq module inside numpy.polyfit.
Here's the code snippet: def findPeak(self, ydex, xdex): # take a vertical slice vslice = [] for i in range(-1,10,1) : vslice.append(arcImage[ydex+i][xdex]) vdex = n.where(vslice == max(vslice)) ymax = ydex -1 + vdex[0][0] # approximate gaussian fit by parabolic fit to logs yvalues = n.array([ymax-2, ymax-1, ymax, ymax+1, ymax+2])
svalues=n.array([arcImage[ymax-2][xdex],arcImage[ymax-1][xdex],arcImage[ymax ][xdex],arcImage[ymax+1][xdex], arcImage[ymax+2][xdex]]) avalues = n.log(svalues) ypoly = n.polyfit(yvalues, avalues, 2)
And the traceback: File "/Users/williamcarithers/BOSS/src/calibrationModel.py", line 345, in findPeak ypoly = n.polyfit(yvalues, avalues, 2) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/lib/polynomial.py", line 503, in polyfit c, resids, rank, s = _lstsq(v, y, rcond) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/lib/polynomial.py", line 46, in _lstsq return lstsq(X, y, rcond) File
"/Library/Python/2.6/site-packages/scipy-0.7.1-py2.6-macosx-10.6-universal.e gg/scipy/linalg/basic.py", line 545, in lstsq lwork = calc_lwork.gelss(gelss.prefix,m,n,nrhs)[1] RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss')
This is such a simple application of polyfit and the error occurs in the guts of lstsq, so I'm completely stumped. Any help would be greatly appreciated.
which version of numpy and the arguments to polyfit would be useful information,e.g.
print repr(yvalues) print repr(avalues)
before the call to polyfit
Hi Josef,
I'm using numpy-1.2.1
Here are the arrays array([ 864., 865., 866., 867., 868.]) array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856, 5.73753977], dtype=float32)
thanks
Josef
Thanks, Bill Carithers
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Mathematician: noun, someone who disavows certainty when their uncertainty set is non-empty, even if that set has measure zero.
Hope: noun, that delusive spirit which escaped Pandora's jar and, with her lies, prevents mankind from committing a general suicide. (As interpreted by Robert Graves)
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Wed, May 19, 2010 at 3:51 PM, William Carithers wccarithers@lbl.gov wrote:
Thanks David and Josef. Replies interspersed below.
On 5/19/10 12:24 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com wrote:
On Wed, May 19, 2010 at 3:18 PM, David Goldsmith d.l.goldsmith@gmail.com wrote:
Charles H.: is this happening because he's calling the old version of polyfit?
William: try using numpy.polynomial.polyfit instead, see if that works.
It says ypoly = n.polynomial.polyfit(yvalues, avalues, 2) AttributeError: 'module' object has no attribute 'polynomial'
Is this because I'm using a relatively old (numpy-1.2.1) version?
DG
On Wed, May 19, 2010 at 11:03 AM, William Carithers wccarithers@lbl.gov wrote:
I'm trying to do a simple 2nd degree polynomial fit to two arrays of 5 entries. I get a runtime error: RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss') in the lstsq module inside numpy.polyfit.
Here's the code snippet: def findPeak(self, ydex, xdex): # take a vertical slice vslice = [] for i in range(-1,10,1) : vslice.append(arcImage[ydex+i][xdex]) vdex = n.where(vslice == max(vslice)) ymax = ydex -1 + vdex[0][0] # approximate gaussian fit by parabolic fit to logs yvalues = n.array([ymax-2, ymax-1, ymax, ymax+1, ymax+2])
svalues=n.array([arcImage[ymax-2][xdex],arcImage[ymax-1][xdex],arcImage[ymax ][xdex],arcImage[ymax+1][xdex], arcImage[ymax+2][xdex]]) avalues = n.log(svalues) ypoly = n.polyfit(yvalues, avalues, 2)
And the traceback: File "/Users/williamcarithers/BOSS/src/calibrationModel.py", line 345, in findPeak ypoly = n.polyfit(yvalues, avalues, 2) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/lib/polynomial.py", line 503, in polyfit c, resids, rank, s = _lstsq(v, y, rcond) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/lib/polynomial.py", line 46, in _lstsq return lstsq(X, y, rcond) File
"/Library/Python/2.6/site-packages/scipy-0.7.1-py2.6-macosx-10.6-universal.e gg/scipy/linalg/basic.py", line 545, in lstsq lwork = calc_lwork.gelss(gelss.prefix,m,n,nrhs)[1] RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss')
This is such a simple application of polyfit and the error occurs in the guts of lstsq, so I'm completely stumped. Any help would be greatly appreciated.
which version of numpy and the arguments to polyfit would be useful information,e.g.
print repr(yvalues) print repr(avalues)
before the call to polyfit
Hi Josef,
I'm using numpy-1.2.1
I don't remember whether 1.2.1 was fully python 2.6 compatible. I would recommend upgrading if possible.
I don't have any problems with more recent versions of scipy and numpy
import numpy as np y = np.array([ 864., 865., 866., 867., 868.]) x = np.array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856, 5.73753977],dtype=np.float32) np.polyfit(y, x, 2)
array([ -1.69296265e-01, 2.93325942e+02, -1.27049335e+05])
I didn't know numpy will use the scipy version of linalg for this. Do the scipy.test() pass?
My guess would be that there are some incompatibilities with your python/numpy/scipy versions.
Josef
Here are the arrays array([ 864., 865., 866., 867., 868.]) array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856, 5.73753977], dtype=float32)
thanks
Josef
Thanks, Bill Carithers
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Mathematician: noun, someone who disavows certainty when their uncertainty set is non-empty, even if that set has measure zero.
Hope: noun, that delusive spirit which escaped Pandora's jar and, with her lies, prevents mankind from committing a general suicide. (As interpreted by Robert Graves)
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Hi Josef,
I did the same test, namely opening a new window and plugging in the printout values by hand and polyfit worked just fine. Here's the terminal output:
import numpy as n y = n.array([ 864., 865., 866., 867., 868.]) a = n.array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856,
5.73753977])
ypoly = n.polyfit(y,a,2) ypoly
array([ -1.69296264e-01, 2.93325941e+02, -1.27049334e+05])
I wonder if the step of printing plus cut and paste is doing some kind of implicit type conversion. Maybe the original problem has to do with data types? In the original code arcImage is integer data so the avalues array is constructed from avalues = n.log(n.array([...list of integers...]))
Should I be doing some kind of casting first?
Thanks, Bill
On 5/19/10 1:09 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com wrote:
On Wed, May 19, 2010 at 3:51 PM, William Carithers wccarithers@lbl.gov wrote:
Thanks David and Josef. Replies interspersed below.
On 5/19/10 12:24 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com wrote:
On Wed, May 19, 2010 at 3:18 PM, David Goldsmith d.l.goldsmith@gmail.com wrote:
Charles H.: is this happening because he's calling the old version of polyfit?
William: try using numpy.polynomial.polyfit instead, see if that works.
It says ypoly = n.polynomial.polyfit(yvalues, avalues, 2) AttributeError: 'module' object has no attribute 'polynomial'
Is this because I'm using a relatively old (numpy-1.2.1) version?
DG
On Wed, May 19, 2010 at 11:03 AM, William Carithers wccarithers@lbl.gov wrote:
I'm trying to do a simple 2nd degree polynomial fit to two arrays of 5 entries. I get a runtime error: RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss') in the lstsq module inside numpy.polyfit.
Here's the code snippet: def findPeak(self, ydex, xdex): # take a vertical slice vslice = [] for i in range(-1,10,1) : vslice.append(arcImage[ydex+i][xdex]) vdex = n.where(vslice == max(vslice)) ymax = ydex -1 + vdex[0][0] # approximate gaussian fit by parabolic fit to logs yvalues = n.array([ymax-2, ymax-1, ymax, ymax+1, ymax+2])
svalues=n.array([arcImage[ymax-2][xdex],arcImage[ymax-1][xdex],arcImage[ym ax ][xdex],arcImage[ymax+1][xdex], arcImage[ymax+2][xdex]]) avalues = n.log(svalues) ypoly = n.polyfit(yvalues, avalues, 2)
And the traceback: File "/Users/williamcarithers/BOSS/src/calibrationModel.py", line 345, in findPeak ypoly = n.polyfit(yvalues, avalues, 2) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/pytho n/ numpy/lib/polynomial.py", line 503, in polyfit c, resids, rank, s = _lstsq(v, y, rcond) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/pytho n/ numpy/lib/polynomial.py", line 46, in _lstsq return lstsq(X, y, rcond) File
"/Library/Python/2.6/site-packages/scipy-0.7.1-py2.6-macosx-10.6-universal .e gg/scipy/linalg/basic.py", line 545, in lstsq lwork = calc_lwork.gelss(gelss.prefix,m,n,nrhs)[1] RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss')
This is such a simple application of polyfit and the error occurs in the guts of lstsq, so I'm completely stumped. Any help would be greatly appreciated.
which version of numpy and the arguments to polyfit would be useful information,e.g.
print repr(yvalues) print repr(avalues)
before the call to polyfit
Hi Josef,
I'm using numpy-1.2.1
I don't remember whether 1.2.1 was fully python 2.6 compatible. I would recommend upgrading if possible.
I don't have any problems with more recent versions of scipy and numpy
import numpy as np y = np.array([ 864., 865., 866., 867., 868.]) x = np.array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856, 5.73753977],dtype=np.float32) np.polyfit(y, x, 2)
array([ -1.69296265e-01, 2.93325942e+02, -1.27049335e+05])
I didn't know numpy will use the scipy version of linalg for this. Do the scipy.test() pass?
My guess would be that there are some incompatibilities with your python/numpy/scipy versions.
Josef
Here are the arrays array([ 864., 865., 866., 867., 868.]) array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856, 5.73753977], dtype=float32)
thanks
Josef
Thanks, Bill Carithers
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Mathematician: noun, someone who disavows certainty when their uncertainty set is non-empty, even if that set has measure zero.
Hope: noun, that delusive spirit which escaped Pandora's jar and, with her lies, prevents mankind from committing a general suicide. (As interpreted by Robert Graves)
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
The polynomial module definitely postdates 1.2.1; I echo Josef's rec. that you update if possible.
On Wed, May 19, 2010 at 1:24 PM, William Carithers wccarithers@lbl.govwrote:
Hi Josef,
I didn't know numpy will use the scipy version of linalg for this.
Right, that's what told me he must be using an old (and to-be-deprecated) version of polyfit; IIRC, the new polynomial module is "all-numpy," right Charles?
DG
On Wed, May 19, 2010 at 4:24 PM, William Carithers wccarithers@lbl.gov wrote:
Hi Josef,
I did the same test, namely opening a new window and plugging in the printout values by hand and polyfit worked just fine. Here's the terminal output:
import numpy as n y = n.array([ 864., 865., 866., 867., 868.]) a = n.array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856,
5.73753977])
here you dropped the ,dtype=np.float32) from your previous numbers
ypoly = n.polyfit(y,a,2) ypoly
array([ -1.69296264e-01, 2.93325941e+02, -1.27049334e+05])
I wonder if the step of printing plus cut and paste is doing some kind of implicit type conversion. Maybe the original problem has to do with data types? In the original code arcImage is integer data so the avalues array is constructed from avalues = n.log(n.array([...list of integers...]))
Should I be doing some kind of casting first?
That's what I thought when I saw your dtype=np.float32 but from your repr print it looks like the y array is float64, and only the second is "non-standard"
You could try to cast inside your function to float (float64)
However, I think this is only a short-term solution, my guess is that your exception is a symptom for more serious/pervasive problems.
Also, I don't know why in your example (if I interpret it correctly) np.log results in float32
np.log(np.array([5,2],int)).dtype
dtype('float64')
Josef
Thanks, Bill
On 5/19/10 1:09 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com wrote:
On Wed, May 19, 2010 at 3:51 PM, William Carithers wccarithers@lbl.gov wrote:
Thanks David and Josef. Replies interspersed below.
On 5/19/10 12:24 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com wrote:
On Wed, May 19, 2010 at 3:18 PM, David Goldsmith d.l.goldsmith@gmail.com wrote:
Charles H.: is this happening because he's calling the old version of polyfit?
William: try using numpy.polynomial.polyfit instead, see if that works.
It says ypoly = n.polynomial.polyfit(yvalues, avalues, 2) AttributeError: 'module' object has no attribute 'polynomial'
Is this because I'm using a relatively old (numpy-1.2.1) version?
DG
On Wed, May 19, 2010 at 11:03 AM, William Carithers wccarithers@lbl.gov wrote:
I'm trying to do a simple 2nd degree polynomial fit to two arrays of 5 entries. I get a runtime error: RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss') in the lstsq module inside numpy.polyfit.
Here's the code snippet: def findPeak(self, ydex, xdex): # take a vertical slice vslice = [] for i in range(-1,10,1) : vslice.append(arcImage[ydex+i][xdex]) vdex = n.where(vslice == max(vslice)) ymax = ydex -1 + vdex[0][0] # approximate gaussian fit by parabolic fit to logs yvalues = n.array([ymax-2, ymax-1, ymax, ymax+1, ymax+2])
svalues=n.array([arcImage[ymax-2][xdex],arcImage[ymax-1][xdex],arcImage[ym ax ][xdex],arcImage[ymax+1][xdex], arcImage[ymax+2][xdex]]) avalues = n.log(svalues) ypoly = n.polyfit(yvalues, avalues, 2)
And the traceback: File "/Users/williamcarithers/BOSS/src/calibrationModel.py", line 345, in findPeak ypoly = n.polyfit(yvalues, avalues, 2) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/pytho n/ numpy/lib/polynomial.py", line 503, in polyfit c, resids, rank, s = _lstsq(v, y, rcond) File
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/pytho n/ numpy/lib/polynomial.py", line 46, in _lstsq return lstsq(X, y, rcond) File
"/Library/Python/2.6/site-packages/scipy-0.7.1-py2.6-macosx-10.6-universal .e gg/scipy/linalg/basic.py", line 545, in lstsq lwork = calc_lwork.gelss(gelss.prefix,m,n,nrhs)[1] RuntimeError: more argument specifiers than keyword list entries (remaining format:'|:calc_lwork.gelss')
This is such a simple application of polyfit and the error occurs in the guts of lstsq, so I'm completely stumped. Any help would be greatly appreciated.
which version of numpy and the arguments to polyfit would be useful information,e.g.
print repr(yvalues) print repr(avalues)
before the call to polyfit
Hi Josef,
I'm using numpy-1.2.1
I don't remember whether 1.2.1 was fully python 2.6 compatible. I would recommend upgrading if possible.
I don't have any problems with more recent versions of scipy and numpy
import numpy as np y = np.array([ 864., 865., 866., 867., 868.]) x = np.array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856, 5.73753977],dtype=np.float32) np.polyfit(y, x, 2)
array([ -1.69296265e-01, 2.93325942e+02, -1.27049335e+05])
I didn't know numpy will use the scipy version of linalg for this. Do the scipy.test() pass?
My guess would be that there are some incompatibilities with your python/numpy/scipy versions.
Josef
Here are the arrays array([ 864., 865., 866., 867., 868.]) array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856, 5.73753977], dtype=float32)
thanks
Josef
Thanks, Bill Carithers
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Mathematician: noun, someone who disavows certainty when their uncertainty set is non-empty, even if that set has measure zero.
Hope: noun, that delusive spirit which escaped Pandora's jar and, with her lies, prevents mankind from committing a general suicide. (As interpreted by Robert Graves)
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Hi David and Josef,
OK, I updated to numpy-1.4.1 and scipy-0.7.2 and this problem went away. Thanks for your help.
BTW, trying to upgrade using the .dmg files from Sourceforge didn't work. It kept saying that it needed System Python 2.6 even though Python 2.6 is already installed. In fact, it was packaged with the OSX 10.6 upgrade. I had to download the tarballs and install from source.
Cheers, Bill
On 5/19/10 1:35 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com wrote:
On Wed, May 19, 2010 at 4:24 PM, William Carithers wccarithers@lbl.gov wrote:
Hi Josef,
I did the same test, namely opening a new window and plugging in the printout values by hand and polyfit worked just fine. Here's the terminal output:
import numpy as n y = n.array([ 864., 865., 866., 867., 868.]) a = n.array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856,
5.73753977])
here you dropped the ,dtype=np.float32) from your previous numbers
ypoly = n.polyfit(y,a,2) ypoly
array([ -1.69296264e-01, 2.93325941e+02, -1.27049334e+05])
I wonder if the step of printing plus cut and paste is doing some kind of implicit type conversion. Maybe the original problem has to do with data types? In the original code arcImage is integer data so the avalues array is constructed from avalues = n.log(n.array([...list of integers...]))
Should I be doing some kind of casting first?
That's what I thought when I saw your dtype=np.float32 but from your repr print it looks like the y array is float64, and only the second is "non-standard"
You could try to cast inside your function to float (float64)
However, I think this is only a short-term solution, my guess is that your exception is a symptom for more serious/pervasive problems.
Also, I don't know why in your example (if I interpret it correctly) np.log results in float32
np.log(np.array([5,2],int)).dtype
dtype('float64')
Josef
Thanks, Bill
On 5/19/10 1:09 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com wrote:
On Wed, May 19, 2010 at 3:51 PM, William Carithers wccarithers@lbl.gov wrote:
Thanks David and Josef. Replies interspersed below.
On 5/19/10 12:24 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com wrote:
On Wed, May 19, 2010 at 3:18 PM, David Goldsmith d.l.goldsmith@gmail.com wrote:
Charles H.: is this happening because he's calling the old version of polyfit?
William: try using numpy.polynomial.polyfit instead, see if that works.
It says ypoly = n.polynomial.polyfit(yvalues, avalues, 2) AttributeError: 'module' object has no attribute 'polynomial'
Is this because I'm using a relatively old (numpy-1.2.1) version?
DG
On Wed, May 19, 2010 at 11:03 AM, William Carithers wccarithers@lbl.gov wrote: > > I'm trying to do a simple 2nd degree polynomial fit to two arrays of 5 > entries. I get a runtime error: > RuntimeError: more argument specifiers than keyword list entries > (remaining > format:'|:calc_lwork.gelss') in the lstsq module inside numpy.polyfit. > > Here's the code snippet: > def findPeak(self, ydex, xdex): > # take a vertical slice > vslice = [] > for i in range(-1,10,1) : > vslice.append(arcImage[ydex+i][xdex]) > vdex = n.where(vslice == max(vslice)) > ymax = ydex -1 + vdex[0][0] > # approximate gaussian fit by parabolic fit to logs > yvalues = n.array([ymax-2, ymax-1, ymax, ymax+1, ymax+2]) > > > svalues=n.array([arcImage[ymax-2][xdex],arcImage[ymax-1][xdex],arcImage[ > ym > ax > ][xdex],arcImage[ymax+1][xdex], arcImage[ymax+2][xdex]]) > avalues = n.log(svalues) > ypoly = n.polyfit(yvalues, avalues, 2) > > And the traceback: > File "/Users/williamcarithers/BOSS/src/calibrationModel.py", line 345, > in > findPeak > ypoly = n.polyfit(yvalues, avalues, 2) > File > > "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/pyt > ho > n/ > numpy/lib/polynomial.py", line 503, in polyfit > c, resids, rank, s = _lstsq(v, y, rcond) > File > > "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/pyt > ho > n/ > numpy/lib/polynomial.py", line 46, in _lstsq > return lstsq(X, y, rcond) > File > > "/Library/Python/2.6/site-packages/scipy-0.7.1-py2.6-macosx-10.6-univers > al > .e > gg/scipy/linalg/basic.py", line 545, in lstsq > lwork = calc_lwork.gelss(gelss.prefix,m,n,nrhs)[1] > RuntimeError: more argument specifiers than keyword list entries > (remaining > format:'|:calc_lwork.gelss') > > This is such a simple application of polyfit and the error occurs in the > guts of lstsq, so I'm completely stumped. Any help would be greatly > appreciated.
which version of numpy and the arguments to polyfit would be useful information,e.g.
print repr(yvalues) print repr(avalues)
before the call to polyfit
Hi Josef,
I'm using numpy-1.2.1
I don't remember whether 1.2.1 was fully python 2.6 compatible. I would recommend upgrading if possible.
I don't have any problems with more recent versions of scipy and numpy
import numpy as np y = np.array([ 864., 865., 866., 867., 868.]) x = np.array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856, 5.73753977],dtype=np.float32) np.polyfit(y, x, 2)
array([ -1.69296265e-01, 2.93325942e+02, -1.27049335e+05])
I didn't know numpy will use the scipy version of linalg for this. Do the scipy.test() pass?
My guess would be that there are some incompatibilities with your python/numpy/scipy versions.
Josef
Here are the arrays array([ 864., 865., 866., 867., 868.]) array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856, 5.73753977], dtype=float32)
thanks
Josef
> > Thanks, > Bill Carithers > > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Mathematician: noun, someone who disavows certainty when their uncertainty set is non-empty, even if that set has measure zero.
Hope: noun, that delusive spirit which escaped Pandora's jar and, with her lies, prevents mankind from committing a general suicide. (As interpreted by Robert Graves)
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Wed, May 19, 2010 at 3:50 PM, William Carithers wccarithers@lbl.govwrote:
Hi David and Josef,
OK, I updated to numpy-1.4.1 and scipy-0.7.2 and this problem went away. Thanks for your help.
BTW, trying to upgrade using the .dmg files from Sourceforge didn't work. It kept saying that it needed System Python 2.6 even though Python 2.6 is already installed. In fact, it was packaged with the OSX 10.6 upgrade. I had to download the tarballs and install from source.
Yeah, Chris Barker typically recommends that Mac users get the dmgs from here:
http://wiki.python.org/moin/MacPython/Packages
but they don't appear to have anything for Python 2.6 yet. :-(
Chris, any ideas?
DG
Cheers, Bill
On 5/19/10 1:35 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com wrote:
On Wed, May 19, 2010 at 4:24 PM, William Carithers wccarithers@lbl.gov wrote:
Hi Josef,
I did the same test, namely opening a new window and plugging in the printout values by hand and polyfit worked just fine. Here's the
terminal
output:
import numpy as n y = n.array([ 864., 865., 866., 867., 868.]) a = n.array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856,
5.73753977])
here you dropped the ,dtype=np.float32) from your previous numbers
ypoly = n.polyfit(y,a,2) ypoly
array([ -1.69296264e-01, 2.93325941e+02, -1.27049334e+05])
I wonder if the step of printing plus cut and paste is doing some kind
of
implicit type conversion. Maybe the original problem has to do with data types? In the original code arcImage is integer data so the avalues
array is
constructed from avalues = n.log(n.array([...list of integers...]))
Should I be doing some kind of casting first?
That's what I thought when I saw your dtype=np.float32 but from your repr print it looks like the y array is float64, and only the second is "non-standard"
You could try to cast inside your function to float (float64)
However, I think this is only a short-term solution, my guess is that your exception is a symptom for more serious/pervasive problems.
Also, I don't know why in your example (if I interpret it correctly) np.log results in float32
np.log(np.array([5,2],int)).dtype
dtype('float64')
Josef
Thanks, Bill
On 5/19/10 1:09 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com
wrote:
On Wed, May 19, 2010 at 3:51 PM, William Carithers <
wccarithers@lbl.gov>
wrote:
Thanks David and Josef. Replies interspersed below.
On 5/19/10 12:24 PM, "josef.pktd@gmail.com" josef.pktd@gmail.com
wrote:
On Wed, May 19, 2010 at 3:18 PM, David Goldsmith d.l.goldsmith@gmail.com wrote: > Charles H.: is this happening because he's calling the old version
of
> polyfit? > > William: try using numpy.polynomial.polyfit instead, see if that
works.
It says ypoly = n.polynomial.polyfit(yvalues, avalues, 2) AttributeError: 'module' object has no attribute 'polynomial'
Is this because I'm using a relatively old (numpy-1.2.1) version?
> > DG > > On Wed, May 19, 2010 at 11:03 AM, William Carithers <
wccarithers@lbl.gov>
> wrote: >> >> I'm trying to do a simple 2nd degree polynomial fit to two arrays
of 5
>> entries. I get a runtime error: >> RuntimeError: more argument specifiers than keyword list entries >> (remaining >> format:'|:calc_lwork.gelss') in the lstsq module inside
numpy.polyfit.
>> >> Here's the code snippet: >> def findPeak(self, ydex, xdex): >> # take a vertical slice >> vslice = [] >> for i in range(-1,10,1) : >> vslice.append(arcImage[ydex+i][xdex]) >> vdex = n.where(vslice == max(vslice)) >> ymax = ydex -1 + vdex[0][0] >> # approximate gaussian fit by parabolic fit to logs >> yvalues = n.array([ymax-2, ymax-1, ymax, ymax+1, ymax+2]) >> >> >>
svalues=n.array([arcImage[ymax-2][xdex],arcImage[ymax-1][xdex],arcImage[
>> ym >> ax >> ][xdex],arcImage[ymax+1][xdex], arcImage[ymax+2][xdex]]) >> avalues = n.log(svalues) >> ypoly = n.polyfit(yvalues, avalues, 2) >> >> And the traceback: >> File "/Users/williamcarithers/BOSS/src/calibrationModel.py", line
345,
>> in >> findPeak >> ypoly = n.polyfit(yvalues, avalues, 2) >> File >> >>
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/pyt
>> ho >> n/ >> numpy/lib/polynomial.py", line 503, in polyfit >> c, resids, rank, s = _lstsq(v, y, rcond) >> File >> >>
"/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/pyt
>> ho >> n/ >> numpy/lib/polynomial.py", line 46, in _lstsq >> return lstsq(X, y, rcond) >> File >> >>
"/Library/Python/2.6/site-packages/scipy-0.7.1-py2.6-macosx-10.6-univers
>> al >> .e >> gg/scipy/linalg/basic.py", line 545, in lstsq >> lwork = calc_lwork.gelss(gelss.prefix,m,n,nrhs)[1] >> RuntimeError: more argument specifiers than keyword list entries >> (remaining >> format:'|:calc_lwork.gelss') >> >> This is such a simple application of polyfit and the error occurs
in the
>> guts of lstsq, so I'm completely stumped. Any help would be greatly >> appreciated.
which version of numpy and the arguments to polyfit would be useful information,e.g.
print repr(yvalues) print repr(avalues)
before the call to polyfit
Hi Josef,
I'm using numpy-1.2.1
I don't remember whether 1.2.1 was fully python 2.6 compatible. I would recommend upgrading if possible.
I don't have any problems with more recent versions of scipy and numpy
> import numpy as np > y = np.array([ 864., 865., 866., 867., 868.]) > x = np.array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856, > 5.73753977],dtype=np.float32) > np.polyfit(y, x, 2)
array([ -1.69296265e-01, 2.93325942e+02, -1.27049335e+05])
I didn't know numpy will use the scipy version of linalg for this. Do the scipy.test() pass?
My guess would be that there are some incompatibilities with your python/numpy/scipy versions.
Josef
Here are the arrays array([ 864., 865., 866., 867., 868.]) array([ 5.24860191, 6.0217514 , 6.11434555, 6.09198856,
5.73753977],
dtype=float32)
thanks
Josef
>> >> Thanks, >> Bill Carithers >> >> >> _______________________________________________ >> NumPy-Discussion mailing list >> NumPy-Discussion@scipy.org >> http://mail.scipy.org/mailman/listinfo/numpy-discussion > > > > -- > Mathematician: noun, someone who disavows certainty when their > uncertainty > set is non-empty, even if that set has measure zero. > > Hope: noun, that delusive spirit which escaped Pandora's jar and,
with
> her > lies, prevents mankind from committing a general suicide. (As > interpreted > by Robert Graves) > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Thu, May 20, 2010 at 10:17 AM, David Goldsmith d.l.goldsmith@gmail.comwrote:
On Wed, May 19, 2010 at 3:50 PM, William Carithers wccarithers@lbl.govwrote:
Hi David and Josef,
OK, I updated to numpy-1.4.1 and scipy-0.7.2 and this problem went away. Thanks for your help.
BTW, trying to upgrade using the .dmg files from Sourceforge didn't work. It kept saying that it needed System Python 2.6 even though Python 2.6 is already installed. In fact, it was packaged with the OSX 10.6 upgrade. I had to download the tarballs and install from source.
The numpy/scipy binaries on sourceforge are built for the dmg installers from http://python.org/, which is the recommended place to get python from. The python provided by Apple is outdated by several release cycles, and can not be used with those binaries.
I agree the help message about needing system python is not particularly helpful.
Cheers, Ralf