[SciPy-dev] Dealing with precision problem: warning vs raise

Robert Kern robert.kern@gmail....
Wed Nov 5 20:28:40 CST 2008

On Wed, Nov 5, 2008 at 20:05, David Cournapeau <cournape@gmail.com> wrote:
> Hi,
> I was looking at bug #651, related to finding the roots of a
> polynomial with too small coefficients. Currently, the small values
> are discarded by the function in #651, which I find a bid surprising
> (it may not be obvious to the user why it gets no zero for a
> polynomial of order N). Wouldn't it be better to raise an exception or
> a at least a warning instead (I was thinking about doing that in
> numpy.roots instead, but that may be too drastic, as it would break
> some code - maybe it is desirable, though, as the values in that case
> are more or less meaningless )

Issue a warning using warnings.warn(). Users may use the warnings
module to turn it into an exception should they so desire.

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

More information about the Scipy-dev mailing list