On Tuesday 12 September 2006 13:33, Sebastian Haase wrote: > Hi ! > I have a nice ndarray image viewer built on OpenGL - one annoyance though > is that is crashes if the array contains any NaN, or inf, ... > > So, I found N.nan_to_num - but OpenGL (read: video cards) supports only > single precision float (N.float32) > > So I get this: > >>> N.nan_to_num([N.inf]) > > [ 1.79769313e+308] > > >>> N.nan_to_num([N.inf]).astype(N.float32) > > [ inf] > > Could nan_to_num() get an optional dtype argument ? > > Thanks, > Sebastian Haase
OK - sorry for the noise... this is how to do it: >>> N.nan_to_num( N.array([N.nan,N.inf,-N.inf],N.float32) ) [ 0.00000000e+00 3.40282347e+38 -3.40282347e+38] In the meantime I noticed that there is a N.asarray_chkfinite() function but no equivalent for N.asanyarray() ! Should N.asanyarray_chkfinite() be added !? -Sebastian ------------------------------------------------------------------------- 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion