[Numpy-discussion] Assigning complex values to a real array

David Warde-Farley dwf@cs.toronto....
Wed Dec 9 03:51:52 CST 2009

On 9-Dec-09, at 1:26 AM, Dr. Phillip M. Feldman wrote:

>  NumPy and Python are somewhat out of step. The NumPy approach
> is stricter and more likely to catch errors than Python. Python  
> tends to be
> somewhat laissez-faire about numerical errors and the correctness of
> results.

The bug/quirk you've been complaining about seems to suggest just the  
opposite. Darren's error is being raised because it is a Python  
complex being coerced. np.int64(np.complex64(10+20j)) raises no such  

> Unfortunately, NumPy seems to be a sort of step-child of Python,  
> tolerated,
> but not fully accepted. There are a number of people who continue to  
> use Matlab,
> despite all of its deficiencies, because it can at least be counted  
> on to
> produce correct answers most of the time.

Except that you could never fully verify that it produces correct  
results, even if that was your desire.

There are legitimate reasons for wanting to use Matlab (e.g.  
familiarity, because collaborators do, and for certain things it's  
still faster than the alternatives) but correctness of results isn't  
one of them. That said, people routinely let price tags influence  
their perceptions of worth.


More information about the NumPy-Discussion mailing list