[MATRIX-SIG] Fix to NumPy10
L. Busby
busby@icf.llnl.gov
Fri, 6 Mar 98 13:09:01 PST
>Is there any files or pages having information (plans) on future
>development of NumPy? I'd like to to read what features are to be
>included in or excluded. That "TODO.TXT" file in distribution seems to
>be rather short :-), though Fortran direct support (at last) is a great
>idea!
TODO.TXT is all there is for now. If it seems short to you, what
else do you think should be there? I'm sure many of us would like to
read what features are to be included or excluded, but that's really
what this mailing list is for.
>Look - another bug? (I use Win'95, Python 1.5, Numpy10)
>Maybe it is a supposed behaviour, but ...
>>>> r = arange(13)
>>>> r
>array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
>>>> ar=pow(10,r)
>### ar=10**r produce the same
>>>> ar
>array([1, 10, 100,1000, 10000,100000,
> 1000000, 10000000, 100000000, 1000000000,
> 1410065408, 1215752192, -727379968])
>
>How do you like it? I do not.
>never can be 10**10 =1410065408
>
>of course, 10.0**r gives "right" result.
>
>Andy K.
When item 4 of TODO is finished, you'll be able to turn on a signal
handler for SIGFPE and catch the overflow you observed above. (Odd
though it may seem, integer divide by zero and overflow will generate
SIGFPE in most implementations.) For the moment, it's neither a bug
nor a feature. Until Python itself was capable of handling SIGFPE,
it was impossible to do much of anything about it in NumPy (unless
you were willing to give up most of NumPy's speed advantage by
checking all operands).
Note that many of the functions in the Standard math library do check
the domain and/or range of their arguments and/or results. (And they
will set errno to EDOM or ERANGE if an error occurs.) That's the
difference between fast_umath and umath modules. The first doesn't
check the value of errno after each call to a library math function,
the second does. This will trap some errors, but not integer
exponentiation, as you discovered.
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________