<p>Try doing this instead: </p>
<pre><code>a[:] += b[c.ravel(), :]
<p>What's happening is that <code>c</code> is considered as a two-dimensional matrix rather than a single 1D array, which is why the unnecessary broadcasting is happening. You are basically trying to index the matrix with a 2D array when you need it to be 1D. </p>
<p>This tip was originally posted on <a href="http://stackoverflow.com/questions/30672650/Issue%20converting%20Matlab%20code%20to%20Python%20non-broadcastable%20output/30673191">Stack Overflow</a>.</p>
Get New Tutorials Delivered to Your Inbox
New tutorials will be sent to your Inbox once a week.