amd64 specific error in fitpack spline interpolation
Hi all, I posted about this problem a few months ago, but we didn't get very far, but the annoyance level of the problem is enough now for me to have another go. I'm trying to run the spline example from the cookbook (my exact code, called spl.py, is inlined below). On an ix86 computer this works fine, and returns the expected graphs, but on an amd64 machine I get the error below. Both computers are running debian etch, with recent svn numpy and scipy. TypeError: array cannot be safely cast to required type
/usr/lib/python2.4/site-packages/scipy/interpolate/fitpack.py(217)splprep() 216 t,c,o=_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, --> 217 nest,wrk,iwrk,per) 218 _parcur_cache['u']=o['u']
I believe the error is generated by the _parcur call -> once in pdb, calling it again re-raises the same error. ipdb>_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, nest,wrk,iwrk,per) *** TypeError: array cannot be safely cast to required type I've checked the values of all the inputs to the call ravel(transpose(x)) | shape=(300,) <type 'numpy.float64'> w | shape=(100,) <type 'numpy.float64'> u | shape=(100,) <type 'numpy.float64'> ub | 0 <type 'int'> ue | 1 <type 'int'> k | 2 <type 'int'> task | 0 <type 'int'> ipar | F <type 'bool'> s | 3.0 <type 'float'> t | [] <type 'numpy.ndarray'> nest | 103 <type 'int'> wrk | [] <type 'numpy.ndarray'> iwrk | [] <type 'numpy.ndarray'> per | 0 <type 'int'> and they are all the same on both machines, suggesting to me that something is happening wrong in the internals of the function call, rather than with one of the parameters. Any suggestions what could be going on, or how I could debug this further? Can anyone at least verify that the problem exists on other amd64 platforms. Thanks, Angus. spl.py: -------------------------------- from numpy import arange, cos, linspace, pi, sin from scipy.interpolate import splprep, splev from numpy.random import randn # make ascending spiral in 3-space t=linspace(0,1.75*2*pi,100) x = sin(t) y = cos(t) z = t # add noise x+= 0.1*randn(*x.shape) y+= 0.1*randn(*y.shape) z+= 0.1*randn(*z.shape) # spline parameters s=3.0 # smoothness parameter k=2 # spline order nest=-1 # estimate of number of knots needed (-1 = maximal) # find the knot points tckp,u = splprep([x,y,z],s=s,k=k,nest=-1) # evaluate spline, including interpolated points xnew,ynew,znew = splev(linspace(0,1,400),tckp) import pylab pylab.subplot(2,2,1) data,=pylab.plot(x,y,'bo-',label='data') fit,=pylab.plot(xnew,ynew,'r-',label='fit') pylab.legend() pylab.xlabel('x') pylab.ylabel('y') pylab.subplot(2,2,2) data,=pylab.plot(x,z,'bo-',label='data') fit,=pylab.plot(xnew,znew,'r-',label='fit') pylab.legend() pylab.xlabel('x') pylab.ylabel('z') pylab.subplot(2,2,3) data,=pylab.plot(y,z,'bo-',label='data') fit,=pylab.plot(ynew,znew,'r-',label='fit') pylab.legend() pylab.xlabel('y') pylab.ylabel('z') -- Angus McMorland email a.mcmorland@auckland.ac.nz mobile +64-21-155-4906 PhD Student, Neurophysiology / Multiphoton & Confocal Imaging Physiology, University of Auckland phone +64-9-3737-599 x89707 Armourer, Auckland University Fencing Secretary, Fencing North Inc.
Angus; We recently got an amd64; I've not had time to get the thing up and running with scipy and friends, but I'll do that tonight (I hope). I'll try your script and post before Monday. -- WH On 30/08/06, Angus McMorland <a.mcmorland@auckland.ac.nz> wrote:
Hi all,
I posted about this problem a few months ago, but we didn't get very far, but the annoyance level of the problem is enough now for me to have another go.
I'm trying to run the spline example from the cookbook (my exact code, called spl.py, is inlined below). On an ix86 computer this works fine, and returns the expected graphs, but on an amd64 machine I get the error below. Both computers are running debian etch, with recent svn numpy and scipy.
TypeError: array cannot be safely cast to required type
/usr/lib/python2.4/site-packages/scipy/interpolate/fitpack.py(217)splprep() 216 t,c,o=_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, --> 217 nest,wrk,iwrk,per) 218 _parcur_cache['u']=o['u']
I believe the error is generated by the _parcur call -> once in pdb, calling it again re-raises the same error.
ipdb>_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, nest,wrk,iwrk,per) *** TypeError: array cannot be safely cast to required type
I've checked the values of all the inputs to the call
ravel(transpose(x)) | shape=(300,) <type 'numpy.float64'> w | shape=(100,) <type 'numpy.float64'> u | shape=(100,) <type 'numpy.float64'> ub | 0 <type 'int'> ue | 1 <type 'int'> k | 2 <type 'int'> task | 0 <type 'int'> ipar | F <type 'bool'> s | 3.0 <type 'float'> t | [] <type 'numpy.ndarray'> nest | 103 <type 'int'> wrk | [] <type 'numpy.ndarray'> iwrk | [] <type 'numpy.ndarray'> per | 0 <type 'int'>
and they are all the same on both machines, suggesting to me that something is happening wrong in the internals of the function call, rather than with one of the parameters.
Any suggestions what could be going on, or how I could debug this further? Can anyone at least verify that the problem exists on other amd64 platforms.
Thanks,
Angus.
spl.py: -------------------------------- from numpy import arange, cos, linspace, pi, sin from scipy.interpolate import splprep, splev from numpy.random import randn
# make ascending spiral in 3-space t=linspace(0,1.75*2*pi,100)
x = sin(t) y = cos(t) z = t
# add noise x+= 0.1*randn(*x.shape) y+= 0.1*randn(*y.shape) z+= 0.1*randn(*z.shape)
# spline parameters s=3.0 # smoothness parameter k=2 # spline order nest=-1 # estimate of number of knots needed (-1 = maximal)
# find the knot points tckp,u = splprep([x,y,z],s=s,k=k,nest=-1)
# evaluate spline, including interpolated points xnew,ynew,znew = splev(linspace(0,1,400),tckp)
import pylab pylab.subplot(2,2,1) data,=pylab.plot(x,y,'bo-',label='data') fit,=pylab.plot(xnew,ynew,'r-',label='fit') pylab.legend() pylab.xlabel('x') pylab.ylabel('y')
pylab.subplot(2,2,2) data,=pylab.plot(x,z,'bo-',label='data') fit,=pylab.plot(xnew,znew,'r-',label='fit') pylab.legend() pylab.xlabel('x') pylab.ylabel('z')
pylab.subplot(2,2,3) data,=pylab.plot(y,z,'bo-',label='data') fit,=pylab.plot(ynew,znew,'r-',label='fit') pylab.legend() pylab.xlabel('y') pylab.ylabel('z')
-- Angus McMorland email a.mcmorland@auckland.ac.nz mobile +64-21-155-4906
PhD Student, Neurophysiology / Multiphoton & Confocal Imaging Physiology, University of Auckland phone +64-9-3737-599 x89707
Armourer, Auckland University Fencing Secretary, Fencing North Inc. _______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
On 30 Aug 2006, at 11:00, Angus McMorland wrote:
Hi all,
I posted about this problem a few months ago, but we didn't get very far, but the annoyance level of the problem is enough now for me to have another go.
I'm trying to run the spline example from the cookbook (my exact code, called spl.py, is inlined below). On an ix86 computer this works fine, and returns the expected graphs, but on an amd64 machine I get the error below. Both computers are running debian etch, with recent svn numpy and scipy.
TypeError: array cannot be safely cast to required type
/usr/lib/python2.4/site-packages/scipy/interpolate/fitpack.py(217) splprep() 216 t,c,o=_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, --> 217 nest,wrk,iwrk,per) 218 _parcur_cache['u']=o['u']
I believe the error is generated by the _parcur call -> once in pdb, calling it again re-raises the same error.
ipdb>_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, nest,wrk,iwrk,per)
Same problem on our Opterons. numpy v 2631 scipy v 1614 built & linked to acml [8]nohow@/noc/users/agn/python> python amdtest.py Traceback (most recent call last): File "amdtest.py", line 23, in ? tckp,u = splprep([x,y,z],s=s,k=k,nest=-1) File "/data/jrd/mod1/agn/ext/Linux/lib64/python2.3/site-packages/ scipy/interpolate/fitpack.py", line 217, in splprep TypeError: array cannot be safely cast to required type -George.
On Wednesday 30 August 2006 07:22, George Nurser wrote:
On 30 Aug 2006, at 11:00, Angus McMorland wrote:
Hi all,
I posted about this problem a few months ago, but we didn't get very far, but the annoyance level of the problem is enough now for me to have another go.
I'm trying to run the spline example from the cookbook (my exact code, called spl.py, is inlined below). On an ix86 computer this works fine, and returns the expected graphs, but on an amd64 machine I get the error below. Both computers are running debian etch, with recent svn numpy and scipy.
TypeError: array cannot be safely cast to required type
/usr/lib/python2.4/site-packages/scipy/interpolate/fitpack.py(217) splprep()
216 t,c,o=_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, --> 217 nest,wrk,iwrk,per) 218 _parcur_cache['u']=o['u']
I believe the error is generated by the _parcur call -> once in pdb, calling it again re-raises the same error.
ipdb>_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, nest,wrk,iwrk,per)
Same problem on our Opterons. numpy v 2631 scipy v 1614 built & linked to acml
I also see it on an Athlon, with numpy 1.0b5.dev3094, scipy 0.5.1.dev2184, linked to atlas 3.7.11.
Said I'd reply... Works fine on my machine. On 30/08/06, George Nurser <agn@noc.soton.ac.uk> wrote:
On 30 Aug 2006, at 11:00, Angus McMorland wrote:
Hi all,
I posted about this problem a few months ago, but we didn't get very far, but the annoyance level of the problem is enough now for me to have another go.
I'm trying to run the spline example from the cookbook (my exact code, called spl.py, is inlined below). On an ix86 computer this works fine, and returns the expected graphs, but on an amd64 machine I get the error below. Both computers are running debian etch, with recent svn numpy and scipy.
TypeError: array cannot be safely cast to required type
/usr/lib/python2.4/site-packages/scipy/interpolate/fitpack.py(217) splprep() 216 t,c,o=_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, --> 217 nest,wrk,iwrk,per) 218 _parcur_cache['u']=o['u']
I believe the error is generated by the _parcur call -> once in pdb, calling it again re-raises the same error.
ipdb>_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, nest,wrk,iwrk,per)
Same problem on our Opterons. numpy v 2631 scipy v 1614 built & linked to acml
[8]nohow@/noc/users/agn/python> python amdtest.py Traceback (most recent call last): File "amdtest.py", line 23, in ? tckp,u = splprep([x,y,z],s=s,k=k,nest=-1) File "/data/jrd/mod1/agn/ext/Linux/lib64/python2.3/site-packages/ scipy/interpolate/fitpack.py", line 217, in splprep TypeError: array cannot be safely cast to required type
-George.
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
On Wed, Aug 30, 2006 at 10:00:26PM +1200, Angus McMorland wrote:
Hi all,
I posted about this problem a few months ago, but we didn't get very far, but the annoyance level of the problem is enough now for me to have another go.
I'm trying to run the spline example from the cookbook (my exact code, called spl.py, is inlined below). On an ix86 computer this works fine, and returns the expected graphs, but on an amd64 machine I get the error below. Both computers are running debian etch, with recent svn numpy and scipy.
TypeError: array cannot be safely cast to required type
/usr/lib/python2.4/site-packages/scipy/interpolate/fitpack.py(217)splprep() 216 t,c,o=_fitpack._parcur(ravel(transpose(x)),w,u,ub,ue,k,task,ipar,s,t, --> 217 nest,wrk,iwrk,per) 218 _parcur_cache['u']=o['u']
Hi Angus, This is fixed in SVN (it works on the AMD Athlon 64 that I have access to). The C-wrappers expect 32-bit integers, instead of the 64-bit integers associated with 'int' on your platform. Can any of the developers tell me what the correct way is of handling 64-bit integers in C, using the numpy API? Or more specifically, of handling the default system type integer. Regards Stéfan
On 30/08/06, Stefan van der Walt <stefan@sun.ac.za> wrote:
Hi Angus,
This is fixed in SVN (it works on the AMD Athlon 64 that I have access to). The C-wrappers expect 32-bit integers, instead of the 64-bit integers associated with 'int' on your platform.
Can any of the developers tell me what the correct way is of handling 64-bit integers in C, using the numpy API? Or more specifically, of handling the default system type integer.
In this case, the problem is not with C but with Fortran. The fitpack routines, and many others in scipy, are written in Fortran, which specifies its integer size machine-independently. So fortran INTEGERS are always int32s. Unfortunately, there are places in the scipy wrappers where people have assumed that they are ints. A. M. Archibald
participants (6)
-
A. M. Archibald -
Angus McMorland -
Darren Dale -
George Nurser -
Stefan van der Walt -
William Hunter