[Numpy-discussion] nan_to_num() SystemException

Jonathan Taylor jonathan.taylor at stanford.edu
Sun Jul 2 16:44:42 EDT 2006


Ooops -- I posted this same question. Sorry.

One more bit of info:

ipdb> maxf
array(1.7976931348623157e+308)
ipdb> minf
-1.7976931348623157e+308
ipdb> type(maxf)
<type 'numpy.ndarray'>
ipdb> type(minf)
<type 'float64scalar'>
ipdb> y[are_inf] = float(maxf)
ipdb>
ipdb> y[are_inf]
array([], dtype=float64)



--Jonathan


Tim Leslie wrote:
> Hi All,
>
> The following script:
>
> import numpy as N
> print N.__version__
> a = N.array([1,2,3,4], dtype=N.float64)
> a.dtype = a.dtype.newbyteorder('big')
> print N.nan_to_num(a)
>
> gives the following exception:
>
> 0.9.9.2707
> Traceback (most recent call last):
>   File "memmap_nan.py", line 5, in ?
>     print N.nan_to_num(a)
>   File "/usr/lib/python2.4/site-packages/numpy/lib/type_check.py",
> line 127, in nan_to_num
>     y[are_inf] = maxf
> SystemError: error return without exception set
>
> Could someone shed some light on this? I'm at a bit of a loss as where
> to go. I had a poke around inside type_check.py but didn't get very
> far. I confirmed that are_inf in type_check.py is [False, False,
> False, False], as expected. I changed the value of maxf to different
> values (0, maxf+1, maxf-1, maxf+0.00000001, minf, 37), and with any of
> these different values the SystemError goes away. Beyond that, I'm not
> sure how to chase this one down.
>
> Cheers,
>
> Tim Leslie
>
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>   

-- 

------------------------------------------------------------------------
Jonathan Taylor                           Tel:   650.723.9230
Dept. of Statistics                       Fax:   650.725.8977
Sequoia Hall, 137                         www-stat.stanford.edu/~jtaylo
390 Serra Mall
Stanford, CA 94305





More information about the NumPy-Discussion mailing list