[Numpy-discussion] ieeespecial

Darren Dale dd55 at cornell.edu
Sun Oct 10 13:57:43 CDT 2004


On Sunday 10 October 2004 03:47 pm, Darren Dale wrote:
> Hello,
>
> I am getting invalid numeric result exceptions when dividing a complex
> array by zero. Is this the desired behavior?
>
> Also, while trying to find a way around the above problem, I ran
> ieeespecial.test and got the following output. I am running numarray 1.1 on
> python 2.3.3. Todd, this might be correlated with the numerix package in
> matplotlib. I tried importing numarray and ieeespecial without matplotlib
> and the ieeespecial.test was successful.
>

On a related note, ieeespecial.getnan appears to be incompatible with complex 
arrays, see below. I didnt mention in my last email that I built numarray for 
my existing blas/lapack libraries, will this change the behavior on my system 
from the default?

Thanks,
Darren

>>> from numarray import *
>>> from numarray.ieeespecial import *
>>> b=arange(10,typecode=Complex64)
>>> a=b/0
Warning: Encountered invalid numeric result(s)  in divide
>>> a
array([              nan             +nanj,
                     nan             +nanj,
                     nan             +nanj,
                     nan             +nanj,
                     nan             +nanj,
                     nan             +nanj,
                     nan             +nanj,
                     nan             +nanj,
                     nan             +nanj,
                     nan             +nanj])
>>> getnan(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/numarray/ieeespecial.py", line 117, 
ingetnan
    return _spec.index(a, _spec.NAN)
  File "/usr/lib/python2.3/site-packages/numarray/ieeespecial.py", line 95, in 
index
    return _na.nonzero(mask(a, msk))
  File "/usr/lib/python2.3/site-packages/numarray/ieeespecial.py", line 87, in 
mask
    f = _na.ieeemask(a, m)
  File "/usr/lib/python2.3/site-packages/numarray/ufunc.py", line 883, in 
_cache_miss2
    mode, win1, win2, wout, cfunc, ufargs = \
  File "/usr/lib/python2.3/site-packages/numarray/ufunc.py", line 929, in 
_setup
    convtype1, convtype2, outtype, ucfunc \
  File "/usr/lib/python2.3/site-packages/numarray/ufunc.py", line 471, in 
_typematch
    newInputSignature = (self._typePromoter(intype, atypelist),)*2
  File "/usr/lib/python2.3/site-packages/numarray/ufunc.py", line 498, in 
_typePromoter
    raise TypeError("unable to find type to promote to")
TypeError: unable to find type to promote to

>>> getnan(a.real)
(array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),)
>>>  




More information about the Numpy-discussion mailing list