<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 7, 2016 at 2:17 PM, Chris Barker <span dir="ltr"><<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Thu, Apr 7, 2016 at 10:00 AM, Ian Henriksen <span dir="ltr"><<a href="mailto:insertinterestingnamehere@gmail.com" target="_blank">insertinterestingnamehere@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>Here's another example that I've seen catch people now and again.</div><div><br></div><div>A = np.random.rand(100, 100)</div><div>b =  np.random.rand(10)</div><div>A * b.T</div></div></div></blockquote><div><br></div></span><div>typo? that was supposed to be </div><div><br></div><div>b =  np.random.rand(100). yes?<br></div><div><br></div><div>This is exactly what someone else referred to as the expectations of someone that comes from MATLAB, and doesn't yet "get" that 1D arrays are 1D arrays.</div><div><br></div><div>All of this is EXACTLY the motivation for the matric class -- which never took off, and was never complete (it needed a row and column vector implementation, if you ask me. But Ithikn the reason it didn't take off is that it really isn't that useful, but is different enough from regular arrays to be a greater source of confusion. And it was decided that all people REALLY wanted was an obviou sway to get matric multiply, which we now have with @.</div><div><br></div><div>So this discussion brings up that we also need an easy an obvious way to make a column vector -- </div><div><br></div><div>maybe:</div><div><br></div><div>np.col_vector(arr)</div><div><br></div><div>which would be a synonym for np.reshape(arr, (-1,1))</div><div><br></div><div>would that make anyone happy?</div><div><br></div><div>NOTE: having transposing a 1D array raise an exception would help remove a lot  of the confusion, but it may be too late for that....</div><span class=""><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>In this case the user pretty clearly meant to be broadcasting along the rows of A</div><div>rather than along the columns, but the code fails silently. </div></div></div></blockquote><div><br></div></span><div>hence the exception idea....</div><div><br></div><div>maybe a warning? </div></div></div></div></blockquote><div><br></div><div>AFAIR, there is a lot of code that works correctly with .T being a noop for 1D</div><div>e.g. covariance matrix/inner product x.T dot y as mentioned before.</div><div><br></div><div>write unit tests with non square 2d arrays and the exception / test error shows up fast.</div><div><br></div><div>Josef</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>-CHB</div><div><br></div></div><span class=""><div><br></div>-- <br><div><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            <a href="tel:%28206%29%20526-6959" value="+12065266959" target="_blank">(206) 526-6959</a>   voice<br>7600 Sand Point Way NE   <a href="tel:%28206%29%20526-6329" value="+12065266329" target="_blank">(206) 526-6329</a>   fax<br>Seattle, WA  98115       <a href="tel:%28206%29%20526-6317" value="+12065266317" target="_blank">(206) 526-6317</a>   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</span></div></div>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div></div>