[Numpy-discussion] index objects are not broadcastable to a single shape

Travis Oliphant oliphant at ee.byu.edu
Wed Apr 12 18:30:03 CDT 2006


Simon Burton wrote:

>This must be up there with the most useless confusing error messages:
>
>  
>
>>>>a=numpy.array([1,2,3])
>>>>b=numpy.array([1,2,3,4])
>>>>a*b
>>>>        
>>>>
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>ValueError: index objects are not broadcastable to a single shape
>  
>
>
>  
>
The problem with these error messages is that some code is used in a 
wide-variety of circumstances.  The original error message was conceived 
in thinking about the application of the code to one circumstance while 
this particular error is occurring in a different one.

The standard behavior is to just propagate the error up.  Better error 
messages means catching a lot more errors and special-casing error 
messages.  It can be done, but it's tedious work.

-Travis





More information about the Numpy-discussion mailing list