[Numpy-tickets] [NumPy] #673: change the error handling code in lapack_lite to return a python exception

NumPy numpy-tickets@scipy....
Thu Feb 28 08:09:30 CST 2008


#673: change the error handling code in lapack_lite to return a python exception
---------------------------+------------------------------------------------
 Reporter:  Zbyszek_Szmek  |       Owner:  somebody
     Type:  defect         |      Status:  new     
 Priority:  normal         |   Milestone:  1.0.5   
Component:  numpy.linalg   |     Version:  none    
 Severity:  normal         |    Keywords:          
---------------------------+------------------------------------------------
 Function xerbla_ is called when an error (e.g. improper argument) is
 detected in functions converted to C from Fortran. Citing the manpage for
 xerbla from the lapack3 library:

   XERBLA is an error handler for the LAPACK routines.  It is called by an
 LAPACK routine
   if an input   parameter has an invalid value.
   A message is printed and execution stops.

   Installers may consider modifying the STOP statement in order to call
 system-specific
   exception-handling facilities.

 I believe that it should indeed be customized for lapack_lite in numpy,
 because
   a. it tries to print a message using Fortran I/O, which doesn't always
 work
   b. calls s_stop, which simply exits the program returning 0

 The Python interface validates all arguments, so that the error-handling
 code in functions converted from Fortran is not called, but in case it
 happens, an exception should be thrown.

 An example:
 {{{
   import numpy
   Ainv = numpy.linalg.inv( numpy.matrix( numpy.zeros((0,0)) ) )
   print Ainv
 }}}

 On suse 10.3 (64bits) with python-numpy-1.0.4-0.pm.2 running such a
 program gives no output (Fortran I/O doesn't work properly?) and returns
 0.
 On debian with python-numpy-10.0.3-1 it says:
 {{{
    ** On entry to DGESV  parameter number  4 had an illegal value
 }}}
 and returns 0.

 With the attached patch, python returns 1 after printing:
 {{{
   Traceback (most recent call last):
   File "test_linalg_inv.py", line 2, in <module>
     Ainv = numpy.linalg.inv( numpy.matrix( numpy.zeros((0,0)) ) )
   File "/usr/lib64/python2.5/site-packages/numpy/linalg/linalg.py", line
 246, in inv
     return wrap(solve(a, identity(a.shape[0], dtype=a.dtype)))
   File "/usr/lib64/python2.5/site-packages/numpy/linalg/linalg.py", line
 193, in solve
     return b.transpose().astype(result_t)
   ValueError: On entry to DGESV parameter number 4 had an illegal value
 }}}

 Of course all this is caused by a small bug in the python wrapper for
 dsegv.

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/673>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list