[Numpy-discussion] [Python-3000] PEP 31XX: A Type Hierarchy for Numbers (and other algebraic entities)

David Goldsmith David.L.Goldsmith@noaa....
Fri Apr 27 13:53:52 CDT 2007


Guido van Rossum wrote:
> On 4/27/07, Jan Grant <jan.grant@bristol.ac.uk> wrote:
>   
>> On Thu, 26 Apr 2007, Dan Christensen wrote:
>>
>>     
>>> Note also that double-precision reals are a subset of the rationals,
>>> since each double precision real is exactly representable as a
>>> rational number, but many rational numbers are not exactly
>>> representable as double precision reals.  Not sure if this means
>>> that reals should be a subclass of the rationals.
>>>       
>> Not quite all: the space of doubles include a small number of things
>> that aren't representable by a rational (+/- inf, for instance).
>>     
>
> This suddenly makes me think of a new idea -- perhaps we could changes
> the type of Inf and NaNs to some *other* numeric type? We could then
> reserve a place in the numeric hierarchy for its abstract base class.
> Though I don't know if this extends to complex numbers with one or
> both parts NaN/Inf or not.
>   
As far as NaN is concerned, I'd assert that it's no different if we're 
talking about reals or complex - if it's not a number, it's not a number 
- IMO a complex number with one part finite and another part NaN makes 
no sense.  And as far as inf is concerned, *if* you're effectively doing 
your math on the Riemann sphere (or any Riemann surface with countably 
many cuts, if I remember correctly - someone please correct me if I'm 
wrong) then there is only one inf - if you need to know the direction 
from, or, equivalently, the curve along which you arrived at inf, then 
you need to keep track of that programmatically.  (Of course, there 
might be some instances where you want to know whether an operation made 
the real part or the imaginary part or both NaN or inf, but then I'd 
assert that you should be checking for that programmatically also.)

DG


More information about the Numpy-discussion mailing list