On Saturday 10 November 2007 04:52:31 pm Michael McNeil Forbes wrote:
> On 10 Nov 2007, at 7:51 AM, Michael V. DePalatis wrote:
> ...
>
> > I recently discovered that if I import
> > pylab after importing numpy, I get tons of warnings:
> >
> > Warning: divide by zero encountered in divide
> > Warning: invalid value encountered in multiply
> > Warning: overflow encountered in long_scalars
> >
> > with the last occurring far most often (interestingly, I do not get
> > these warnings if pylab is imported before numpy). My question then is
> > two fold:
> >
> > (1) Why do I only get these warnings depending on when I import pylab?
>
> I am not sure: with the latest svn builds I get the message both
> ways. Maybe the default error handling is different between the
> version of numpy and matplotlib you have installed.
>
> > (2) (a more general python question) How can I get these warning
> > messages to give me *useful* information, such as where the
> > problems
> > are happening?
>
> In numpy you can cause these to be exceptions by setting
>
> numpy.seterr("raise")
>
> Now you can see exactly where the exception happens.
>
> If you don't want to stop execution at this point, you use a
> callback. This will pop-open the debugger at the point of error, but
> allow you to continue.
>
> def f(err,flag):
> import pdb; pdb.set_trace()
>
> numpy.seterr("call")
> numpy.seterrcall(f)
>
> In general, with python warnings you can change them to exceptions by
> using warnings.simplefilter('error',Warning) (see http://
> docs.python.org/lib/module-warnings.html for details), however numpy
> does not seem to issue warnings, instead opting to directly print a
> message. (Anyone know why the warnings library is not used? Is this
> a bug that should be fixed?)
It would be better to discuss this on the numpy mailing list.
Darren
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users