This test is using a SpatialPooler to generate some data. Here is the call into nupic.core:
onCells = numpy.zeros(columnDimensions) spImpl.compute(spInput, True, onCells) spOutput.append(onCells.tolist()) activeCoincIndices = set(onCells.nonzero())
onCells array is filled mostly with “0.0” and if all values are zero the
activeCoincIndices array would be empty. On python 3 that is the case whereas on python 2.7 there are some non zero values. The things is that all the non zero values are very small, I mean small as “2.1219957909652723e-314”. I have checked:
if(len([x for x in onCells if abs(x) > 0.00000000001]) > 0): print 'good values'
onCells never seem to have anything useful in it. Is that a correct observation?
In any event, when there are only 0.0 in onCells the code will fault because of division by zero.
factor = max(summ)*len(summ)/sum(summ)
Is it correct to fix the test like this:
if(len([x for x in summ if x!=0]) > 0): zeros = len([x for x in summ if x==0]) factor = max(summ)*len(summ)/sum(summ)