× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Issue converting Matlab code to Python non-broadcastable output

Ray Phan
Jun 10, 2015
<p>Try doing this instead: </p> <pre><code>a[:] += b[c.ravel(), :] </code></pre> <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>
comments powered by Disqus