diff --git a/docs/README.md b/docs/README.md index 76ffecc3e8..b502a38a35 100644 --- a/docs/README.md +++ b/docs/README.md @@ -179,17 +179,17 @@ nupic │   ├── configuration.py [TODO] │   ├── configuration_base.py [TODO] │   ├── configuration_custom.py [TODO] -│   ├── consoleprinter.py [TODO] +│   ├── console_printer.py [TODO] │   ├── decorators.py [TODO] │   ├── enum.py [TODO] │   ├── exceptions.py [TODO] │   ├── feature_groups.py [TODO] │   ├── features.py [TODO] │   ├── features_list.py [TODO] -│   ├── fshelpers.py [TODO] +│   ├── fs_helpers.py [TODO] │   ├── group_by.py [TODO] -│   ├── lockattributes.py [TODO] -│   └── mysqlhelpers.py [TODO] +│   ├── lock_attributes.py [TODO] +│   └── mysql_helpers.py [TODO] ├── swarming │   ├── DummyModelRunner.py [TODO] │   ├── HypersearchV2.py [TODO] diff --git a/src/nupic/algorithms/backtracking_tm.py b/src/nupic/algorithms/backtracking_tm.py index 0e6adb5c3b..de98536756 100644 --- a/src/nupic/algorithms/backtracking_tm.py +++ b/src/nupic/algorithms/backtracking_tm.py @@ -35,7 +35,7 @@ from nupic.bindings.math import Random from nupic.bindings.algorithms import getSegmentActivityLevel, isSegmentActive from nupic.math import GetNTAReal -from nupic.support.consoleprinter import ConsolePrinterMixin +from nupic.support.console_printer import ConsolePrinterMixin # Default verbosity while running unit tests diff --git a/src/nupic/database/client_jobs_dao.py b/src/nupic/database/client_jobs_dao.py index 0a0d60d6db..18e51fa554 100755 --- a/src/nupic/database/client_jobs_dao.py +++ b/src/nupic/database/client_jobs_dao.py @@ -33,7 +33,7 @@ from nupic.support.decorators import logExceptions #, logEntryExit from nupic.database.connection import ConnectionFactory from nupic.support.configuration import Configuration -from nupic.support import pymysqlhelpers +from nupic.support import pymysql_helpers _MODULE_NAME = "nupic.database.ClientJobsDAO" @@ -55,7 +55,7 @@ class InvalidConnectionException(Exception): # insertions, etc. # NOTE: having this as a global permits us to switch parameters wholesale (e.g., # timeout) -g_retrySQL = pymysqlhelpers.retrySQL(logger=_LOGGER) +g_retrySQL = pymysql_helpers.retrySQL(logger=_LOGGER) diff --git a/src/nupic/engine/__init__.py b/src/nupic/engine/__init__.py index b3bb89f318..ffe49e54c6 100644 --- a/src/nupic/engine/__init__.py +++ b/src/nupic/engine/__init__.py @@ -21,7 +21,7 @@ import os import nupic.bindings.engine_internal as engine_internal -from nupic.support.lockattributes import LockAttributesMixin +from nupic.support.lock_attributes import LockAttributesMixin import functools basicTypes = ['Byte', @@ -85,7 +85,7 @@ def registerBuiltInRegions(): def customExceptionHandler(type, value, tb): """Catch unhandled Python exception - + The handler prints the original exception info including into a buffer. It then extracts the original error message (when the exception is raised inside a Py node additional stacktrace info will be appended in the end) @@ -108,7 +108,7 @@ def customExceptionHandler(type, value, tb): for i, line in enumerate(lines): if line.startswith('RuntimeError:'): begin = i - # + # # elif line.startswith('Traceback (most recent call last):'): # end = i # break @@ -154,19 +154,19 @@ def customExceptionHandler(type, value, tb): class Dimensions(engine_internal.Dimensions): """Represent the topology of an N-dimensional region - + Basically, it is a list of integers such as: [4, 8, 6] In this example the topology is a 3 dimensional region with 4 x 8 x 6 nodes. - + You can initialize it with a list of dimensions or with no arguments and then append dimensions. - + """ def __init__(self, *args): """Construct a Dimensions object - + The constructor can be called with no arguments or with a list of integers """ @@ -179,22 +179,22 @@ def __str__(self): def Array(dtype, size=None, ref=False): """Factory function that creates typed Array or ArrayRef objects - + dtype - the data type of the array (as string). Supported types are: Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Real32, Real64 - + size - the size of the array. Must be positive integer. """ def getArrayType(self): """A little function to replace the getType() method of arrays - + It returns a string representation of the array element type instead of the integer value (NTA_BasicType enum) returned by the origianl array """ return self._dtype - - + + # ArrayRef can't be allocated if ref: assert size is None @@ -223,10 +223,10 @@ def ArrayRef(dtype): class CollectionWrapper(object): """Wrap an nupic::Collection with a dict-like interface - + The optional valueWrapper is used to wrap values for adaptation purposes. Maintains the original documentation - + collection - the original collection valueWrapper - an optional callable object used to wrap values. """ @@ -295,11 +295,11 @@ def __hash__(self): class SpecItem(object): """Wrapper that translates the data type and access code to a string - + The original values are an enumerated type in C++ that become just integers in Python. This class wraps the original ParameterSpec and translates the integer values to meaningful strings: that correspond to the C++ enum labels. - + It is used to wrap ParameterSpec, InputSpec and OutputSpec """ accessModes = ['Create', 'ReadOnly', 'ReadWrite'] @@ -361,7 +361,7 @@ def __init__(self, region, datatype): self.datatype = basicTypes[datatype] def getParameterArray(self, paramName): - # return a PyArray instead of a plain array. + # return a PyArray instead of a plain array. # PyArray constructor/class for type X is called XArray() #factoryName = self.datatype + 'Array' #if factoryName not in globals(): @@ -382,7 +382,7 @@ class Region(LockAttributesMixin): #Wrapper for a network region #- Maintains original documentation - #- Implement syntactic sugar properties: + #- Implement syntactic sugar properties: #name = property(getName) #type = property(getType) #spec = property(getSpec) @@ -390,10 +390,10 @@ class Region(LockAttributesMixin): #network = property(getNetwork) #- Makes sure that returned objects are high-level wrapper objects #- Forwards everything else to internal region - + def __init__(self, region, network): """Store the wraped region and hosting network - + The network is the high-level Network and not the internal Network. This is important in case the user requests the network from the region (never leak a engine object, remember) @@ -428,9 +428,9 @@ def getSpecFromType(nodeType): def compute(self): """ @doc:place_holder(Region.compute) - - ** This line comes from the original docstring (not generated by Documentor) - + + ** This line comes from the original docstring (not generated by Documentor) + """ return self._region.compute() @@ -487,7 +487,7 @@ def __cmp__(self, other): return self._region == other._region def _getParameterMethods(self, paramName): - """Returns functions to set/get the parameter. These are + """Returns functions to set/get the parameter. These are the strongly typed functions get/setParameterUInt32, etc. The return value is a pair: setfunc, getfunc @@ -496,7 +496,7 @@ def _getParameterMethods(self, paramName): if paramName in self._paramTypeCache: return self._paramTypeCache[paramName] try: - # Catch the error here. We will re-throw in getParameter or + # Catch the error here. We will re-throw in getParameter or # setParameter with a better error message than we could generate here paramSpec = self.getSpec().parameters.getByName(paramName) except: @@ -581,7 +581,7 @@ class Network(engine_internal.Network): def __init__(self, *args): """Constructor - + - Initialize the internal engine_internal.Network class generated by Swig - Attach docstrings to selected methods """ @@ -597,7 +597,7 @@ def __init__(self, *args): docTable = ( (engine_internal.Network.getRegions, 'Get the collection of regions in a network'), ) - + # Attach documentation to methods and properties for obj, docString in docTable: if isinstance(obj, str): @@ -610,7 +610,7 @@ def __init__(self, *args): def _getRegions(self): """Get the collection of regions in a network - + This is a tricky one. The collection of regions returned from from the internal network is a collection of internal regions. The desired collection is a collelcion of net.Region objects @@ -623,9 +623,9 @@ class is used with a custom makeRegion() function (see bellow) def makeRegion(name, r): """Wrap a engine region with a nupic.engine_internal.Region - + Also passes the containing nupic.engine_internal.Network network in _network. This - function is passed a value wrapper to the CollectionWrapper + function is passed a value wrapper to the CollectionWrapper """ r = Region(r, self) #r._network = self diff --git a/src/nupic/frameworks/opf/htm_prediction_model.py b/src/nupic/frameworks/opf/htm_prediction_model.py index b7551ace0b..1bfa89faec 100644 --- a/src/nupic/frameworks/opf/htm_prediction_model.py +++ b/src/nupic/frameworks/opf/htm_prediction_model.py @@ -42,7 +42,7 @@ from nupic.data.field_meta import FieldMetaSpecial, FieldMetaInfo from nupic.encoders import MultiEncoder, DeltaEncoder from nupic.engine import Network -from nupic.support.fshelpers import makeDirectoryFromAbsolutePath +from nupic.support.fs_helpers import makeDirectoryFromAbsolutePath from nupic.frameworks.opf.opf_utils import (InferenceType, InferenceElement, SensorInput, diff --git a/src/nupic/frameworks/opf/htm_prediction_model_callbacks.py b/src/nupic/frameworks/opf/htm_prediction_model_callbacks.py index 75800fd604..ac77be260b 100644 --- a/src/nupic/frameworks/opf/htm_prediction_model_callbacks.py +++ b/src/nupic/frameworks/opf/htm_prediction_model_callbacks.py @@ -25,7 +25,7 @@ import os -from nupic.support.fshelpers import makeDirectoryFromAbsolutePath +from nupic.support.fs_helpers import makeDirectoryFromAbsolutePath from htm_prediction_model import HTMPredictionModel diff --git a/src/nupic/support/__init__.py b/src/nupic/support/__init__.py index 4b7c1330a8..b965e5c3ff 100644 --- a/src/nupic/support/__init__.py +++ b/src/nupic/support/__init__.py @@ -81,7 +81,7 @@ from pkg_resources import resource_string, resource_filename from configuration import Configuration -from nupic.support.fshelpers import makeDirectoryFromAbsolutePath +from nupic.support.fs_helpers import makeDirectoryFromAbsolutePath # Local imports diff --git a/src/nupic/support/configuration_custom.py b/src/nupic/support/configuration_custom.py index b992ef7c72..8e853b8c49 100644 --- a/src/nupic/support/configuration_custom.py +++ b/src/nupic/support/configuration_custom.py @@ -29,7 +29,7 @@ import traceback from xml.etree import ElementTree -from nupic.support.fshelpers import makeDirectoryFromAbsolutePath +from nupic.support.fs_helpers import makeDirectoryFromAbsolutePath from nupic.support.configuration_base import Configuration as ConfigurationBase @@ -86,13 +86,13 @@ def setCustomProperties(cls, properties): """ _getLogger().info("Setting custom configuration properties=%r; caller=%r", properties, traceback.format_stack()) - + _CustomConfigurationFileWrapper.edit(properties) - + for propertyName, value in properties.iteritems(): cls.set(propertyName, value) - + @classmethod def clear(cls): """ Clear all configuration properties from in-memory cache, but do NOT @@ -104,8 +104,8 @@ def clear(cls): # Reset in-memory custom configuration info. _CustomConfigurationFileWrapper.clear(persistent=False) - - + + @classmethod def resetCustomConfig(cls): """ Clear all custom configuration settings and delete the persistent @@ -128,7 +128,7 @@ def loadCustomConfig(cls): """ Loads custom configuration settings from their persistent storage. DO NOT CALL THIS: It's typically not necessary to call this method directly - see NOTE below. - + NOTE: this method exists *solely* for the benefit of prepare_conf.py, which needs to load configuration files selectively. """ @@ -273,7 +273,7 @@ def edit(cls, properties): newProp.append(valueTag) elements.append(newProp) - + try: makeDirectoryFromAbsolutePath(os.path.dirname(configFilePath)) with open(configFilePath,'w') as fp: diff --git a/src/nupic/support/consoleprinter.py b/src/nupic/support/console_printer.py similarity index 100% rename from src/nupic/support/consoleprinter.py rename to src/nupic/support/console_printer.py diff --git a/src/nupic/support/fshelpers.py b/src/nupic/support/fs_helpers.py similarity index 100% rename from src/nupic/support/fshelpers.py rename to src/nupic/support/fs_helpers.py diff --git a/src/nupic/support/lockattributes.py b/src/nupic/support/lock_attributes.py similarity index 100% rename from src/nupic/support/lockattributes.py rename to src/nupic/support/lock_attributes.py diff --git a/src/nupic/support/pymysqlhelpers.py b/src/nupic/support/pymysql_helpers.py similarity index 100% rename from src/nupic/support/pymysqlhelpers.py rename to src/nupic/support/pymysql_helpers.py diff --git a/tests/unit/nupic/support/consoleprinter_test/consoleprinter_test.py b/tests/unit/nupic/support/consoleprinter_test/consoleprinter_test.py index 00e8275f35..370d34181e 100755 --- a/tests/unit/nupic/support/consoleprinter_test/consoleprinter_test.py +++ b/tests/unit/nupic/support/consoleprinter_test/consoleprinter_test.py @@ -22,7 +22,7 @@ import os import unittest2 as unittest -from nupic.support.consoleprinter import ConsolePrinterMixin, Tee +from nupic.support.console_printer import ConsolePrinterMixin, Tee