Problem with Help when using numarray

Colin J. Williams cjw at sympatico.ca
Fri Sep 16 12:41:22 EDT 2005


Python advertises some basic service:

C:\Python24>python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
 >>>

With numarray, help gives unhelpful responses:

import numarray.numarraycore as _n
c= _n.array((1, 2))
print 'rank Value:', c.rank
print 'c.rank Help:', help(c.rank)

Results:
rank Value: 1
c.rank Help:Help on int object:

class int(object)
  |  int(x[, base]) -> integer
  |
  |  Convert a string or number to an integer, if possible.  A floating 
point
  |  argument will be truncated towards zero (this does not include a 
.................  etc etc.

Another example:

 >>> help(c.copy)
<bound method NumArray.copy of array([1, 2])>
 >>> help(c.copy)
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
   File "site.py", line 328, in __call__
     return pydoc.help(*args, **kwds)
   File "C:\Python24\lib\pydoc.py", line 1647, in __call__
     self.help(request)
   File "C:\Python24\lib\pydoc.py", line 1691, in help
     else: doc(request, 'Help on %s:')
   File "C:\Python24\lib\pydoc.py", line 1475, in doc
     pager(title % desc + '\n\n' + text.document(object, name))
   File "C:\Python24\lib\pydoc.py", line 297, in document
     if inspect.isroutine(object): return self.docroutine(*args)
   File "C:\Python24\lib\pydoc.py", line 1226, in docroutine
     if object.im_self:
   File "C:\Python24\Lib\site-packages\numarray\generic.py", line 537, 
in __nonzero__
     raise RuntimeError("An array doesn't make sense as a truth value. 
Use any(a) or all(a).")
RuntimeError: An array doesn't make sense as a truth value.  Use any(a) 
or all(a).
 >>>

c.copy.__doc_ does return the __doc__ string OK:
 >>> c.copy.__doc__
'Returns a native byte order copy of the array.'
 >>>

But c.rank.__doc__ does not:
 >>> c.rank.__doc__
'int(x[, base]) -> integer\n\nConvert a string or number to an integer, 
if possible.  A floating point\nargument will be truncated towards zero 
(this does not include a string\nrepresentation of a floating point 
number!)  When converting a string, use\nthe optional base.  It is an 
error to supply a base when converting a\nnon-string. If the argument is 
outside the integer range a long object\nwill be returned instead.'
 >>>

Colin W.



More information about the Python-list mailing list