[Scipy-tickets] [SciPy] #1616: interpolate.sproot fails even when running fitpack tests

SciPy Trac scipy-tickets@scipy....
Sat Mar 3 16:01:58 CST 2012


#1616: interpolate.sproot fails even when running fitpack tests
-------------------------------+--------------------------------------------
 Reporter:  clopezx            |       Owner:  somebody   
     Type:  defect             |      Status:  new        
 Priority:  high               |   Milestone:  Unscheduled
Component:  scipy.interpolate  |     Version:  0.10.0     
 Keywords:                     |  
-------------------------------+--------------------------------------------

Old description:

> I ran this in Mac OS X version 10.7.3. I installed the scipy/numpy/etc
> tools as described in the SciPy superpack website
> (http://fonnesbeck.github.com/ScipySuperpack/).
>
> Running the tests of fitpack results in the following:
>
> neo.local:interpolate] 678 >python fitpack.py
> ******************************************
>         Tests of splrep and splev
> ******************************************
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
>  per=0 s=1e-06 Evaluation at the middle of nodes
>  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
>  1 :  8.1e-04 7.3e-02
>  2 :  2.3e-05 3.3e-04 2.3e-01
>  3 :  7.1e-07 4.4e-05 2.4e-03 2.9e-01
>  4 :  9.2e-07 1.1e-04 6.3e-03 1.3e-01 1.4e+00
>  5 :  8.8e-07 6.9e-05 3.5e-03 7.0e-02 6.0e-01 2.4e+00
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
>  per=0 s=0 Evaluation at the middle of nodes
>  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
>  1 :  7.8e-04 7.3e-02
>  2 :  1.5e-07 9.3e-04 1.6e-01
>  3 :  2.3e-09 3.7e-06 4.3e-04 7.5e-02
>  4 :  4.7e-11 1.4e-06 2.8e-04 1.5e-02 4.4e-01
>  5 :  7.5e-13 2.8e-08 6.1e-06 3.9e-04 1.0e-02 1.7e-01
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
>  per=0 s=0 Evaluation at knots
>  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
>  1 :  0.0e+00 2.5e-01
>  2 :  1.9e-07 1.9e-03 3.6e-01
>  3 :  3.6e-31 5.6e-06 1.4e-03 2.6e-01
>  4 :  6.9e-11 2.7e-06 5.4e-04 3.0e-02 7.1e-01
>  5 :  2.0e-31 5.4e-08 1.2e-05 7.7e-04 1.8e-02 3.5e-01
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
>  per=1 s=0 Evaluation at the middle of nodes
>  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
>  1 :  7.8e-04 7.3e-02
>  2 :  1.5e-07 9.3e-04 1.6e-01
>  3 :  2.2e-09 5.2e-07 4.4e-05 7.0e-02
>  4 :  4.1e-12 2.4e-08 6.3e-07 7.6e-04 1.6e-01
>  5 :  1.2e-14 3.7e-12 2.5e-10 5.1e-07 4.3e-05 7.0e-02
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
>  per=1 s=0 Evaluation at knots
>  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
>  1 :  6.3e-32 2.5e-01
>  2 :  2.0e-06 1.9e-03 3.7e-01
>  3 :  7.7e-31 3.3e-08 6.8e-04 2.5e-01
>  4 :  1.4e-10 3.1e-08 1.3e-06 1.7e-03 3.6e-01
>  5 :  7.7e-31 4.2e-13 1.9e-09 1.8e-08 6.8e-04 2.5e-01
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 4.712] > [0.0, 4.712]
>  per=0 s=0 Evaluation at the middle of nodes
>  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
>  1 :  2.4e-04 5.1e-02
>  2 :  5.9e-08 5.8e-05 4.6e-02
>  3 :  3.2e-10 5.6e-06 1.5e-03 1.2e-01
>  4 :  1.8e-12 2.3e-08 6.2e-06 4.7e-04 8.3e-02
>  5 :  3.7e-14 4.6e-09 1.9e-06 2.4e-04 1.3e-02 3.3e-01
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 4.712]
>  per=1 s=0.1 Evaluation at the middle of nodes
>  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
>  1 :  9.8e-01 1.0e+01
>  2 :  7.2e-01 1.3e+01 2.5e+02
>  3 :  7.2e-01 9.3e+00 1.5e+02 5.9e+03
>  4 :  7.1e-01 1.2e+01 1.1e+02 8.9e+03 1.5e+05
>  5 :  6.8e-01 1.0e+01 1.0e+02 2.5e+03 2.8e+05 1.5e+07
> ******************************************
>         Tests of splint and spalde
> ******************************************
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
>  per=0 s=0 N=20 [a, b] = [0.0, 6.283]  dx=0.628
>  k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
>  1    0.00000000   1.3e-16  0.0e+00  1.3e-01
>  2    0.00000000   8.6e-17  2.2e-16  3.1e-03  1.7e-02
>  3    0.00000000   1.1e-16  2.2e-16  9.8e-05  1.1e-02  1.3e-01
>  4    0.00000000   6.1e-16  2.2e-16  1.2e-04  8.9e-04  1.1e-02  1.3e-01
>  5   -0.00000000   2.7e-16  0.0e+00  1.4e-05  9.5e-05  1.1e-03  1.5e-02
> 4.6e-02
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
>  per=1 s=0 N=20 [a, b] = [0.0, 6.283]  dx=0.628
>  k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
>  1    0.00000000   1.7e-16  0.0e+00  1.3e-01
>  2   -0.00000000   3.0e-16  5.6e-16  3.1e-03  1.7e-02
>  3   -0.00000000   2.4e-16  4.4e-16  5.5e-05  8.3e-03  1.2e-01
>  4   -0.00000000   3.3e-16  4.4e-16  1.6e-05  2.7e-04  2.3e-03  3.9e-02
>  5   -0.00000000   4.9e-17  0.0e+00  2.0e-07  1.4e-05  4.1e-05  8.3e-03
> 1.2e-01
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
>  per=0 s=0 N=20 [a, b] = [0.628, 3.142]  dx=0.628
>  k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
>  1    1.79411389   1.5e-02  0.0e+00  1.3e-01
>  2    1.80893734   8.0e-05  2.2e-16  3.1e-03  1.7e-02
>  3    1.80899266   2.4e-05  2.2e-16  9.8e-05  1.1e-02  1.3e-01
>  4    1.80901586   1.1e-06  2.2e-16  1.2e-04  8.9e-04  1.1e-02  1.3e-01
>  5    1.80901683   1.6e-07  0.0e+00  1.4e-05  9.5e-05  1.1e-03  1.5e-02
> 4.6e-02
>
> f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
>  per=0 s=0 N=50 [a, b] = [0.628, 3.142]  dx=0.628
>  k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
>  1    1.80663580   2.4e-03  0.0e+00  4.8e-02
>  2    1.80901480   2.2e-06  0.0e+00  6.6e-04  6.3e-04
>  3    1.80901636   6.3e-07  0.0e+00  1.5e-06  1.3e-03  4.7e-02
>  4    1.80901699   1.2e-09  0.0e+00  1.6e-07  4.0e-06  6.0e-04  3.4e-03
>  5    1.80901699   2.3e-10  0.0e+00  3.9e-09  4.4e-07  1.3e-06  1.4e-03
> 4.8e-02
> ******************************************
>         Tests of sproot
> ******************************************
>   k  :     Roots of s(x) approx sin(x)  x in [0.0,15.0]:
> Traceback (most recent call last):
>   File "fitpack.py", line 1219, in <module>
>     test3(a=0,b=15)
>   File "fitpack.py", line 1150, in test3
>     print '  %d  : %s'%(k,`sproot(tck).tolist()`)
>   File "fitpack.py", line 668, in sproot
>     z,ier=_fitpack._sproot(t,c,k,mest)
> ValueError: negative dimensions are not allowed
>
> Perhaps this is an error in the fitpack routines? I tried downloading the
> fitpack source files but did not find the sources. There are no negative
> dimensions in any of the arrays.
>
> Help would be greatly appreciated

New description:

 I ran this in Mac OS X version 10.7.3. I installed the scipy/numpy/etc
 tools as described in the SciPy superpack website
 (http://fonnesbeck.github.com/ScipySuperpack/).

 Running the tests of fitpack results in the following:
 {{{
 neo.local:interpolate] 678 >python fitpack.py
 ******************************************
         Tests of splrep and splev
 ******************************************

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
  per=0 s=1e-06 Evaluation at the middle of nodes
  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
  1 :  8.1e-04 7.3e-02
  2 :  2.3e-05 3.3e-04 2.3e-01
  3 :  7.1e-07 4.4e-05 2.4e-03 2.9e-01
  4 :  9.2e-07 1.1e-04 6.3e-03 1.3e-01 1.4e+00
  5 :  8.8e-07 6.9e-05 3.5e-03 7.0e-02 6.0e-01 2.4e+00

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
  per=0 s=0 Evaluation at the middle of nodes
  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
  1 :  7.8e-04 7.3e-02
  2 :  1.5e-07 9.3e-04 1.6e-01
  3 :  2.3e-09 3.7e-06 4.3e-04 7.5e-02
  4 :  4.7e-11 1.4e-06 2.8e-04 1.5e-02 4.4e-01
  5 :  7.5e-13 2.8e-08 6.1e-06 3.9e-04 1.0e-02 1.7e-01

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
  per=0 s=0 Evaluation at knots
  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
  1 :  0.0e+00 2.5e-01
  2 :  1.9e-07 1.9e-03 3.6e-01
  3 :  3.6e-31 5.6e-06 1.4e-03 2.6e-01
  4 :  6.9e-11 2.7e-06 5.4e-04 3.0e-02 7.1e-01
  5 :  2.0e-31 5.4e-08 1.2e-05 7.7e-04 1.8e-02 3.5e-01

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
  per=1 s=0 Evaluation at the middle of nodes
  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
  1 :  7.8e-04 7.3e-02
  2 :  1.5e-07 9.3e-04 1.6e-01
  3 :  2.2e-09 5.2e-07 4.4e-05 7.0e-02
  4 :  4.1e-12 2.4e-08 6.3e-07 7.6e-04 1.6e-01
  5 :  1.2e-14 3.7e-12 2.5e-10 5.1e-07 4.3e-05 7.0e-02

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
  per=1 s=0 Evaluation at knots
  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
  1 :  6.3e-32 2.5e-01
  2 :  2.0e-06 1.9e-03 3.7e-01
  3 :  7.7e-31 3.3e-08 6.8e-04 2.5e-01
  4 :  1.4e-10 3.1e-08 1.3e-06 1.7e-03 3.6e-01
  5 :  7.7e-31 4.2e-13 1.9e-09 1.8e-08 6.8e-04 2.5e-01

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 4.712] > [0.0, 4.712]
  per=0 s=0 Evaluation at the middle of nodes
  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
  1 :  2.4e-04 5.1e-02
  2 :  5.9e-08 5.8e-05 4.6e-02
  3 :  3.2e-10 5.6e-06 1.5e-03 1.2e-01
  4 :  1.8e-12 2.3e-08 6.2e-06 4.7e-04 8.3e-02
  5 :  3.7e-14 4.6e-09 1.9e-06 2.4e-04 1.3e-02 3.3e-01

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 4.712]
  per=1 s=0.1 Evaluation at the middle of nodes
  k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
  1 :  9.8e-01 1.0e+01
  2 :  7.2e-01 1.3e+01 2.5e+02
  3 :  7.2e-01 9.3e+00 1.5e+02 5.9e+03
  4 :  7.1e-01 1.2e+01 1.1e+02 8.9e+03 1.5e+05
  5 :  6.8e-01 1.0e+01 1.0e+02 2.5e+03 2.8e+05 1.5e+07
 ******************************************
         Tests of splint and spalde
 ******************************************

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
  per=0 s=0 N=20 [a, b] = [0.0, 6.283]  dx=0.628
  k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
  1    0.00000000   1.3e-16  0.0e+00  1.3e-01
  2    0.00000000   8.6e-17  2.2e-16  3.1e-03  1.7e-02
  3    0.00000000   1.1e-16  2.2e-16  9.8e-05  1.1e-02  1.3e-01
  4    0.00000000   6.1e-16  2.2e-16  1.2e-04  8.9e-04  1.1e-02  1.3e-01
  5   -0.00000000   2.7e-16  0.0e+00  1.4e-05  9.5e-05  1.1e-03  1.5e-02
 4.6e-02

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
  per=1 s=0 N=20 [a, b] = [0.0, 6.283]  dx=0.628
  k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
  1    0.00000000   1.7e-16  0.0e+00  1.3e-01
  2   -0.00000000   3.0e-16  5.6e-16  3.1e-03  1.7e-02
  3   -0.00000000   2.4e-16  4.4e-16  5.5e-05  8.3e-03  1.2e-01
  4   -0.00000000   3.3e-16  4.4e-16  1.6e-05  2.7e-04  2.3e-03  3.9e-02
  5   -0.00000000   4.9e-17  0.0e+00  2.0e-07  1.4e-05  4.1e-05  8.3e-03
 1.2e-01

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
  per=0 s=0 N=20 [a, b] = [0.628, 3.142]  dx=0.628
  k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
  1    1.79411389   1.5e-02  0.0e+00  1.3e-01
  2    1.80893734   8.0e-05  2.2e-16  3.1e-03  1.7e-02
  3    1.80899266   2.4e-05  2.2e-16  9.8e-05  1.1e-02  1.3e-01
  4    1.80901586   1.1e-06  2.2e-16  1.2e-04  8.9e-04  1.1e-02  1.3e-01
  5    1.80901683   1.6e-07  0.0e+00  1.4e-05  9.5e-05  1.1e-03  1.5e-02
 4.6e-02

 f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.283] > [0.0, 6.283]
  per=0 s=0 N=50 [a, b] = [0.628, 3.142]  dx=0.628
  k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
  1    1.80663580   2.4e-03  0.0e+00  4.8e-02
  2    1.80901480   2.2e-06  0.0e+00  6.6e-04  6.3e-04
  3    1.80901636   6.3e-07  0.0e+00  1.5e-06  1.3e-03  4.7e-02
  4    1.80901699   1.2e-09  0.0e+00  1.6e-07  4.0e-06  6.0e-04  3.4e-03
  5    1.80901699   2.3e-10  0.0e+00  3.9e-09  4.4e-07  1.3e-06  1.4e-03
 4.8e-02
 ******************************************
         Tests of sproot
 ******************************************
   k  :     Roots of s(x) approx sin(x)  x in [0.0,15.0]:
 Traceback (most recent call last):
   File "fitpack.py", line 1219, in <module>
     test3(a=0,b=15)
   File "fitpack.py", line 1150, in test3
     print '  %d  : %s'%(k,`sproot(tck).tolist()`)
   File "fitpack.py", line 668, in sproot
     z,ier=_fitpack._sproot(t,c,k,mest)
 ValueError: negative dimensions are not allowed
 }}}
 Perhaps this is an error in the fitpack routines? I tried downloading the
 fitpack source files but did not find the sources. There are no negative
 dimensions in any of the arrays.

 Help would be greatly appreciated

--

Comment(by pv):

 Note that the tests in `fitpack.py` are mostly "developer tests" that may
 or may not be up to date, as they are not a real part of Scipy's test
 suite --- which can be run with `scipy.test()`.

 Is this a problem in a real code for you?

 However, something indeed seems to be strange with sproot:
 {{{
 import numpy as np
 from scipy.interpolate import splrep, sproot

 def foo():
     _fitpack._sproot

 x = np.linspace(0, 15, 20)
 v = np.sin(x)
 for k in range(1,6):
     tck = splrep(x, v, s=0)
     print sproot(tck)
 }}}
 This fails with MemoryError, unless the `foo()` function (which is not
 called!) is removed. Valgrind indicates that uninitialized memory is used
 at some point, so there's certainly a bug here.

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


More information about the Scipy-tickets mailing list