title: Python 2.7 Value Error math domain error
body: <blockquote>
    <p>UPDATE</p>
  </blockquote>
  
  <p>@peter wood comment is actually answer but it is comment so i just upvoted it.</p>
  
  <p>The accepted answer reveals the presence of negative number in the matrix. 
  What I have done is converted both image to grayscale and compared, no more warnings and error. Cheers and Thanks guys.</p>
  
  <hr>
  
  <p>I am started to learn python and simplecv , using one of the example program in simple which is comparing two images, i am encountering this error. It first throws </p>
  
  <blockquote>
    <p>runtime warning: overflow encountered in int_scalars</p>
  </blockquote>
  
  <pre><code>map(lambda a,b: (a-b)**2,h1,h2))/len(h1))
  </code></pre>
  
  <p>Then throws the error</p>
  
  <pre><code>Traceback (most recent call last):
    File "G:\fs\python27files\imagecompare2.py", line 29, in &lt;module&gt;
      compare('belt.jpg','belt4.jpg')
    File "G:\fs\python27files\imagecompare2.py", line 20, in compare
      map(lambda a,b: (a-b)**2,h1,h2))/len(h1))
  ValueError: math domain error
  </code></pre>
  
  <p>The code is</p>
  
  <pre><code>import math, operator
  from SimpleCV import *
  
  def compare(f1,f2):
  
  
          img = Image(f1)
          img1 = Image(f2)
  
          h1 = img.hueHistogram()
          h2 = img1.hueHistogram()
          #print h1
          #print h2
          print len(h1)
          print len(h2)
          f = map(lambda a,b: (a-b)**2,h1,h2)
          print f
  
          rms = math.sqrt(reduce(operator.add,
                              map(lambda a,b: (a-b)**2,h1,h2))/len(h1))
          #print rms
  
  
          #print h1.huePeaks()
          #print h2.huePeaks()
  
  
  if __name__=='__main__':
     compare('belt.jpg','belt4.jpg')
  </code></pre>
  
  <p>as you can see i tried to print map alone in variable f, and encounters the same warning. </p>
  
  <p>Finally i saw one related question here in SO which tells that setting up </p>
  
  <p>dType(datatype) will remove the issue , but that is pertaining to numpy, I read </p>
  
  <p>that simplecv is also incorporating numpy. any help regarding this?</p>
  
  <blockquote>
    <p>EDIT</p>
  </blockquote>
  
  <p>i have pasted image showing the output of map function of resulting histograms, and i see one negative value in it. </p>
  
  <p><a href="https://i.stack.imgur.com/wqbps.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wqbps.png" alt="enter image description here"></a></p>
  
  <p>the highlighted portion is showing the negative number. 
  so how to overcome this?</p>