[Numpy-discussion] Second try: possible bug in assignment to complex array

Travis Oliphant travis at continuum.io
Fri Aug 10 10:00:04 EDT 2012


On Aug 10, 2012, at 5:37 AM, Paul Anton Letnes wrote:

> 
> 
> On 10. aug. 2012, at 09:54, Mark Bakker wrote:
> 
>> I am giving this a second try. Can anybody help me out? 
>> 
>> I think there is a problem with assigning a 1D complex array of length one
>> to a position in another complex array.
>> 
>> Example:
>> 
>> a = ones(1,'D')
>> b = ones(1,'D')
>> a[0] = b
>> ---------------------------------------------------------------------------
>> TypeError                                 Traceback (most recent call last)
>> <ipython-input-37-0c4fc6d780e3> in <module>()
>> ----> 1 a[0] = b
>> 
>> TypeError: can't convert complex to float
>> 
>> This works correctly when a and b are real arrays:
>> 
>> a = ones(1)
>> b = ones(1)
>> a[0] = b
>> 
>> Bug or feature?
> 
> The exact same thing happens on OS X 10.7.4, python 2.7.3, numpy 1.6.1.
> 
> Looks like a bug to me - or at least very surprising behavior.

This is definitely an inconsistency.    The error seems more correct (though the error message needs improvement).    

Can someone try this on NumPy 1.5 and see if this inconsistency existed there as well. 

Thanks,

-Travis

> 
> Paul
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion




More information about the NumPy-Discussion mailing list