<br><br><div class="gmail_quote">On Wed, Mar 16, 2011 at 8:58 AM, Paul Anton Letnes <span dir="ltr"><<a href="mailto:paul.anton.letnes@gmail.com">paul.anton.letnes@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
On 16. mars 2011, at 15.49, Chris Barker wrote:<br>
<br>
> On 3/16/11 6:34 AM, Charles R Harris wrote:<br>
>> On Wed, Mar 16, 2011 at 7:24 AM, Paul Anton Letnes<br>
><br>
>> Yes, it is intentional. Numpy is more C than Python in this case,<br>
><br>
> I don't know that C has anything to do with it -- the *= operators were<br>
> added specifically to be "in-place" operators -- otherwise they would be<br>
> nothing but syntactic sugar. And IIRC, numpy was one of the motivators.<br>
><br>
> IMHO, the mistake was even allowing += and friends for immutables, as<br>
> that inherently means something different.<br>
><br>
> Of course, using += with integers is probably the most common case.<br>
><br>
> -Chris<br>
<br>
</div>I see. In that case, I have the following either/or christmas wish:<br>
<br>
Either: implement a warning along the following lines:<br>
>>> from numpy import *<br>
>>> a = zeros(10, dtype=complex)<br>
>>> a.astype(float)<br>
/Users/paulanto/Library/Python/2.7/bin/bpython:2: ComplexWarning: Casting complex values to real discards the imaginary part<br>
  # EASY-INSTALL-ENTRY-SCRIPT: 'bpython==0.9.7.1','console_scripts','bpython'<br>
array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.])<br>
<br></blockquote><div><br>This comes up for discussion on a fairly regular basis. I tend towards the more warnings side myself, but you aren't going to get the current behavior changed unless you can convince a large bunch of people that it is the right thing to do, which won't be easy. For one thing, a lot of current code in the wild would begin to raise warnings that weren't there before.<br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Or: give me a hint how and where to change the numpy code, and I could try to write a patch.<br>
<font color="#888888"><br></font></blockquote><div><br>You have to go down to the C level to deal with this.<br><br>Chuck <br></div><br></div>