473,722 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Help when using numarray

Python advertises some basic service:

C:\Python24>pyt hon
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.numarr aycore 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 "<interacti ve input>", line 1, in ?
File "site.py", line 328, in __call__
return pydoc.help(*arg s, **kwds)
File "C:\Python24\li b\pydoc.py", line 1647, in __call__
self.help(reque st)
File "C:\Python24\li b\pydoc.py", line 1691, in help
else: doc(request, 'Help on %s:')
File "C:\Python24\li b\pydoc.py", line 1475, in doc
pager(title % desc + '\n\n' + text.document(o bject, name))
File "C:\Python24\li b\pydoc.py", line 297, in document
if inspect.isrouti ne(object): return self.docroutine (*args)
File "C:\Python24\li b\pydoc.py", line 1226, in docroutine
if object.im_self:
File "C:\Python24\Li b\site-packages\numarr ay\generic.py", line 537,
in __nonzero__
raise RuntimeError("A n 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\nConv ert a string or number to an integer,
if possible. A floating point\nargument will be truncated towards zero
(this does not include a string\nreprese ntation 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.
Sep 16 '05 #1
3 3361
Colin J. Williams wrote:
Python advertises some basic service:

C:\Python24>pyt hon
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.numarr aycore 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.
c.rank is an integer, not a method. It doesn't have a docstring. It
can't have a docstring.
Another example:
>>> help(c.copy) <bound method NumArray.copy of array([1, 2])> >>> help(c.copy) Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "site.py", line 328, in __call__
return pydoc.help(*arg s, **kwds)
File "C:\Python24\li b\pydoc.py", line 1647, in __call__
self.help(reque st)
File "C:\Python24\li b\pydoc.py", line 1691, in help
else: doc(request, 'Help on %s:')
File "C:\Python24\li b\pydoc.py", line 1475, in doc
pager(title % desc + '\n\n' + text.document(o bject, name))
File "C:\Python24\li b\pydoc.py", line 297, in document
if inspect.isrouti ne(object): return self.docroutine (*args)
File "C:\Python24\li b\pydoc.py", line 1226, in docroutine
if object.im_self:
File "C:\Python24\Li b\site-packages\numarr ay\generic.py", line 537,
in __nonzero__
raise RuntimeError("A n 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.im_self is c . pydoc is trying to use it as a truth value (I'm
not sure why, you'll have to take it up with pydoc, not numarray), but
numarray has made a decision not to implement __nonzero__.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Sep 16 '05 #2
Colin J. Williams wrote:
With numarray, help gives unhelpful responses:

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


c.rank returns a Python integer object.

if you pass in an object to help(), help figures out what that object is,
and tries to tell you what you can do with that object.

the integer itself has no idea whatsoever from where it came; it's just
an integer, and that's all Python knows about it.

cf.
import sys
help(sys) Help on built-in module sys:
NAME
sys
help(sys.stdout ) Help on file object:
class file(object)
| file(name[, mode[, buffering]]) -> file object
help(sys.stdout .softspace) Help on int object:
class int(object)
help(sys.stdout .softspace.__in t__)

Help on method-wrapper object:
__int__ = class method-wrapper(object)

and so on.

</F>

Sep 16 '05 #3
Fredrik Lundh wrote:
Colin J. Williams wrote:

With numarray, help gives unhelpful responses:

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

c.rank returns a Python integer object.

Fredrik,

Thanks to Robert Kern and yourself.
Yes, you are right. Most of such cases are treated as properties so
that a doc string is available.

I think that the script below shows that there are cases where a doc
string is available but this information is not retrieved by help()

names= [n * int(not ( '_' in n)) for n in dir(c)]
for n in names:
if len(n):
try:
txt= eval('c.'+n+'._ _doc__ ')
print n, txt
print 'help:', help('c.'+n)
except:
print n, ' fails'

You give an integer example below, which I have marked <<<<<<<

This gives the basics. help(c.rank) below gives much more and a lot of
it is irrelevant.

Colin W.
help(c.rank) 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 string
| representation of a floating point number!) When converting a
string, use
| the optional base. It is an error to supply a base when converting a
| non-string. If the argument is outside the integer range a long object
| will be returned instead.
|
| Methods defined here:
|
| __abs__(...)
| x.__abs__() <==> abs(x)
|
| __add__(...)
| x.__add__(y) <==> x+y
|
| __and__(...)
| x.__and__(y) <==> x&y
|
| __cmp__(...)
| x.__cmp__(y) <==> cmp(x,y)
|
| __coerce__(...)
| x.__coerce__(y) <==> coerce(x, y)
|
| __div__(...)
| x.__div__(y) <==> x/y
|
| __divmod__(...)
| x.__divmod__(y) <==> xdivmod(x, y)y
|
| __float__(...)
| x.__float__() <==> float(x)
|
| __floordiv__(.. .)
| x.__floordiv__( y) <==> x//y
|
| __getattribute_ _(...)
| x.__getattribut e__('name') <==> x.name
|
| __getnewargs__( ...)
|
| __hash__(...)
| x.__hash__() <==> hash(x)
|
| __hex__(...)
| x.__hex__() <==> hex(x)
|
| __int__(...)
| x.__int__() <==> int(x)
|
| __invert__(...)
| x.__invert__() <==> ~x
|
| __long__(...)
| x.__long__() <==> long(x)
|
| __lshift__(...)
| x.__lshift__(y) <==> x<<y
|
| __mod__(...)
| x.__mod__(y) <==> x%y
|
| __mul__(...)
| x.__mul__(y) <==> x*y
|
| __neg__(...)
| x.__neg__() <==> -x
|
| __nonzero__(... )
| x.__nonzero__() <==> x != 0
|
| __oct__(...)
| x.__oct__() <==> oct(x)
|
| __or__(...)
| x.__or__(y) <==> x|y
|
| __pos__(...)
| x.__pos__() <==> +x
|
| __pow__(...)
| x.__pow__(y[, z]) <==> pow(x, y[, z])
|
| __radd__(...)
| x.__radd__(y) <==> y+x
|
| __rand__(...)
| x.__rand__(y) <==> y&x
|
| __rdiv__(...)
| x.__rdiv__(y) <==> y/x
|
| __rdivmod__(... )
| x.__rdivmod__(y ) <==> ydivmod(y, x)x
|
| __repr__(...)
| x.__repr__() <==> repr(x)
|
| __rfloordiv__(. ..)
| x.__rfloordiv__ (y) <==> y//x
|
| __rlshift__(... )
| x.__rlshift__(y ) <==> y<<x
|
| __rmod__(...)
| x.__rmod__(y) <==> y%x
|
| __rmul__(...)
| x.__rmul__(y) <==> y*x
|
| __ror__(...)
| x.__ror__(y) <==> y|x
|
| __rpow__(...)
| y.__rpow__(x[, z]) <==> pow(x, y[, z])
|
| __rrshift__(... )
| x.__rrshift__(y ) <==> y>>x
|
| __rshift__(...)
| x.__rshift__(y) <==> x>>y
|
| __rsub__(...)
| x.__rsub__(y) <==> y-x
|
| __rtruediv__(.. .)
| x.__rtruediv__( y) <==> y/x
|
| __rxor__(...)
| x.__rxor__(y) <==> y^x
|
| __str__(...)
| x.__str__() <==> str(x)
|
| __sub__(...)
| x.__sub__(y) <==> x-y
|
| __truediv__(... )
| x.__truediv__(y ) <==> x/y
|
| __xor__(...)
| x.__xor__(y) <==> x^y
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __new__ = <built-in method __new__ of type object>
| T.__new__(S, ...) -> a new object with type S, a subtype of T

if you pass in an object to help(), help figures out what that object is,
and tries to tell you what you can do with that object.

the integer itself has no idea whatsoever from where it came; it's just
an integer, and that's all Python knows about it.

cf.

import sys
help(sys)
Help on built-in module sys:
NAME
sys

help(sys.st dout)
Help on file object:
class file(object)
| file(name[, mode[, buffering]]) -> file object

help(sys.st dout.softspace)
Help on int object: <<<<<<
class int(object)

help(sys.st dout.softspace. __int__)


Help on method-wrapper object:
__int__ = class method-wrapper(object)

and so on.

</F>

Sep 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
9852
by: Brandon McCombs | last post by:
This may be the wrong group but I didn't see anything for VC++ so I'm trying here. I have a C++ book by Deitel and Deitel that says I can use fstream File("data.dat", ios::in | ios::out | ios::binary) to declare a file object with read/write modes turned on for working with binary data. I've tried this and my file is not created. The only time it is created is when I specify ifstream or ofstream but not fstream. I've tried removing the...
2
2129
by: Palm Kevin | last post by:
Hello, I have a little problem when I try to use a class of a DLL. Example : I have a DLL with the object MTSync with a function Sync() I try in another program to use this dll like this : MTSync sync = new MTSync(); sync.Sync(); OK, now the problem: The problem is NOT that this does not work, it works great, it does everything it has to do. BUT THE PROBLEM IS THAT
1
4025
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the same way a menu does. To do this my control needs to get notified when the user tried to click off of it. The Leave and LostFocus events of the UserControl work most of the time but not always. For example, if they click on a part of the form...
3
2545
by: Giovanni Boschi | last post by:
We have found a memory leak when using a COM library with a C# application. The leak appears only if the C# application is compiled with the /optimize flag. It goes away when the C# application is compiled with the /debug flag. The COM library is coded to fire asynchronous events, which are handled by the C# application. It is in the firing and handling of these events that the leak occurs. Why does the optimized application leak while...
13
1787
by: Bev in TX | last post by:
We are using Visual Studio .NET 2003. When using that compiler, the following example code goes into an endless loop in the "while" loop when the /Og optimization option is used: #include <stdlib.h> int resize(int *incsize, int min_size) { while(*incsize <= min_size) { *incsize = (int)(*incsize * 1.25); } if ( min_size > 60 ) return 0;
0
1100
by: Eugene | last post by:
Hi, I have a template in html and want to use web matrix to create a form. I am able to open the file and use the web controls after changing the file extension to aspx. But after saving the file, the textbox and the other input web controls disappear from the design tab. I can still find them in the properties pane. Is this normal when saving apsx from html pages? Another issue that I have is I can create a new database on my SQL...
10
7927
by: Anthony Williams | last post by:
Hi gang, This one looks like a bug :o( As you may or may not know, setting session management in web.config to use cookieless sessions causes the ASP.NET runtime to munge a session ID into the URL, in the format http://yourapplicationpath/(Session.SessionID)/... which saves numerous headaches when it comes to storing state across page requests and sessions.
3
3110
by: =?Utf-8?B?QXho?= | last post by:
Is there a limitation on the number of (sequential) opened connection for SQL Server User Instances? The following method will run to about the 240th iteration then will receive a timeout exception (SqlException. "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."). If User Instance=false then the method will execute to completion. Note that connection pooling is off just...
13
4008
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
This is a follow-up to my post "Silverlight video doesn't work when file is streamed from handler in ASP.net" at http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.dotnet.framework.aspnet&mid=e9a38d03-83a8-41fc-8950-5ee60d2a18a5. I have a web site under .NET 2.0 that renders videos using the Silverlight media player. When I stream the video file (.wmv) to the browser via a hard-coded link to the file,...
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.