[Numpy-discussion] isinf raises in inf

Pauli Virtanen pav@iki...
Fri Jul 16 03:02:30 CDT 2010


Testing with arithmetic can raise overflows and underflows.

I think the correct isinf is to compare to NPY_INFINITY and -NPY_INFINITY. Patch is attached to #1500

----- Alkuperäinen viesti -----
> On Thu, Jul 15, 2010 at 6:42 PM, John Hunter <jdh2358@gmail.com> wrote:
> 
> > On Thu, Jul 15, 2010 at 7:27 PM, Charles R Harris
> > <charlesr.harris@gmail.com> wrote:
> > > 
> > > 
> > > On Thu, Jul 15, 2010 at 6:11 PM, John Hunter <jdh2358@gmail.com>
> > > wrote:
> > > > 
> > > > On Thu, Jul 15, 2010 at 6:14 PM, Eric Firing <efiring@hawaii.edu>
> > wrote:
> > > > > Is it certain that the Solaris compiler lacks isinf?   Is it
> > > > > possible that it has it, but it is not being detected?
> > > > 
> > > > Just to clarify, I'm not using the sun compiler, but gcc-3.4.3 on
> > solaris
> > > > x86
> > > 
> > > Might be related to this thread.   What version of numpy are you
> > > using?
> > 
> > svn HEAD (2.0.0.dev8480)
> > 
> > After reading the thread you suggested, I tried forcing the
> > 
> > CFLAGS=-DNPY_HAVE_DECL_ISFINITE
> > 
> > flag to be set, but this is apparently a bad idea for my platform...
> > 
> > File
> > "/home/titan/johnh/dev/lib/python2.4/site-packages/numpy/core/__init__.py",
> > line 5, in ?
> > import multiarray
> > ImportError: ld.so.1: python: fatal: relocation error: file
> > /home/titan/johnh/dev/lib/python2.4/site-packages/numpy/core/multiarray.so:
> > symbol isfinite: referenced symbol not found
> > 
> > so while I think my bug is related to that thread, I don't see
> > anything in that thread to help me fix my problem.   Or am I missing
> > something?
> > __
> > 
> 
> Can you try out this patch without David's fixes?
> 
> diff --git a/numpy/core/include/numpy/npy_math.h
> b/numpy/core/include/numpy/npy_
> index d53900e..341fb58 100644
> --- a/numpy/core/include/numpy/npy_math.h
> +++ b/numpy/core/include/numpy/npy_math.h
> @@ -151,13 +151,13 @@ double npy_spacing(double x);
>   #endif
> 
>   #ifndef NPY_HAVE_DECL_ISFINITE
> -       #define npy_isfinite(x) !npy_isnan((x) + (-x))
> +       #define npy_isfinite(x) (((x) + (x)) != (x) && (x) == (x))
>   #else
>           #define npy_isfinite(x) isfinite((x))
>   #endif
> 
>   #ifndef NPY_HAVE_DECL_ISINF
> -       #define npy_isinf(x) (!npy_isfinite(x) && !npy_isnan(x))
> +       #define npy_isinf(x) (((x) + (x)) == (x) && (x) != 0)
>   #else
>           #define npy_isinf(x) isinf((x))
>   #endif
> 
> 
> Chuck



More information about the NumPy-Discussion mailing list