BTW, here is the relevant explanation from mathmodule.c: /* ANSI C generally requires libm functions to set ERANGE * on overflow, but also generally *allows* them to set * ERANGE on underflow too. There's no consistency about * the latter across platforms. * Alas, C99 never requires that errno be set. * Here we suppress the underflow errors (libm functions * should return a zero on underflow, and +- HUGE_VAL on * overflow, so testing the result for zero suffices to * distinguish the cases). */
On 6/12/06, Sasha <[EMAIL PROTECTED]> wrote: > 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 <[EMAIL PROTECTED]> 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@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > > > _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion