[Numpy-discussion] Re: Vote: complex64 vs complex128

Tim Hochberg tim.hochberg at cox.net
Wed Apr 5 05:30:14 EDT 2006


Arnd Baecker wrote:

>On Tue, 4 Apr 2006, Robert Kern wrote:
>
>  
>
>>Tim Hochberg wrote:
>>    
>>
>
>[...]
>
>  
>
>>>    >>> help(complex128)
>>>   class complex128scalar(complexfloatingscalar, complex)
>>>    |  complex128: composed of two 64 bit floats
>>>    |
>>>    |  Method resolution order:
>>>    |      complex128scalar
>>>    |      complexfloatingscalar
>>>    |      inexactscalar
>>>    |      numberscalar
>>>    |      genericscalar
>>>    |      complex
>>>    |      object
>>>   ...
>>>      
>>>
>
>I am puzzled why this does not show up with Ipython:
>
>In [1]:import numpy
>In [2]:numpy.complex128?
>Type:           type
>Base Class:     <type 'type'>
>String Form:    <type 'complex128scalar'>
>Namespace:      Interactive
>Docstring:
>    <no docstring>
>
>whereas
>
>In [3]:help(numpy.complex128)
>
>shows the above!
>So this might be more of an IPython question (I am running IPython
>0.7.2.svn), but maybe numpy does some magic tricks to hide the docs from
>IPython (surely not on purpose ...)?
>It seems that numpy.complex128.__doc__ is None
>
That's right, none of the scalar types have docstrings at present. The 
builtin help (AKA pydoc.help) tracks back through all the base classes 
and presents all kinds of extra information. The result tends to be 
awfully verbose; so much so that I just stuffed a function called hint 
into __builtins___ that just prints the results of pydoc.describe and 
pydoc.getdoc. It's quite possible that such a function already exists, 
maybe even in pydoc, but oddly enough the docs for pydoc are pretty 
impenatrable.

Here I've added basic docstrings to the complex types. I was hoping 
someone would have some ideas for other stuff that should go into the 
docstrings, but perhaps I'll just commit that change as is. Here's what 
I see here using hint:

 >>> hint(numpy.float64) # Still no docstring
class float64scalar
 >>> hint(numpy.complex64) # Now has a terse docstring
class complex64scalar
 |  Composed of two 32 bit floats
 >>> hint(numpy.complex128) # Same here.
class complex128scalar
 |  Composed of two 64 bit floats

Regards,

-tim






More information about the NumPy-Discussion mailing list