[Scipy-tickets] [SciPy] #1375: Getting traceback when debugging UnivariateSpline

SciPy Trac scipy-tickets@scipy....
Fri Jan 28 16:28:24 CST 2011


#1375: Getting traceback when debugging UnivariateSpline
------------------------+---------------------------------------------------
 Reporter:  penguin_tx  |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:  0.9.0   
Component:  Other       |     Version:  0.8.0   
 Keywords:              |  
------------------------+---------------------------------------------------
 My original call looks like:

   csp_press = scipy.interpolate.UnivariateSpline(list1, list2, k=1)

 This succeeds with some debuggers but fails with Winpdb and with pdb if
 you step into the fitpack2.py routines.

 Using the python debugger and stepping into fitpack2.py

 Traceback is as follows:

   File "/home/user/src/wellsim/sim/gasliftfuncs.py", line 287, in
 valve_flow_and_status
     k=1)
   File "/usr/lib/python2.6/dist-packages/scipy/interpolate/fitpack2.py",
 line 91, in __init__
     data = self._reset_nest(data)
   File "/usr/lib/python2.6/dist-packages/scipy/interpolate/fitpack2.py",
 line 137, in _reset_nest
     t.resize(nest)

 ValueError: cannot resize an array that has been referenced or is
 referencing
 another array in this way.  Use the resize function

 The problem was documented earlier on a mailing list:

 http://mail.scipy.org/pipermail/scipy-dev/2008-March/008507.html

 which includes a patch that fixes the problem but apparently it wasn't
 applied.

 The patch to fix this from the earlier mailing list:

 from:

 t,c,fpint,nrdata = data[8].copy(),data[9].copy(),\
                           data[11].copy(),data[12].copy()
        t.resize(nest)
        c.resize(nest)
        fpint.resize(nest)
        nrdata.resize(nest)

 to:

     t,c,fpint,nrdata = [resize(data[n],nest) for n in
                            [8,9,11,12]]

 The patch appears to work (for me) due to differences in how numpy resizes
 arrays (see:
 http://docs.scipy.org/doc/numpy/reference/generated/numpy.resize.html)

 e.g.
 If the new array is larger than the original array, then the new array is
 filled with repeated copies of a. Note that this behavior is different
 from a.resize(new_shape) which fills with zeros instead of repeated copies
 of a.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1375>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list