title: Mean each row of nonzero values and avoid RuntimeWarning and NaN as some rows are all zero
body: <p>I already checked <a href="https://stackoverflow.com/questions/38542548/numpy-mean-of-nonzero-values">Numpy mean of nonzero values</a> and it worked nicely. However, some rows of my matrix are all zero element. What is a good way to avoid <code>RuntimeWarning: invalid value encountered in true_divide</code> in this case? Also,  I don't want the zero element to be replaced by <code>Nan</code> here.</p>
  
  <pre><code>eachPSM = np.ones([3,4])
  eachPSM[0] = 0
  print eachPSM
  &gt;&gt; [[ 0.  0.  0.  0.]
   [ 1.  1.  1.  1.]
   [ 1.  1.  1.  1.]]
  print np.true_divide(eachPSM.sum(1),(eachPSM!=0).sum(1))
  &gt;&gt; RuntimeWarning: invalid value encountered in true_divide
  [ nan   1.   1.]
  </code></pre>