Skip to content

Commit 09fb9cb

Browse files
committed
fixed. sp.writeToString Unicode error
1 parent 3c4d421 commit 09fb9cb

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

bindings/py/cpp_src/bindings/algorithms/py_SpatialPooler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ Argument wrapAround boolean value that determines whether or not inputs
246246
py_SpatialPooler.def("setMinPctOverlapDutyCycles", &SpatialPooler::setMinPctOverlapDutyCycles);
247247

248248
// loadFromString
249-
py_SpatialPooler.def("loadFromString", [](SpatialPooler& self, const std::string& inString)
249+
py_SpatialPooler.def("loadFromString", [](SpatialPooler& self, const py::bytes& inString)
250250
{
251-
std::istringstream inStream(inString);
251+
std::stringstream inStream(inString.cast<std::string>());
252252
self.load(inStream);
253253
});
254254

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

262262
self.save(os);
263263

264-
return os.str();
264+
return py::bytes( os.str() );
265265
});
266266

267267
// compute

bindings/py/tests/algorithms/spatial_pooler_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ def testNupicSpatialPoolerSavingToString(self):
184184
sp = SP()
185185
s = sp.writeToString()
186186

187-
sp2 = sp.readFromString(s)
187+
sp2 = SP(columnDimensions=[32, 32])
188+
sp2.loadFromString(s)
188189

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

0 commit comments

Comments
 (0)