[Numpy-discussion] should get rid of the annoying numpy STDERR output

eat e.antero.tammi@gmail....
Thu Mar 24 09:52:48 CDT 2011


Hi

On Thu, Mar 24, 2011 at 4:17 PM, Skipper Seabold <jsseabold@gmail.com>wrote:

> On Thu, Mar 24, 2011 at 9:45 AM, Ralf Gommers
> <ralf.gommers@googlemail.com> wrote:
> > 2011/3/24 Dmitrey <tmp50@ukr.net>:
> >>
> >> Hi
> >>
> >> 2011/3/24 Dmitrey <tmp50@ukr.net>
> >>>
> >>> >>> from numpy import inf, array
> >>> >>> inf*0
> >>> nan
> >>>
> >>> (ok)
> >>>
> >>> >>> array(inf) * 0.0
> >>> StdErr: Warning: invalid value encountered in multiply
> >>> nan
> >>>
> >>> My cycled calculations yields this thousands times slowing computations
> >>> and making text output completely non-readable.
> >>
> >> Would old= seterr(invalid= 'ignore') be sufficient for you?
> >>
> >> yes for me, but I'm not sure for all those users who use my soft. Maybe
> it
> >> will hide some bugs in their objective functions and nonlinear
> constraints
> >> in numerical optimization and nonlinear equation systems.
> >
> > If we do what you request in your message subject your users will have
> > the same issue.
> >
> > You can wrap (parts of) your code in something like:
> >  olderr = seterr(invalid= 'ignore')
> >  <do stuff>
> >  seterr(**olderr)
> >
>
> Also, as Robert pointed out to me before np.errstate is a
> context-manager for ignoring these warnings. I often wrap optimization
> code with it.
>
I didn't realize that its context-manager, but that's really create!
(Perhaps documents could reflect that.)

Regards,
eat

>
> In [3]: np.array(np.inf)*0.
> Warning: invalid value encountered in multiply
> Out[3]: nan
>
> In [4]: with np.errstate(all='ignore'):
>   ...:     np.array(np.inf)*0.
>   ...:
>   ...:
> Out[4]: nan
>
> In [5]: np.array(np.inf)*0.
> Warning: invalid value encountered in multiply
> Out[5]: nan
>
> Skipper
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110324/577fea0c/attachment.html 


More information about the NumPy-Discussion mailing list