title: sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype('float64')
body: <p>I am using sklearn and having a problem with the affinity propagation. I have built an input matrix and I keep getting the following error. </p>
  
  <pre><code>ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
  </code></pre>
  
  <p>I have run</p>
  
  <pre><code>np.isnan(mat.any()) #and gets False
  np.isfinite(mat.all()) #and gets True
  </code></pre>
  
  <p>I tried using</p>
  
  <pre><code>mat[np.isfinite(mat) == True] = 0
  </code></pre>
  
  <p>to remove the infinite values but this did not work either. 
  What can I do to get rid of the infinite values in my matrix, so that I can use the affinity propagation algorithm?</p>
  
  <p>I am using anaconda and python 2.7.9.</p>