Showing with 30 additions and 30 deletions.
  1. +30 −30 src/test/unit/algorithms/TemporalMemoryTest.cpp
@@ -76,8 +76,9 @@ namespace nupic {
testMapCellsToColumns();
testWrite();

// Depreciated serialization method (incomplete due to lack of load & save
// in Connections and Random classes). Replaced by Cap'n Proto read & write.
// Depreciated serialization method.
// Requires load & save in Connections classes).
// See PR #522 https://github.com/numenta/nupic.core/pull/522
//testSaveLoad();

}
@@ -453,19 +454,19 @@ namespace nupic {
set<Cell> activeCells = { Cell(23), Cell(37), Cell(49), Cell(733) };
vector<Cell> cellsForColumn = tm.cellsForColumn(0);

tie(foundCell, bestCell, foundSegment, bestSegment) =
tie(foundCell, bestCell, foundSegment, bestSegment) =
tm.bestMatchingCell(cellsForColumn, activeCells, connections);

ASSERT_EQ(bestCell, Cell(0));
ASSERT_EQ(bestSegment, Segment(0, Cell(0)));

cellsForColumn = tm.cellsForColumn(3);
tie(foundCell, bestCell, foundSegment, bestSegment) =
tie(foundCell, bestCell, foundSegment, bestSegment) =
tm.bestMatchingCell(cellsForColumn, activeCells, connections);
ASSERT_EQ(bestCell, Cell(96)); // Random cell from column

cellsForColumn = tm.cellsForColumn(999);
tie(foundCell, bestCell, foundSegment, bestSegment) =
tie(foundCell, bestCell, foundSegment, bestSegment) =
tm.bestMatchingCell(cellsForColumn, activeCells, connections);
ASSERT_EQ(bestCell, Cell(31972)); // Random cell from column
}
@@ -491,7 +492,7 @@ namespace nupic {
{
// Never pick cell 0, always pick cell 1
vector<Cell> cellsForColumn = tm.cellsForColumn(0);
tie(foundCell, cell, foundSegment, segment) =
tie(foundCell, cell, foundSegment, segment) =
tm.bestMatchingCell(cellsForColumn, activeSynapsesForSegment, connections);
ASSERT_EQ(cell, Cell(1));
}
@@ -565,7 +566,7 @@ namespace nupic {
{
// Never pick cell 0, always pick cell 1
vector<Cell> cellsForColumn = tm.cellsForColumn(0);
tie(foundCell, cell, foundSegment, segment) =
tie(foundCell, cell, foundSegment, segment) =
tm.bestMatchingCell(cellsForColumn, cells, connections);
ASSERT_EQ(cell, Cell(1));
}
@@ -820,18 +821,17 @@ namespace nupic {

tm1.initialize({ 100 }, 4, 7, 0.37, 0.58, 4, 18, 0.23, 0.08, 91);
/*
// GH issue https://github.com/numenta/nupic.core/issues/505 to uncomment this
//
// Run some data through before serializing
patternMachine = PatternMachine(100, 4);
sequenceMachine = SequenceMachine(self.patternMachine);
sequence = self.sequenceMachine.generateFromNumbers(range(5));
PatternMachine patternMachine = PatternMachine(100, 4);
SequenceMachine sequenceMachine = SequenceMachine(self.patternMachine);
Sequence sequence = self.sequenceMachine.generateFromNumbers(range(5));
*/
vector<vector<UInt>> sequence = { { 83, 53, 70, 45 },{ 8, 65, 67, 59 },{ 25, 98, 99, 39 },{ 66, 11, 78, 14 },{ 96, 87, 69, 95 } };
for (UInt i = 0; i < 3; i++)
{
for (auto pattern : sequence)
tm1.compute(pattern);
for (vector<UInt> pattern : sequence)
tm1.compute(pattern.size(), pattern.data());
}
*/

// Write the proto to a temp file and read it back into a new proto
ofstream outfile(filename, ios::binary);
tm1.write(outfile);
@@ -847,20 +847,20 @@ namespace nupic {
check_spatial_eq(tm1, tm2);

// Run a couple records through after deserializing and check results match
/* tm1.compute(self.patternMachine.get(0))
tm2.compute(self.patternMachine.get(0))
self.assertEqual(tm1.activeCells, tm2.activeCells)
self.assertEqual(tm1.predictiveCells, tm2.predictiveCells)
self.assertEqual(tm1.winnerCells, tm2.winnerCells)
self.assertEqual(tm1.connections, tm2.connections)
tm1.compute(self.patternMachine.get(3))
tm2.compute(self.patternMachine.get(3))
self.assertEqual(tm1.activeCells, tm2.activeCells)
self.assertEqual(tm1.predictiveCells, tm2.predictiveCells)
self.assertEqual(tm1.winnerCells, tm2.winnerCells)
self.assertEqual(tm1.connections, tm2.connections)
*/
tm1.compute(1, sequence[0].data());
tm2.compute(1, sequence[0].data());
ASSERT_EQ(tm1.activeCells, tm2.activeCells);
ASSERT_EQ(tm1.predictiveCells, tm2.predictiveCells);
ASSERT_EQ(tm1.winnerCells, tm2.winnerCells);
ASSERT_EQ(tm1.connections, tm2.connections);

tm1.compute(1, sequence[3].data());
tm2.compute(1, sequence[3].data());
ASSERT_EQ(tm1.activeCells, tm2.activeCells);
ASSERT_EQ(tm1.predictiveCells, tm2.predictiveCells);
ASSERT_EQ(tm1.winnerCells, tm2.winnerCells);
ASSERT_EQ(tm1.connections, tm2.connections);

int ret = ::remove(filename);
NTA_CHECK(ret == 0) << "Failed to delete " << filename;
}