[Numpy-discussion] old-Numeric: OverflowError on exp(-760)
Sasha
ndarray at mac.com
Mon Jun 12 17:15:15 CDT 2006
I don't know about numarray, but the difference between Numeric and
python math module stems from the fact that the math module ignores
errno set by C library and only checks for infinity. Numeric relies
on errno exclusively, numpy ignores errors by default:
>>> import numpy,math,Numeric
>>> numpy.exp(-760)
0.0
>>> math.exp(-760)
0.0
>>> Numeric.exp(-760)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OverflowError: math range error
>>> numpy.exp(760)
inf
>>> math.exp(760)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OverflowError: math range error
>>> Numeric.exp(760)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OverflowError: math range error
I would say it's a bug in Numeric, so you are out of luck.
Unfortunalely, even MA.exp(-760) does not work, but this is easy to fix:
>>> exp = MA.masked_unary_operation(Numeric.exp,0.0,MA.domain_check_interval(-100,100))
>>> exp(-760).filled()
0
You would need to replace -100,100 with the bounds appropriate for your system.
On 6/12/06, Sebastian Haase <haase at msg.ucsf.edu> wrote:
> Hi,
> I'm using Konrad Hinsen's LeastSquares.leastSquaresFit for a convenient way to
> do a non linear minimization. It uses the "old" Numeric module.
> But since I upgraded to Numeric 24.2 I get OverflowErrors that I tracked down
> to
> >>> Numeric.exp(-760.)
> Traceback (most recent call last):
> File "<input>", line 1, in ?
> OverflowError: math range error
>
> >From numarray I'm used to getting this:
> >>> na.exp(-760)
> 0.0
>
> Mostly I'm confused because my code worked before I upgraded to version 24.2.
>
> Thanks for any hints on how I could revive my code...
> -Sebastian Haase
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
More information about the Numpy-discussion
mailing list