[Numpy-discussion] initialise an array

Tim Hochberg tim.hochberg at cox.net
Tue Jan 10 08:47:05 CST 2006

Humufr wrote:

> Hello,
> I have a function like this:
> def test(x,xall=None):
>     if xall == None: xall =x
> I obtain this error message when I'm doing this with numpy (I don't 
> have this problem with numarray and Numeric).
> ValueError: The truth value of an array with more than one element is 
> ambiguous. Use a.any() or a.all
> How can I do something similar? Do I have to use the function suggest 
> in the error message? The function is something inside a long script 
> with a lot of condition similar to this one so it's why I ask if it's 
> normal to not have the special None parameter take in count.

Use 'is', for example:

    if xall is None: xall = x


> Thanks,
> N.
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log 
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion

More information about the Numpy-discussion mailing list