Skip to content

Commit

Permalink
Issue numenta/nupic.core-legacy#1380: Add SP test checking results wi…
Browse files Browse the repository at this point in the history
…th no learning and 0 boosting
  • Loading branch information
lscheinkman committed Jan 10, 2018
1 parent 5ecae91 commit 90eea66
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/unit/nupic/algorithms/spatial_pooler_cpp_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,20 @@ def testUpdateDutyCycles(self):

self.assertEqual(list(resultOverlapArr2), list(trueOverlapArr2))

def testSameOutputForSameInputNoLearningNoBoosting(self):
inputSize = 10
columns = 20
sp = SpatialPooler(inputDimensions=[inputSize], columnDimensions=[columns])
sp.setBoostStrength(0)

out1 = np.zeros(columns, dtype=uintDType)
out2 = np.zeros(columns, dtype=uintDType)
inputVector = np.array([1, 1, 0, 0, 1, 1, 0, 0, 1, 1], dtype=realDType)

sp.compute(inputVector, False, out1);
sp.compute(inputVector, False, out2);
self.assertEqual(list(out1), list(out2))



if __name__ == "__main__":
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/nupic/algorithms/spatial_pooler_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,21 @@ def testActiveColumnsEqualNumActive(self):
sp.compute(inputArray2, False, activeArray)
self.assertEqual(sum(activeArray), numActive)

def testSameOutputForSameInputNoLearningNoBoosting(self):
inputSize = 10
columns = 20
sp = SpatialPooler(inputDimensions=[inputSize], columnDimensions=[columns])
sp.setBoostStrength(0)

out1 = numpy.zeros(columns, dtype=uintDType)
out2 = numpy.zeros(columns, dtype=uintDType)
inputVector = numpy.array([1, 1, 0, 0, 1, 1, 0, 0, 1, 1], dtype=realDType)

sp.compute(inputVector, False, out1);
sp.compute(inputVector, False, out2);
self.assertEqual(list(out1), list(out2))



if __name__ == "__main__":
unittest.main()

0 comments on commit 90eea66

Please sign in to comment.