[Scipy-tickets] [SciPy] #1428: use custom warnings instead of print statements

SciPy Trac scipy-tickets@scipy....
Thu Apr 28 13:48:10 CDT 2011


#1428: use custom warnings instead of print statements
-----------------------+----------------------------------------------------
 Reporter:  josefpktd  |       Owner:  somebody
     Type:  defect     |      Status:  new     
 Priority:  normal     |   Milestone:          
Component:  Other      |     Version:  0.9.0   
 Keywords:             |  
-----------------------+----------------------------------------------------
 use custom warnings instead of print statements

 eg. InterpolationWarning, OptimizationWarning, ....

 {{{

 From: Yaroslav Halchenko

 BUT scipy does use straight printouts of warnings


 $> dpkg -L python-scipy | grep '\.py' | xargs grep -i "print.*warn" | head
 /usr/share/pyshared/scipy/signal/signaltools.py:        print
 "Warning: imaginary part of x ignored."
 /usr/share/pyshared/scipy/signal/signaltools.py:        print
 "Warning: imaginary part of x ignored."
 /usr/share/pyshared/scipy/signal/filter_design.py:        print
 "Warning, order is zero...check input parametegstop."
 /usr/share/pyshared/scipy/interpolate/fitpack.py:                if
 quiet<2:print 'Warning: Setting x[%d][%d]=x[%d][0]'%(i,m,i)
 /usr/share/pyshared/scipy/interpolate/fitpack.py:            print
 "Warning: "+_iermess[ier][0]
 /usr/share/pyshared/scipy/interpolate/fitpack.py:            print
 "Warning: "+_iermess[ier][0]
 /usr/share/pyshared/scipy/interpolate/fitpack.py:            print
 "Warning: the number of zeros exceeds mest"
 /usr/share/pyshared/scipy/interpolate/fitpack.py:            print
 "Warning: "+_iermess2[ierm][0]
 /usr/share/pyshared/scipy/integrate/quadpack.py:            print
 "Warning: " + msg
 /usr/share/pyshared/scipy/maxentropy/maxentutils.py:#    print
 "Warning: could not load the fast FORTRAN library for logsumexp()."


 (git)novo:~/proj/scipy[tags/v0.9.0]git
 $> git grep -i 'print .*Warning:'
 scipy/integrate/quadpack.py:            print "Warning: " + msg
 scipy/interpolate/fitpack.py:                if quiet<2:print
 'Warning: Setting x[%d][%d]=x[%d][0]'%(i,m,i)
 scipy/interpolate/fitpack.py:            print "Warning:
 "+_iermess[ier][0]
 scipy/interpolate/fitpack.py:            print "Warning:
 "+_iermess[ier][0]
 scipy/interpolate/fitpack.py:            print "Warning: the number of
 zeros exceeds mest"
 scipy/interpolate/fitpack.py:            print "Warning:
 "+_iermess2[ierm][0]
 scipy/maxentropy/maxentutils.py:#    print "Warning: could not load
 the fast FORTRAN library for logsumexp()."
 scipy/maxentropy/maxentutils.py:        print "Warning: OverflowError
 using numpy.exp(). Using slower Python"\
 scipy/optimize/anneal.py:                print "Warning: Cooled to %f
 at %s but this is not" \
 scipy/optimize/anneal.py:            print "Warning: Maximum number of
 iterations exceeded."
 scipy/optimize/optimize.py:            print "Warning: Maximum number
 of function evaluations has "\
 scipy/optimize/optimize.py:            print "Warning: Maximum number
 of iterations has been exceeded"
 scipy/optimize/optimize.py:            print "Warning: Desired error
 not necessarily achieved" \
 scipy/optimize/optimize.py:            print "Warning: Maximum number
 of iterations has been exceeded"
 scipy/optimize/optimize.py:            print "Warning: Desired error
 not necessarily achieved due to precision loss"
 scipy/optimize/optimize.py:            print "Warning: Maximum number
 of iterations has been exceeded"
 scipy/optimize/optimize.py:            print "Warning: Maximum number
 of iterations has been exceeded"
 scipy/optimize/optimize.py:            print "Warning: Maximum number
 of function evaluations has "\
 scipy/optimize/optimize.py:            print "Warning: Maximum number
 of iterations has been exceeded"
 scipy/optimize/optimize.py:            print "Warning: Final
 optimization did not succeed"
 scipy/signal/signaltools.py:        print "Warning: imaginary part of
 x ignored."
 scipy/signal/signaltools.py:        print "Warning: imaginary part of
 x ignored."
 scipy/sparse/linalg/dsolve/umfpack/umfpack.py:
 print 'warning: singular matrix'
 scipy/sparse/linalg/dsolve/umfpack/umfpack.py:
 print 'warning: recomputing symbolic'
 scipy/sparse/linalg/dsolve/umfpack/umfpack.py:            print
 'warning: (almost) singular matrix! '\
 scipy/weave/blitz_tools.py:            print 'warning: compilation
 failed. Executing as python code'
 scipy/weave/build_tools.py:        #print "warning: build directory
 was not part of python path."\
 scipy/weave/build_tools.py:        print "warning: specified temp_dir
 '%s' does not exist " \
 scipy/weave/build_tools.py:            print "warning:, neither the
 module's directory nor the "\
 scipy/weave/build_tools.py:            print 'WARNING: failed to build
 import library for gcc. Linking will fail.'
 scipy/weave/catalog.py:        print 'warning: default directory is
 not write accessible.'
 scipy/weave/catalog.py:        print 'warning: default directory is
 not write accessible.'
 scipy/weave/catalog.py:            print 'warning: unable to repair
 catalog entry\n %s\n in\n %s' % \
 scipy/weave/swig2_spec.py:            print "WARNING: Multiple SWIG
 versions detected.  No version was"

 }}}

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


More information about the Scipy-tickets mailing list