diff --git a/bindings/py/cpp_src/bindings/engine/py_Engine.cpp b/bindings/py/cpp_src/bindings/engine/py_Engine.cpp index a60d4af163..2ae10dcfad 100644 --- a/bindings/py/cpp_src/bindings/engine/py_Engine.cpp +++ b/bindings/py/cpp_src/bindings/engine/py_Engine.cpp @@ -221,8 +221,9 @@ namespace htm_ext /////////////////// // Spec /////////////////// - py::class_ py_Spec(m, "Spec"); + py::class_> py_Spec(m, "Spec"); + py_Spec.def("toString", &Spec::toString); diff --git a/py/htm/advanced/regions/GridCellLocationRegion.py b/py/htm/advanced/regions/GridCellLocationRegion.py index e05b603602..ce36338023 100644 --- a/py/htm/advanced/regions/GridCellLocationRegion.py +++ b/py/htm/advanced/regions/GridCellLocationRegion.py @@ -40,7 +40,7 @@ class GridCellLocationRegion(PyRegion): gaussian activity bumps that move as the population receives motor input. When two bumps are near each other, the intermediate cells have higher firing rates than they would with a single bump. The cells with firing rates above a - certain threshold are considered "active". When the network receives a motor + certain threshold are considered 'active'. When the network receives a motor command, it shifts its bumps. The cells are distributed uniformly through the rhombus, packed in the optimal diff --git a/py/htm/advanced/regions/RawValues.py b/py/htm/advanced/regions/RawValues.py index 9b55815a5e..582a7e6203 100644 --- a/py/htm/advanced/regions/RawValues.py +++ b/py/htm/advanced/regions/RawValues.py @@ -26,9 +26,9 @@ class RawValues(PyRegion): """ - RawDate is a simple region used to send raw scalar values into networks. + RawValues is a simple region used to send raw scalar values into networks. - It accepts data using the command "addDataToQueue" or through the function + It accepts data using the command 'addDataToQueue' or through the function addDataToQueue() which can be called directly from Python. Data is queued up in a FIFO and each call to compute pops the top element. diff --git a/py/tests/networkapi/getParameters_test.py b/py/tests/networkapi/getParameters_test.py index f877a791a8..fc1c4416c1 100644 --- a/py/tests/networkapi/getParameters_test.py +++ b/py/tests/networkapi/getParameters_test.py @@ -34,7 +34,7 @@ class NetworkAPI_getParameters_Test(unittest.TestCase): """ Unit tests for Network class. """ - def testGetSpec(self): + def testGetSpecJSON(self): """ A test of the Network.getSpecJSON( ) function. """ @@ -127,6 +127,19 @@ def testGetSpec(self): net = Network() json_str = net.getSpecJSON("RDSEEncoderRegion") self.assertEqual(json_str, expected) + + def testGetSpec(self): + """ + Test of region.getSpec() function. Testing if pybind pointers are correctly handled + """ + net = Network() + dateRegion = net.addRegion('dateEncoder', 'DateEncoderRegion', + str(dict(timeOfDay_width=30, + timeOfDay_radius=1, + weekend_width=21))) + + dateRegion.getSpec()# twice times to check if no double free arises + dateRegion.getSpec() def testGetParameters(self): diff --git a/src/htm/engine/Region.hpp b/src/htm/engine/Region.hpp index cfa75f9eac..e5c7380f21 100644 --- a/src/htm/engine/Region.hpp +++ b/src/htm/engine/Region.hpp @@ -106,7 +106,7 @@ class Region : public Serializable { * * @returns The spec that describes this region */ - const std::shared_ptr &getSpec() const { return spec_; } + const std::shared_ptr getSpec() const { return spec_; } /** diff --git a/src/htm/engine/RegionImplFactory.cpp b/src/htm/engine/RegionImplFactory.cpp index 9da9f5d845..1cd9535a8c 100644 --- a/src/htm/engine/RegionImplFactory.cpp +++ b/src/htm/engine/RegionImplFactory.cpp @@ -207,7 +207,7 @@ RegionImpl *RegionImplFactory::deserializeRegionImpl(const std::string nodeType, -std::shared_ptr& RegionImplFactory::getSpec(const std::string nodeType) { +std::shared_ptr RegionImplFactory::getSpec(const std::string nodeType) { auto it = regionSpecMap.find(nodeType); if (it == regionSpecMap.end()) { NTA_THROW << "getSpec() -- unknown node type: '" << nodeType diff --git a/src/htm/engine/RegionImplFactory.hpp b/src/htm/engine/RegionImplFactory.hpp index 66fc0d4539..87167a98b9 100644 --- a/src/htm/engine/RegionImplFactory.hpp +++ b/src/htm/engine/RegionImplFactory.hpp @@ -60,7 +60,7 @@ class RegionImplFactory { // Returns node spec for a specific node type as a shared pointer. - std::shared_ptr& getSpec(const std::string nodeType); + std::shared_ptr getSpec(const std::string nodeType); // RegionImplFactory caches nodespecs and the dynamic library reference // This frees up the cached information. diff --git a/src/htm/regions/SPRegion.cpp b/src/htm/regions/SPRegion.cpp index 1bb8f3328d..d973c7b6eb 100644 --- a/src/htm/regions/SPRegion.cpp +++ b/src/htm/regions/SPRegion.cpp @@ -190,7 +190,7 @@ Spec *SPRegion::createSpec() { "SPRegion. This implements the Spatial Pooler algorithm as a plugin " "for the Network framework. The Spatial Pooler manages relationships " "between the columns of a region and the inputs bits. The primary " - "public interface to this function is the \"compute\" method, which " + "public interface to this function is the 'compute' method, which " "takes in an input vector and returns a list of activeColumns columns."; @@ -372,7 +372,7 @@ Spec *SPRegion::createSpec() { ParameterSpec("(float)\n" "The default connected threshold.Any synapse whose " "permanence value is " - "above the connected threshold is a \"connected synapse\", " + "above the connected threshold is a 'connected synapse', " "meaning it can " "contribute to the cell's firing. Default ``0.1``.", NTA_BasicType_Real32, // type @@ -404,7 +404,7 @@ Spec *SPRegion::createSpec() { "when " "either its previously learned inputs are no longer ever active, or " "when " - "the vast majority of them have been \"hijacked\" by other " + "the vast majority of them have been 'hijacked' by other " "columns.Default " "``0.001``.", NTA_BasicType_Real32, // type