def tmDiff(tm1, tm2, verbosity = <NUM_LIT:0>, relaxSegmentTests =True):
<EOL>if sameTMParams(tm1, tm2) == False:<EOL><INDENT>print("<STR_LIT>")<EOL>return False<EOL><DEDENT>result = True<EOL>if (tm1.activeState['<STR_LIT:t>'] != tm2.activeState['<STR_LIT:t>']).any():<EOL><INDENT>print('<STR_LIT>', numpy.where(tm1.activeState['<STR_LIT:t>'] != tm2.activeState['<STR_LIT:t>']))<EOL>result = False<EOL><DEDENT>if (tm1.predictedState['<STR_LIT:t>'] - tm2.predictedState['<STR_LIT:t>']).any():<EOL><INDENT>print('<STR_LIT>', numpy.where(tm1.predictedState['<STR_LIT:t>'] != tm2.predictedState['<STR_LIT:t>']))<EOL>result = False<EOL><DEDENT>if tm1.getNumSegments() != tm2.getNumSegments():<EOL><INDENT>print("<STR_LIT>", tm1.getNumSegments(), tm2.getNumSegments())<EOL>result = False<EOL><DEDENT>if tm1.getNumSynapses() != tm2.getNumSynapses():<EOL><INDENT>print("<STR_LIT>", tm1.getNumSynapses(), tm2.getNumSynapses())<EOL>tm1.printCells()<EOL>tm2.printCells()<EOL>result = False<EOL><DEDENT>for c in range(tm1.numberOfCols):<EOL><INDENT>for i in range(tm2.cellsPerColumn):<EOL><INDENT>if tm1.getNumSegmentsInCell(c, i) != tm2.getNumSegmentsInCell(c, i):<EOL><INDENT>print("<STR_LIT>",c,i, end='<STR_LIT:U+0020>')<EOL>print(tm1.getNumSegmentsInCell(c, i), tm2.getNumSegmentsInCell(c, i))<EOL>result = False<EOL><DEDENT><DEDENT><DEDENT>if result == True and not relaxSegmentTests:<EOL><INDENT>for c in range(tm1.numberOfCols):<EOL><INDENT>for i in range(tm2.cellsPerColumn):<EOL><INDENT>nSegs = tm1.getNumSegmentsInCell(c, i)<EOL>for segIdx in range(nSegs):<EOL><INDENT>tm1seg = tm1.getSegmentOnCell(c, i, segIdx)<EOL>res = False<EOL>for tm2segIdx in range(nSegs):<EOL><INDENT>tm2seg = tm2.getSegmentOnCell(c, i, tm2segIdx)<EOL>if sameSegment(tm1seg, tm2seg) == True:<EOL><INDENT>res = True<EOL>break<EOL><DEDENT><DEDENT>if res == False:<EOL><INDENT>print("<STR_LIT>",c,i)<EOL>if verbosity >= <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>")<EOL>tm1.printCell(c, i)<EOL>print("<STR_LIT>")<EOL>tm2.printCell(c, i)<EOL><DEDENT>result = False<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if result == True and (verbosity > <NUM_LIT:1>):<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>return result<EOL>
Given two TM instances, list the difference between them and returns False
if there is a difference. This function checks the major parameters. If this
passes (and checkLearn is true) it checks the number of segments on
each cell. If this passes, checks each synapse on each segment.
When comparing C++ and Py, the segments are usually in different orders in the
cells. tmDiff ignores segment order when comparing TM's.