Replace division by zero numpy
<p>I'm doing a matrix by matrix pointwise division however there are some zeros in the divisor matrix. This results in a warning and in some NaNs. I want these to map to 0, which I can do like this:</p>

<pre><code>edge_map = (xy/(x_norm*y_norm))
edge_map[np.isnan(edge_map)] = 0
</code></pre>

<p>However there are two issues with this, first of all it still gives a warning (I don't like warnings) and second of all this requires a second pass over the matrix (not sure if this is unavoidable) and efficiency is very important for this part of the code. Ideas?</p>