<div>oh, I forgot. It happens with "divide", too.</div>
<div>lorenzo.<br><br> </div>
<div><span class="gmail_quote">On 1/8/07, <b class="gmail_sendername">Charles R Harris</b> <<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br><br>
<div>
<div><span class="e" id="q_110028d46f81097d_1"><span class="gmail_quote">On 1/8/07, <b class="gmail_sendername">Charles R Harris</b> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:charlesr.harris@gmail.com" target="_blank">
charlesr.harris@gmail.com</a>> wrote:</span> 
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid"><br><br>
<div><span><span class="gmail_quote">On 1/8/07, <b class="gmail_sendername">lorenzo bolla</b> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:lbolla@gmail.com" target="_blank"> lbolla@gmail.com
</a>> wrote:</span> 
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<div>Hello all!</div>
<div>I'm fairly new to Numpy and, while experimenting, I found a strange (i.e. not expected by me!) behaviour of arrays.</div>
<div>I tried this (in comment what I get):</div>
<div> </div>
<div>x = arange(4)      # x = array([0,1,2,3])</div>
<div> </div>
<div>def myadd(x,y):    # re-define the binary sum function</div>
<div>    return x + y</div>
<div> </div>
<div>reduce(myadd, x)     # 6, as expected</div>
<div>
<div>add.reduce(x)     # 6, as expected</div>
<div> </div></div>
<div>def mysub(x,y):   # re-define the binary diff function</div>
<div>    return x - y</div>
<div> </div>
<div>reduce(mysub, x)    # -6, as expected</div>
<div>subtract.reduce(x)    # 2 ---> WHY?</div></blockquote></span>
<div><br>It might be a bug in the implementation. What is happening is that instead of subtracting the new number from the previous result, the previous result is being subtracted from the new number. So you start with 0, and the sequence of operations continues: 
<br><br>0 = 0 - 0<br>1 = 1 - 0<br>1 = 2 - 1<br>2 = 3 - 1<br>2 = 4 - 2<br>3 = 5 - 2<br><br>Definitely a bug. Want to file a ticket?</div></div></blockquote></span></div>
<div><br>Or maybe not a bug. It depends on what reduce means for this operation. So either a bug or something that could use a bit of documentation. <br><br>Chuck<br> </div></div><br><br>_______________________________________________
<br>Numpy-discussion mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Numpy-discussion@scipy.org">Numpy-discussion@scipy.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://projects.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">
http://projects.scipy.org/mailman/listinfo/numpy-discussion</a><br><br><br></blockquote></div><br>