def testNupicSpatialPoolerSavingToString(self): """Test writing to and reading from NuPIC SpatialPooler.""" # Simple test: make sure that writing/reading works... sp = SP() s = sp.writeToString() sp2 = SP(columnDimensions=[32, 32]) sp2.loadFromString(s) self.assertEqual( sp.getNumColumns(), sp2.getNumColumns(), "NuPIC SpatialPooler write to/read from string failed.")
def testNupicSpatialPoolerSavingToString(self): """Test writing to and reading from NuPIC SpatialPooler.""" inputs = SDR( 100 ).randomize( .05 ) active = SDR( 100 ) sp = SP( inputs.dimensions, active.dimensions, stimulusThreshold = 1 ) for _ in range(10): sp.compute( inputs, True, active ) # Simple test: make sure that writing/reading works... s = sp.writeToString() sp2 = SP(columnDimensions=[32, 32]) sp2.loadFromString(s) self.assertEqual(sp.getNumColumns(), sp2.getNumColumns(), "NuPIC SpatialPooler write to/read from string failed.") self.assertEqual(str(sp), str(sp2), "HTM SpatialPooler write to/read from string failed.")