[Numpy-discussion] Infinity definitions

Anne Archibald peridot.faceted at gmail.com
Thu Apr 10 14:57:57 EDT 2008


On 10/04/2008, Travis E. Oliphant <oliphant at enthought.com> wrote:
> Bruce Southey wrote:
>  > Hi,
>  > Since we are discussing namespace and standardization, I am curious in
>  > why there are multiple definitions for defining infinity in numpy when
>  > perhaps there should be two (one for positive infinity and one for
>  > negative infinity). I really do understand that other people have use of
>  > these definitions and that it is easier to leave them in than take them
>  > out. Also, it is minor reduction in namespace because I do know that
>  > much of the namespace is either defining variables (like different
>  > floats and complex numbers) or mathematical functions (like logs and
>  > trig functions).
>  >
>  > Currently we have:
>  > numpy.Inf
>  > numpy.Infinity
>  > numpy.inf
>  > numpy.infty
>  > numpy.NINF
>  > numpy.PINF
>  >
>  > Most of these are defined in numeric.py: 'Inf = inf = infty = Infinity =
>  > PINF'
>  > In the f2py/tests subdirectories, the files return_real.py and
>  > return_complex.py uses both 'inf','Infinity'.
>  > The only occurrence of NINF and PINF are in core/src/umathmodule.c but I
>  > don't see any other usage.
>  > There does not seem to be any use of 'infty'.
>  >
>
> I think this is a product of bringing together a few definitions into
>  one and not forcing a standard.
>
>  numpy.inf
>  numpy.nan
>
>  should be used except for backward compatibility.

The others have some use if you want to be able to use the results of
repr() as literals - as I understand it the output representation of a
NaN depends on the C library, and users seeing, say, "NaN" might well
expect to be able to type NaN (after from numpy import NaN) and get a
NaN.

Anne



More information about the NumPy-Discussion mailing list