replace print by custom Warnings
should scipy get additional custom warnings instead of print statements ? eg. InterpolationWarning, OptimizationWarning, .... Josef ---------- Forwarded message ---------- From: Yaroslav Halchenko <debian@onerussian.com> Date: Wed, Apr 27, 2011 at 10:45 AM Subject: Re: [pymvpa] minor bug ? To: pkg-exppsy-pymvpa@lists.alioth.debian.org On Wed, 27 Apr 2011, josef.pktd@gmail.com wrote:
You can just temporarily turn off the warnings in the test, if you add test for corner cases. That's how Ralf silenced the scipy test suite.
and we silence our tests ;-) but apparently not externals checks
If there are print statements, then it would be a bug in scipy, but these look like "Warnings" where you have control over what happens to them.
Ha -- poking in my eyes works at times! Thanks Josef! Apparently it is indeed numpy warnings so np.seterr(all="ignore") was effective! BUT scipy does use straight printouts of warnings, and that is what made me believe that it was one of them: $> 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" -- =------------------------------------------------------------------= Keep in touch www.onerussian.com Yaroslav Halchenko www.ohloh.net/accounts/yarikoptic _______________________________________________ Pkg-ExpPsy-PyMVPA mailing list Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org http://lists.alioth.debian.org/mailman/listinfo/pkg-exppsy-pymvpa
On Wed, Apr 27, 2011 at 09:56, <josef.pktd@gmail.com> wrote:
should scipy get additional custom warnings instead of print statements ?
eg. InterpolationWarning, OptimizationWarning, ....
Is that a volunteer I smell? :-) Yes, these print statements should become warnings wherever possible. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
On Wed, Apr 27, 2011 at 2:05 PM, Robert Kern <robert.kern@gmail.com> wrote:
On Wed, Apr 27, 2011 at 09:56, <josef.pktd@gmail.com> wrote:
should scipy get additional custom warnings instead of print statements ?
eg. InterpolationWarning, OptimizationWarning, ....
Is that a volunteer I smell? :-)
I'm currently not smelly enough :), but I created http://projects.scipy.org/scipy/ticket/1428 ( However, after trying for a few hours yesterday, I managed to authenticate with github so I can push something there. git(gui) is kind of fun, at least for bugfixes. ) Josef
Yes, these print statements should become warnings wherever possible.
-- Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
On Thu, Apr 28, 2011 at 2:52 PM, <josef.pktd@gmail.com> wrote:
On Wed, Apr 27, 2011 at 2:05 PM, Robert Kern <robert.kern@gmail.com> wrote:
On Wed, Apr 27, 2011 at 09:56, <josef.pktd@gmail.com> wrote:
should scipy get additional custom warnings instead of print statements ?
eg. InterpolationWarning, OptimizationWarning, ....
Is that a volunteer I smell? :-)
I'm currently not smelly enough :), but I created http://projects.scipy.org/scipy/ticket/1428
( However, after trying for a few hours yesterday, I managed to authenticate with github so I can push something there. git(gui) is kind of fun, at least for bugfixes. )
Josef
Yes, these print statements should become warnings wherever possible.
A first attempt, just to get started https://github.com/josef-pkt/scipy/commit/548a8925c36c2627f0acb8102a835393de... in optimization, do we drop the disp option for warnings and the associated prints ? there still remains the final print for success. Is there a way to set the default warning level for the UserWarning to "always" ? Still needs tests, examples that raise the warnings. (I'm only partially familiar with the internal details of scipy.optimize, interpolate, ... ) Josef
-- Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
participants (2)
-
josef.pktd@gmail.com
-
Robert Kern