def runSideBySide(self, params, seed = None,
                    learnMode = None,
                    convertEveryIteration = False):
    """
    Run the PY and CPP implementations side by side on random inputs.
    If seed is None a random seed will be chosen based on time, otherwise
    the fixed seed will be used.
    
    If learnMode is None learning will be randomly turned on and off.
    If it is False or True then set it accordingly.
    
    If convertEveryIteration is True, the CPP will be copied from the PY
    instance on every iteration just before each compute.
    """
    randomState = getNumpyRandomGenerator(seed)
    cppSp = CreateSP("cpp", params)
    pySp = CreateSP("py", params)
    self.compare(pySp, cppSp)
    numColumns = pySp.getNumColumns()
    numInputs = pySp.getNumInputs()
    threshold = 0.8
    inputMatrix = (
      randomState.rand(numRecords,numInputs) > threshold).astype(uintType)
    
    # Run side by side for numRecords iterations
    for i in xrange(numRecords):
      if learnMode is None:
        learn = (randomState.rand() > 0.5)
      else:
        learn = learnMode
      if self.verbosity > 1:
        print "Iteration:",i,"learn=",learn
      PyActiveArray = numpy.zeros(numColumns).astype(uintType)
      CppActiveArray = numpy.zeros(numColumns).astype(uintType)
      inputVector = inputMatrix[i,:]
      
      pySp.compute(inputVector, learn, PyActiveArray)
      cppSp.compute(inputVector, learn, CppActiveArray)
      self.assertListEqual(list(PyActiveArray), list(CppActiveArray))
      self.compare(pySp,cppSp)

      # The permanence values for the two implementations drift ever so slowly
      # over time due to numerical precision issues. This causes different
      # permanences
      # By converting the SP's we reset the permanence values
      if convertEveryIteration or ((i+1)%30 == 0):
        cppSp = convertSP(pySp, i+1)
 def runSideBySide(self, params, seed = None,
                   learnMode = None,
                   convertEveryIteration = False):
   """
   Run the PY and CPP implementations side by side on random inputs.
   If seed is None a random seed will be chosen based on time, otherwise
   the fixed seed will be used.
   
   If learnMode is None learning will be randomly turned on and off.
   If it is False or True then set it accordingly.
   
   If convertEveryIteration is True, the CPP will be copied from the PY
   instance on every iteration just before each compute.
   """
   randomState = getNumpyRandomGenerator(seed)
   pySp = self.createSp("py", params)
   cppSp = self.createSp("cpp", params)
   self.compare(pySp, cppSp)
   numColumns = pySp.getNumColumns()
   numInputs = pySp.getNumInputs()
   threshold = 0.8
   inputMatrix = (
     randomState.rand(numRecords,numInputs) > threshold).astype(uintType)
   for i in xrange(numRecords):
     if learnMode is None:
       learn = (randomState.rand() > 0.5)
     else:
       learn = learnMode
     if self.verbosity > 1:
       print "Iteration:",i,"learn=",learn
     PyActiveArray = numpy.zeros(numColumns).astype(uintType)
     CppActiveArray = numpy.zeros(numColumns).astype(uintType)
     inputVector = inputMatrix[i,:]
     if convertEveryIteration:
       cppSp = convertSP(pySp, i+1)
     pySp.compute(inputVector, learn, PyActiveArray)
     cppSp.compute(inputVector, learn, CppActiveArray)
     self.assertListEqual(list(PyActiveArray), list(CppActiveArray))
     self.compare(pySp,cppSp)