Skip to content

Commit

Permalink
Merge pull request #1 from Lupino/pull/547
Browse files Browse the repository at this point in the history
fixed. sp.writeToString Unicode error
  • Loading branch information
fcr authored Jul 8, 2019
2 parents 3c4d421 + 09fb9cb commit 6350337
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions bindings/py/cpp_src/bindings/algorithms/py_SpatialPooler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ Argument wrapAround boolean value that determines whether or not inputs
py_SpatialPooler.def("setMinPctOverlapDutyCycles", &SpatialPooler::setMinPctOverlapDutyCycles);

// loadFromString
py_SpatialPooler.def("loadFromString", [](SpatialPooler& self, const std::string& inString)
py_SpatialPooler.def("loadFromString", [](SpatialPooler& self, const py::bytes& inString)
{
std::istringstream inStream(inString);
std::stringstream inStream(inString.cast<std::string>());
self.load(inStream);
});

Expand All @@ -261,7 +261,7 @@ Argument wrapAround boolean value that determines whether or not inputs

self.save(os);

return os.str();
return py::bytes( os.str() );
});

// compute
Expand Down
3 changes: 2 additions & 1 deletion bindings/py/tests/algorithms/spatial_pooler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def testNupicSpatialPoolerSavingToString(self):
sp = SP()
s = sp.writeToString()

sp2 = sp.readFromString(s)
sp2 = SP(columnDimensions=[32, 32])
sp2.loadFromString(s)

self.assertEqual(sp.getNumColumns(), sp2.getNumColumns(),
"NuPIC SpatialPooler write to/read from string failed.")
Expand Down

0 comments on commit 6350337

Please sign in to comment.