partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
Aggregator.next
Return the next aggregated record, if any Parameters: ------------------------------------------------------------------------ record: The input record (values only) from the input source, or None if the input has reached EOF (this will cause this method to f...
src/nupic/data/aggregator.py
def next(self, record, curInputBookmark): """ Return the next aggregated record, if any Parameters: ------------------------------------------------------------------------ record: The input record (values only) from the input source, or None if the input has reached EOF (th...
def next(self, record, curInputBookmark): """ Return the next aggregated record, if any Parameters: ------------------------------------------------------------------------ record: The input record (values only) from the input source, or None if the input has reached EOF (th...
[ "Return", "the", "next", "aggregated", "record", "if", "any" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/aggregator.py#L515-L716
[ "def", "next", "(", "self", ",", "record", ",", "curInputBookmark", ")", ":", "# This will hold the aggregated record we return", "outRecord", "=", "None", "# This will hold the bookmark of the last input used within the", "# aggregated record we return.", "retInputBookmark", "=",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
processClubAttendance
Process the attendance data of one club If the club already exists in the list update its data. If the club is new create a new Club object and add it to the dict The next step is to iterate over all the lines and add a record for each line. When reaching an empty line it means there are no more records f...
src/nupic/datafiles/extra/gym/raw/makeDataset.py
def processClubAttendance(f, clubs): """Process the attendance data of one club If the club already exists in the list update its data. If the club is new create a new Club object and add it to the dict The next step is to iterate over all the lines and add a record for each line. When reaching an empty...
def processClubAttendance(f, clubs): """Process the attendance data of one club If the club already exists in the list update its data. If the club is new create a new Club object and add it to the dict The next step is to iterate over all the lines and add a record for each line. When reaching an empty...
[ "Process", "the", "attendance", "data", "of", "one", "club", "If", "the", "club", "already", "exists", "in", "the", "list", "update", "its", "data", ".", "If", "the", "club", "is", "new", "create", "a", "new", "Club", "object", "and", "add", "it", "to"...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/datafiles/extra/gym/raw/makeDataset.py#L124-L156
[ "def", "processClubAttendance", "(", "f", ",", "clubs", ")", ":", "try", ":", "# Skip as many empty lines as necessary (file format inconsistent)", "line", "=", "f", ".", "next", "(", ")", "while", "line", "==", "',,,,,,,,,,,,,,,,,,,\\n'", ":", "line", "=", "f", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
processClubConsumption
Process the consumption a club - Skip the header line - Iterate over lines - Read 4 records at a time - Parse each line: club, date, time, consumption - Get club object from dictionary if needed - Aggregate consumption - Call club.processConsumption() with data
src/nupic/datafiles/extra/gym/raw/makeDataset.py
def processClubConsumption(f, clubs): """Process the consumption a club - Skip the header line - Iterate over lines - Read 4 records at a time - Parse each line: club, date, time, consumption - Get club object from dictionary if needed - Aggregate consumption - Call club.processConsum...
def processClubConsumption(f, clubs): """Process the consumption a club - Skip the header line - Iterate over lines - Read 4 records at a time - Parse each line: club, date, time, consumption - Get club object from dictionary if needed - Aggregate consumption - Call club.processConsum...
[ "Process", "the", "consumption", "a", "club", "-", "Skip", "the", "header", "line", "-", "Iterate", "over", "lines", "-", "Read", "4", "records", "at", "a", "time", "-", "Parse", "each", "line", ":", "club", "date", "time", "consumption", "-", "Get", "...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/datafiles/extra/gym/raw/makeDataset.py#L158-L228
[ "def", "processClubConsumption", "(", "f", ",", "clubs", ")", ":", "try", ":", "# Skip header line", "line", "=", "f", ".", "next", "(", ")", "assert", "line", ".", "endswith", "(", "'\" \",\"SITE_LOCATION_NAME\",\"TIMESTAMP\",\"TOTAL_KWH\"\\n'", ")", "valid_times...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Model.run
Run one iteration of this model. :param inputRecord: (object) A record object formatted according to :meth:`~nupic.data.record_stream.RecordStreamIface.getNextRecord` or :meth:`~nupic.data.record_stream.RecordStreamIface.getNextRecordDict` result format. :returns: (:...
src/nupic/frameworks/opf/model.py
def run(self, inputRecord): """ Run one iteration of this model. :param inputRecord: (object) A record object formatted according to :meth:`~nupic.data.record_stream.RecordStreamIface.getNextRecord` or :meth:`~nupic.data.record_stream.RecordStreamIface.getNextRecordDict` ...
def run(self, inputRecord): """ Run one iteration of this model. :param inputRecord: (object) A record object formatted according to :meth:`~nupic.data.record_stream.RecordStreamIface.getNextRecord` or :meth:`~nupic.data.record_stream.RecordStreamIface.getNextRecordDict` ...
[ "Run", "one", "iteration", "of", "this", "model", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L78-L97
[ "def", "run", "(", "self", ",", "inputRecord", ")", ":", "# 0-based prediction index for ModelResult", "predictionNumber", "=", "self", ".", "_numPredictions", "self", ".", "_numPredictions", "+=", "1", "result", "=", "opf_utils", ".", "ModelResult", "(", "predictio...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Model._getModelCheckpointFilePath
Return the absolute path of the model's checkpoint file. :param checkpointDir: (string) Directory of where the experiment is to be or was saved :returns: (string) An absolute path.
src/nupic/frameworks/opf/model.py
def _getModelCheckpointFilePath(checkpointDir): """ Return the absolute path of the model's checkpoint file. :param checkpointDir: (string) Directory of where the experiment is to be or was saved :returns: (string) An absolute path. """ path = os.path.join(checkpointDir, "model.data") ...
def _getModelCheckpointFilePath(checkpointDir): """ Return the absolute path of the model's checkpoint file. :param checkpointDir: (string) Directory of where the experiment is to be or was saved :returns: (string) An absolute path. """ path = os.path.join(checkpointDir, "model.data") ...
[ "Return", "the", "absolute", "path", "of", "the", "model", "s", "checkpoint", "file", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L228-L237
[ "def", "_getModelCheckpointFilePath", "(", "checkpointDir", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "checkpointDir", ",", "\"model.data\"", ")", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "return", "path" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Model.writeToCheckpoint
Serializes model using capnproto and writes data to ``checkpointDir``
src/nupic/frameworks/opf/model.py
def writeToCheckpoint(self, checkpointDir): """Serializes model using capnproto and writes data to ``checkpointDir``""" proto = self.getSchema().new_message() self.write(proto) checkpointPath = self._getModelCheckpointFilePath(checkpointDir) # Clean up old saved state, if any if os.path.exist...
def writeToCheckpoint(self, checkpointDir): """Serializes model using capnproto and writes data to ``checkpointDir``""" proto = self.getSchema().new_message() self.write(proto) checkpointPath = self._getModelCheckpointFilePath(checkpointDir) # Clean up old saved state, if any if os.path.exist...
[ "Serializes", "model", "using", "capnproto", "and", "writes", "data", "to", "checkpointDir" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L239-L265
[ "def", "writeToCheckpoint", "(", "self", ",", "checkpointDir", ")", ":", "proto", "=", "self", ".", "getSchema", "(", ")", ".", "new_message", "(", ")", "self", ".", "write", "(", "proto", ")", "checkpointPath", "=", "self", ".", "_getModelCheckpointFilePath...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Model.readFromCheckpoint
Deserializes model from checkpointDir using capnproto
src/nupic/frameworks/opf/model.py
def readFromCheckpoint(cls, checkpointDir): """Deserializes model from checkpointDir using capnproto""" checkpointPath = cls._getModelCheckpointFilePath(checkpointDir) with open(checkpointPath, 'r') as f: proto = cls.getSchema().read(f, traversal_limit_in_words=_TRA...
def readFromCheckpoint(cls, checkpointDir): """Deserializes model from checkpointDir using capnproto""" checkpointPath = cls._getModelCheckpointFilePath(checkpointDir) with open(checkpointPath, 'r') as f: proto = cls.getSchema().read(f, traversal_limit_in_words=_TRA...
[ "Deserializes", "model", "from", "checkpointDir", "using", "capnproto" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L268-L277
[ "def", "readFromCheckpoint", "(", "cls", ",", "checkpointDir", ")", ":", "checkpointPath", "=", "cls", ".", "_getModelCheckpointFilePath", "(", "checkpointDir", ")", "with", "open", "(", "checkpointPath", ",", "'r'", ")", "as", "f", ":", "proto", "=", "cls", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Model.writeBaseToProto
Save the state maintained by the Model base class :param proto: capnp ModelProto message builder
src/nupic/frameworks/opf/model.py
def writeBaseToProto(self, proto): """Save the state maintained by the Model base class :param proto: capnp ModelProto message builder """ inferenceType = self.getInferenceType() # lower-case first letter to be compatible with capnproto enum naming inferenceType = inferenceType[:1].lower() + in...
def writeBaseToProto(self, proto): """Save the state maintained by the Model base class :param proto: capnp ModelProto message builder """ inferenceType = self.getInferenceType() # lower-case first letter to be compatible with capnproto enum naming inferenceType = inferenceType[:1].lower() + in...
[ "Save", "the", "state", "maintained", "by", "the", "Model", "base", "class" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L280-L294
[ "def", "writeBaseToProto", "(", "self", ",", "proto", ")", ":", "inferenceType", "=", "self", ".", "getInferenceType", "(", ")", "# lower-case first letter to be compatible with capnproto enum naming", "inferenceType", "=", "inferenceType", "[", ":", "1", "]", ".", "l...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Model.save
Save the model in the given directory. :param saveModelDir: (string) Absolute directory path for saving the model. This directory should only be used to store a saved model. If the directory does not exist, it will be created automatically and populated with model data. A pre-ex...
src/nupic/frameworks/opf/model.py
def save(self, saveModelDir): """ Save the model in the given directory. :param saveModelDir: (string) Absolute directory path for saving the model. This directory should only be used to store a saved model. If the directory does not exist, it will be created automatically and popula...
def save(self, saveModelDir): """ Save the model in the given directory. :param saveModelDir: (string) Absolute directory path for saving the model. This directory should only be used to store a saved model. If the directory does not exist, it will be created automatically and popula...
[ "Save", "the", "model", "in", "the", "given", "directory", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L317-L364
[ "def", "save", "(", "self", ",", "saveModelDir", ")", ":", "logger", "=", "self", ".", "_getLogger", "(", ")", "logger", ".", "debug", "(", "\"(%s) Creating local checkpoint in %r...\"", ",", "self", ",", "saveModelDir", ")", "modelPickleFilePath", "=", "self", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Model.load
Load saved model. :param savedModelDir: (string) Directory of where the experiment is to be or was saved :returns: (:class:`Model`) The loaded model instance
src/nupic/frameworks/opf/model.py
def load(cls, savedModelDir): """ Load saved model. :param savedModelDir: (string) Directory of where the experiment is to be or was saved :returns: (:class:`Model`) The loaded model instance """ logger = opf_utils.initLogger(cls) logger.debug("Loading model from local checkpoint at ...
def load(cls, savedModelDir): """ Load saved model. :param savedModelDir: (string) Directory of where the experiment is to be or was saved :returns: (:class:`Model`) The loaded model instance """ logger = opf_utils.initLogger(cls) logger.debug("Loading model from local checkpoint at ...
[ "Load", "saved", "model", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L377-L403
[ "def", "load", "(", "cls", ",", "savedModelDir", ")", ":", "logger", "=", "opf_utils", ".", "initLogger", "(", "cls", ")", "logger", ".", "debug", "(", "\"Loading model from local checkpoint at %r...\"", ",", "savedModelDir", ")", "# Load the model", "modelPickleFil...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Model._getModelPickleFilePath
Return the absolute path of the model's pickle file. :param saveModelDir: (string) Directory of where the experiment is to be or was saved :returns: (string) An absolute path.
src/nupic/frameworks/opf/model.py
def _getModelPickleFilePath(saveModelDir): """ Return the absolute path of the model's pickle file. :param saveModelDir: (string) Directory of where the experiment is to be or was saved :returns: (string) An absolute path. """ path = os.path.join(saveModelDir, "model.pkl") path = os....
def _getModelPickleFilePath(saveModelDir): """ Return the absolute path of the model's pickle file. :param saveModelDir: (string) Directory of where the experiment is to be or was saved :returns: (string) An absolute path. """ path = os.path.join(saveModelDir, "model.pkl") path = os....
[ "Return", "the", "absolute", "path", "of", "the", "model", "s", "pickle", "file", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L417-L426
[ "def", "_getModelPickleFilePath", "(", "saveModelDir", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "saveModelDir", ",", "\"model.pkl\"", ")", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "return", "path" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Model._getModelExtraDataDir
Return the absolute path to the directory where the model's own "extra data" are stored (i.e., data that's too big for pickling). :param saveModelDir: (string) Directory of where the experiment is to be or was saved :returns: (string) An absolute path.
src/nupic/frameworks/opf/model.py
def _getModelExtraDataDir(saveModelDir): """ Return the absolute path to the directory where the model's own "extra data" are stored (i.e., data that's too big for pickling). :param saveModelDir: (string) Directory of where the experiment is to be or was saved :returns: (string) An absolute ...
def _getModelExtraDataDir(saveModelDir): """ Return the absolute path to the directory where the model's own "extra data" are stored (i.e., data that's too big for pickling). :param saveModelDir: (string) Directory of where the experiment is to be or was saved :returns: (string) An absolute ...
[ "Return", "the", "absolute", "path", "to", "the", "directory", "where", "the", "model", "s", "own", "extra", "data", "are", "stored", "(", "i", ".", "e", ".", "data", "that", "s", "too", "big", "for", "pickling", ")", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/model.py#L429-L440
[ "def", "_getModelExtraDataDir", "(", "saveModelDir", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "saveModelDir", ",", "\"modelextradata\"", ")", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "return", "path" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
runExperiment
Run a single OPF experiment. .. note:: The caller is responsible for initializing python logging before calling this function (e.g., import :mod:`nupic.support`; :meth:`nupic.support.initLogging`) See also: :meth:`.initExperimentPrng`. :param args: (string) Experiment command-line args list. Too see ...
src/nupic/frameworks/opf/experiment_runner.py
def runExperiment(args, model=None): """ Run a single OPF experiment. .. note:: The caller is responsible for initializing python logging before calling this function (e.g., import :mod:`nupic.support`; :meth:`nupic.support.initLogging`) See also: :meth:`.initExperimentPrng`. :param args: (string...
def runExperiment(args, model=None): """ Run a single OPF experiment. .. note:: The caller is responsible for initializing python logging before calling this function (e.g., import :mod:`nupic.support`; :meth:`nupic.support.initLogging`) See also: :meth:`.initExperimentPrng`. :param args: (string...
[ "Run", "a", "single", "OPF", "experiment", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L132-L181
[ "def", "runExperiment", "(", "args", ",", "model", "=", "None", ")", ":", "# Parse command-line options", "opt", "=", "_parseCommandLineOptions", "(", "args", ")", "#print \"runExperiment: Parsed Command Options: \", opt", "model", "=", "_runExperimentImpl", "(", "opt", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_parseCommandLineOptions
Parse command line options Args: args: command line arguments (not including sys.argv[0]) Returns: namedtuple ParseCommandLineOptionsResult
src/nupic/frameworks/opf/experiment_runner.py
def _parseCommandLineOptions(args): """Parse command line options Args: args: command line arguments (not including sys.argv[0]) Returns: namedtuple ParseCommandLineOptionsResult """ usageStr = ( "%prog [options] descriptionPyDirectory\n" "This script runs a single OPF Model described by desc...
def _parseCommandLineOptions(args): """Parse command line options Args: args: command line arguments (not including sys.argv[0]) Returns: namedtuple ParseCommandLineOptionsResult """ usageStr = ( "%prog [options] descriptionPyDirectory\n" "This script runs a single OPF Model described by desc...
[ "Parse", "command", "line", "options" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L210-L332
[ "def", "_parseCommandLineOptions", "(", "args", ")", ":", "usageStr", "=", "(", "\"%prog [options] descriptionPyDirectory\\n\"", "\"This script runs a single OPF Model described by description.py \"", "\"located in the given directory.\"", ")", "parser", "=", "optparse", ".", "Opti...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
reapVarArgsCallback
Used as optparse callback for reaping a variable number of option args. The option may be specified multiple times, and all the args associated with that option name will be accumulated in the order that they are encountered
src/nupic/frameworks/opf/experiment_runner.py
def reapVarArgsCallback(option, optStr, value, parser): """Used as optparse callback for reaping a variable number of option args. The option may be specified multiple times, and all the args associated with that option name will be accumulated in the order that they are encountered """ newValues = [] # Re...
def reapVarArgsCallback(option, optStr, value, parser): """Used as optparse callback for reaping a variable number of option args. The option may be specified multiple times, and all the args associated with that option name will be accumulated in the order that they are encountered """ newValues = [] # Re...
[ "Used", "as", "optparse", "callback", "for", "reaping", "a", "variable", "number", "of", "option", "args", ".", "The", "option", "may", "be", "specified", "multiple", "times", "and", "all", "the", "args", "associated", "with", "that", "option", "name", "will...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L336-L375
[ "def", "reapVarArgsCallback", "(", "option", ",", "optStr", ",", "value", ",", "parser", ")", ":", "newValues", "=", "[", "]", "# Reap the args, taking care to stop before the next option or '.'", "gotDot", "=", "False", "for", "arg", "in", "parser", ".", "rargs", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_reportCommandLineUsageErrorAndExit
Report usage error and exit program with error indication.
src/nupic/frameworks/opf/experiment_runner.py
def _reportCommandLineUsageErrorAndExit(parser, message): """Report usage error and exit program with error indication.""" print parser.get_usage() print message sys.exit(1)
def _reportCommandLineUsageErrorAndExit(parser, message): """Report usage error and exit program with error indication.""" print parser.get_usage() print message sys.exit(1)
[ "Report", "usage", "error", "and", "exit", "program", "with", "error", "indication", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L379-L383
[ "def", "_reportCommandLineUsageErrorAndExit", "(", "parser", ",", "message", ")", ":", "print", "parser", ".", "get_usage", "(", ")", "print", "message", "sys", ".", "exit", "(", "1", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_runExperimentImpl
Creates and runs the experiment Args: options: namedtuple ParseCommandLineOptionsResult model: For testing: may pass in an existing OPF Model instance to use instead of creating a new one. Returns: reference to OPFExperiment instance that was constructed (this is provided to aid with debuggi...
src/nupic/frameworks/opf/experiment_runner.py
def _runExperimentImpl(options, model=None): """Creates and runs the experiment Args: options: namedtuple ParseCommandLineOptionsResult model: For testing: may pass in an existing OPF Model instance to use instead of creating a new one. Returns: reference to OPFExperiment instance that was const...
def _runExperimentImpl(options, model=None): """Creates and runs the experiment Args: options: namedtuple ParseCommandLineOptionsResult model: For testing: may pass in an existing OPF Model instance to use instead of creating a new one. Returns: reference to OPFExperiment instance that was const...
[ "Creates", "and", "runs", "the", "experiment" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L387-L509
[ "def", "_runExperimentImpl", "(", "options", ",", "model", "=", "None", ")", ":", "json_helpers", ".", "validate", "(", "options", ".", "privateOptions", ",", "schemaDict", "=", "g_parsedPrivateCommandLineOptionsSchema", ")", "# Load the experiment's description.py module...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_saveModel
Save model
src/nupic/frameworks/opf/experiment_runner.py
def _saveModel(model, experimentDir, checkpointLabel, newSerialization=False): """Save model""" checkpointDir = _getModelCheckpointDir(experimentDir, checkpointLabel) if newSerialization: model.writeToCheckpoint(checkpointDir) else: model.save(saveModelDir=checkpointDir)
def _saveModel(model, experimentDir, checkpointLabel, newSerialization=False): """Save model""" checkpointDir = _getModelCheckpointDir(experimentDir, checkpointLabel) if newSerialization: model.writeToCheckpoint(checkpointDir) else: model.save(saveModelDir=checkpointDir)
[ "Save", "model" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L513-L519
[ "def", "_saveModel", "(", "model", ",", "experimentDir", ",", "checkpointLabel", ",", "newSerialization", "=", "False", ")", ":", "checkpointDir", "=", "_getModelCheckpointDir", "(", "experimentDir", ",", "checkpointLabel", ")", "if", "newSerialization", ":", "model...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_getModelCheckpointDir
Creates directory for serialization of the model checkpointLabel: Checkpoint label (string) Returns: absolute path to the serialization directory
src/nupic/frameworks/opf/experiment_runner.py
def _getModelCheckpointDir(experimentDir, checkpointLabel): """Creates directory for serialization of the model checkpointLabel: Checkpoint label (string) Returns: absolute path to the serialization directory """ checkpointDir = os.path.join(getCheckpointParentDir(experimentDir), ...
def _getModelCheckpointDir(experimentDir, checkpointLabel): """Creates directory for serialization of the model checkpointLabel: Checkpoint label (string) Returns: absolute path to the serialization directory """ checkpointDir = os.path.join(getCheckpointParentDir(experimentDir), ...
[ "Creates", "directory", "for", "serialization", "of", "the", "model" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L523-L536
[ "def", "_getModelCheckpointDir", "(", "experimentDir", ",", "checkpointLabel", ")", ":", "checkpointDir", "=", "os", ".", "path", ".", "join", "(", "getCheckpointParentDir", "(", "experimentDir", ")", ",", "checkpointLabel", "+", "g_defaultCheckpointExtension", ")", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
getCheckpointParentDir
Get checkpoint parent dir. Returns: absolute path to the base serialization directory within which model checkpoints for this experiment are created
src/nupic/frameworks/opf/experiment_runner.py
def getCheckpointParentDir(experimentDir): """Get checkpoint parent dir. Returns: absolute path to the base serialization directory within which model checkpoints for this experiment are created """ baseDir = os.path.join(experimentDir, "savedmodels") baseDir = os.path.abspath(baseDir) return baseDi...
def getCheckpointParentDir(experimentDir): """Get checkpoint parent dir. Returns: absolute path to the base serialization directory within which model checkpoints for this experiment are created """ baseDir = os.path.join(experimentDir, "savedmodels") baseDir = os.path.abspath(baseDir) return baseDi...
[ "Get", "checkpoint", "parent", "dir", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L540-L549
[ "def", "getCheckpointParentDir", "(", "experimentDir", ")", ":", "baseDir", "=", "os", ".", "path", ".", "join", "(", "experimentDir", ",", "\"savedmodels\"", ")", "baseDir", "=", "os", ".", "path", ".", "abspath", "(", "baseDir", ")", "return", "baseDir" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_checkpointLabelFromCheckpointDir
Returns a checkpoint label string for the given model checkpoint directory checkpointDir: relative or absolute model checkpoint directory path
src/nupic/frameworks/opf/experiment_runner.py
def _checkpointLabelFromCheckpointDir(checkpointDir): """Returns a checkpoint label string for the given model checkpoint directory checkpointDir: relative or absolute model checkpoint directory path """ assert checkpointDir.endswith(g_defaultCheckpointExtension) lastSegment = os.path.split(checkpointDir)[1...
def _checkpointLabelFromCheckpointDir(checkpointDir): """Returns a checkpoint label string for the given model checkpoint directory checkpointDir: relative or absolute model checkpoint directory path """ assert checkpointDir.endswith(g_defaultCheckpointExtension) lastSegment = os.path.split(checkpointDir)[1...
[ "Returns", "a", "checkpoint", "label", "string", "for", "the", "given", "model", "checkpoint", "directory" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L553-L564
[ "def", "_checkpointLabelFromCheckpointDir", "(", "checkpointDir", ")", ":", "assert", "checkpointDir", ".", "endswith", "(", "g_defaultCheckpointExtension", ")", "lastSegment", "=", "os", ".", "path", ".", "split", "(", "checkpointDir", ")", "[", "1", "]", "checkp...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_isCheckpointDir
Return true iff checkpointDir appears to be a checkpoint directory.
src/nupic/frameworks/opf/experiment_runner.py
def _isCheckpointDir(checkpointDir): """Return true iff checkpointDir appears to be a checkpoint directory.""" lastSegment = os.path.split(checkpointDir)[1] if lastSegment[0] == '.': return False if not checkpointDir.endswith(g_defaultCheckpointExtension): return False if not os.path.isdir(checkpoin...
def _isCheckpointDir(checkpointDir): """Return true iff checkpointDir appears to be a checkpoint directory.""" lastSegment = os.path.split(checkpointDir)[1] if lastSegment[0] == '.': return False if not checkpointDir.endswith(g_defaultCheckpointExtension): return False if not os.path.isdir(checkpoin...
[ "Return", "true", "iff", "checkpointDir", "appears", "to", "be", "a", "checkpoint", "directory", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L568-L580
[ "def", "_isCheckpointDir", "(", "checkpointDir", ")", ":", "lastSegment", "=", "os", ".", "path", ".", "split", "(", "checkpointDir", ")", "[", "1", "]", "if", "lastSegment", "[", "0", "]", "==", "'.'", ":", "return", "False", "if", "not", "checkpointDir...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_printAvailableCheckpoints
List available checkpoints for the specified experiment.
src/nupic/frameworks/opf/experiment_runner.py
def _printAvailableCheckpoints(experimentDir): """List available checkpoints for the specified experiment.""" checkpointParentDir = getCheckpointParentDir(experimentDir) if not os.path.exists(checkpointParentDir): print "No available checkpoints." return checkpointDirs = [x for x in os.listdir(checkpo...
def _printAvailableCheckpoints(experimentDir): """List available checkpoints for the specified experiment.""" checkpointParentDir = getCheckpointParentDir(experimentDir) if not os.path.exists(checkpointParentDir): print "No available checkpoints." return checkpointDirs = [x for x in os.listdir(checkpo...
[ "List", "available", "checkpoints", "for", "the", "specified", "experiment", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L584-L609
[ "def", "_printAvailableCheckpoints", "(", "experimentDir", ")", ":", "checkpointParentDir", "=", "getCheckpointParentDir", "(", "experimentDir", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "checkpointParentDir", ")", ":", "print", "\"No available checkpoi...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_TaskRunner.run
Runs a single experiment task
src/nupic/frameworks/opf/experiment_runner.py
def run(self): """Runs a single experiment task""" self.__logger.debug("run(): Starting task <%s>", self.__task['taskLabel']) # Set up the task # Create our main loop-control iterator if self.__cmdOptions.privateOptions['testMode']: numIters = 10 else: numIters = self.__task['itera...
def run(self): """Runs a single experiment task""" self.__logger.debug("run(): Starting task <%s>", self.__task['taskLabel']) # Set up the task # Create our main loop-control iterator if self.__cmdOptions.privateOptions['testMode']: numIters = 10 else: numIters = self.__task['itera...
[ "Runs", "a", "single", "experiment", "task" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L686-L751
[ "def", "run", "(", "self", ")", ":", "self", ".", "__logger", ".", "debug", "(", "\"run(): Starting task <%s>\"", ",", "self", ".", "__task", "[", "'taskLabel'", "]", ")", "# Set up the task", "# Create our main loop-control iterator", "if", "self", ".", "__cmdOpt...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_TaskRunner._createPeriodicActivities
Creates and returns a list of activites for this TaskRunner instance Returns: a list of PeriodicActivityRequest elements
src/nupic/frameworks/opf/experiment_runner.py
def _createPeriodicActivities(self): """Creates and returns a list of activites for this TaskRunner instance Returns: a list of PeriodicActivityRequest elements """ # Initialize periodic activities periodicActivities = [] # Metrics reporting class MetricsReportCb(object): def __init_...
def _createPeriodicActivities(self): """Creates and returns a list of activites for this TaskRunner instance Returns: a list of PeriodicActivityRequest elements """ # Initialize periodic activities periodicActivities = [] # Metrics reporting class MetricsReportCb(object): def __init_...
[ "Creates", "and", "returns", "a", "list", "of", "activites", "for", "this", "TaskRunner", "instance" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/experiment_runner.py#L754-L807
[ "def", "_createPeriodicActivities", "(", "self", ")", ":", "# Initialize periodic activities", "periodicActivities", "=", "[", "]", "# Metrics reporting", "class", "MetricsReportCb", "(", "object", ")", ":", "def", "__init__", "(", "self", ",", "taskRunner", ")", ":...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_generateFile
Parameters: ---------------------------------------------------------------- filename: name of .csv file to generate
src/nupic/datafiles/extra/regression/makeDataset.py
def _generateFile(filename, data): """ Parameters: ---------------------------------------------------------------- filename: name of .csv file to generate """ # Create the file print "Creating %s..." % (filename) numRecords, numFields = data.shape fields = [('field%...
def _generateFile(filename, data): """ Parameters: ---------------------------------------------------------------- filename: name of .csv file to generate """ # Create the file print "Creating %s..." % (filename) numRecords, numFields = data.shape fields = [('field%...
[ "Parameters", ":", "----------------------------------------------------------------", "filename", ":", "name", "of", ".", "csv", "file", "to", "generate" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/datafiles/extra/regression/makeDataset.py#L93-L111
[ "def", "_generateFile", "(", "filename", ",", "data", ")", ":", "# Create the file", "print", "\"Creating %s...\"", "%", "(", "filename", ")", "numRecords", ",", "numFields", "=", "data", ".", "shape", "fields", "=", "[", "(", "'field%d'", "%", "(", "i", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
corruptVector
Corrupts a copy of a binary vector by inverting noiseLevel percent of its bits. @param v1 (array) binary vector whose copy will be corrupted @param noiseLevel (float) amount of noise to be applied on the new vector @param numActiveCols (int) number of sparse columns that represent an input @return...
examples/tm/tm_high_order.py
def corruptVector(v1, noiseLevel, numActiveCols): """ Corrupts a copy of a binary vector by inverting noiseLevel percent of its bits. @param v1 (array) binary vector whose copy will be corrupted @param noiseLevel (float) amount of noise to be applied on the new vector @param numActiveCols (int) num...
def corruptVector(v1, noiseLevel, numActiveCols): """ Corrupts a copy of a binary vector by inverting noiseLevel percent of its bits. @param v1 (array) binary vector whose copy will be corrupted @param noiseLevel (float) amount of noise to be applied on the new vector @param numActiveCols (int) num...
[ "Corrupts", "a", "copy", "of", "a", "binary", "vector", "by", "inverting", "noiseLevel", "percent", "of", "its", "bits", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/tm/tm_high_order.py#L53-L75
[ "def", "corruptVector", "(", "v1", ",", "noiseLevel", ",", "numActiveCols", ")", ":", "size", "=", "len", "(", "v1", ")", "v2", "=", "np", ".", "zeros", "(", "size", ",", "dtype", "=", "\"uint32\"", ")", "bitsToSwap", "=", "int", "(", "noiseLevel", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
showPredictions
Shows predictions of the TM when presented with the characters A, B, C, D, X, and Y without any contextual information, that is, not embedded within a sequence.
examples/tm/tm_high_order.py
def showPredictions(): """ Shows predictions of the TM when presented with the characters A, B, C, D, X, and Y without any contextual information, that is, not embedded within a sequence. """ for k in range(6): tm.reset() print "--- " + "ABCDXY"[k] + " ---" tm.compute(set(seqT[k][:].nonzero()[0...
def showPredictions(): """ Shows predictions of the TM when presented with the characters A, B, C, D, X, and Y without any contextual information, that is, not embedded within a sequence. """ for k in range(6): tm.reset() print "--- " + "ABCDXY"[k] + " ---" tm.compute(set(seqT[k][:].nonzero()[0...
[ "Shows", "predictions", "of", "the", "TM", "when", "presented", "with", "the", "characters", "A", "B", "C", "D", "X", "and", "Y", "without", "any", "contextual", "information", "that", "is", "not", "embedded", "within", "a", "sequence", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/tm/tm_high_order.py#L78-L93
[ "def", "showPredictions", "(", ")", ":", "for", "k", "in", "range", "(", "6", ")", ":", "tm", ".", "reset", "(", ")", "print", "\"--- \"", "+", "\"ABCDXY\"", "[", "k", "]", "+", "\" ---\"", "tm", ".", "compute", "(", "set", "(", "seqT", "[", "k",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
trainTM
Trains the TM with given sequence for a given number of time steps and level of input corruption @param sequence (array) array whose rows are the input characters @param timeSteps (int) number of time steps in which the TM will be presented with sequence @param noiseLevel (float) amount of noise to be a...
examples/tm/tm_high_order.py
def trainTM(sequence, timeSteps, noiseLevel): """ Trains the TM with given sequence for a given number of time steps and level of input corruption @param sequence (array) array whose rows are the input characters @param timeSteps (int) number of time steps in which the TM will be presented with sequen...
def trainTM(sequence, timeSteps, noiseLevel): """ Trains the TM with given sequence for a given number of time steps and level of input corruption @param sequence (array) array whose rows are the input characters @param timeSteps (int) number of time steps in which the TM will be presented with sequen...
[ "Trains", "the", "TM", "with", "given", "sequence", "for", "a", "given", "number", "of", "time", "steps", "and", "level", "of", "input", "corruption" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/tm/tm_high_order.py#L96-L120
[ "def", "trainTM", "(", "sequence", ",", "timeSteps", ",", "noiseLevel", ")", ":", "currentColumns", "=", "np", ".", "zeros", "(", "tm", ".", "numberOfColumns", "(", ")", ",", "dtype", "=", "\"uint32\"", ")", "predictedColumns", "=", "np", ".", "zeros", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
PassThroughEncoder.encodeIntoArray
See method description in base.py
src/nupic/encoders/pass_through.py
def encodeIntoArray(self, inputVal, outputVal): """See method description in base.py""" if len(inputVal) != len(outputVal): raise ValueError("Different input (%i) and output (%i) sizes." % ( len(inputVal), len(outputVal))) if self.w is not None and sum(inputVal) != self.w: raise Value...
def encodeIntoArray(self, inputVal, outputVal): """See method description in base.py""" if len(inputVal) != len(outputVal): raise ValueError("Different input (%i) and output (%i) sizes." % ( len(inputVal), len(outputVal))) if self.w is not None and sum(inputVal) != self.w: raise Value...
[ "See", "method", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/pass_through.py#L83-L97
[ "def", "encodeIntoArray", "(", "self", ",", "inputVal", ",", "outputVal", ")", ":", "if", "len", "(", "inputVal", ")", "!=", "len", "(", "outputVal", ")", ":", "raise", "ValueError", "(", "\"Different input (%i) and output (%i) sizes.\"", "%", "(", "len", "(",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
PassThroughEncoder.decode
See the function description in base.py
src/nupic/encoders/pass_through.py
def decode(self, encoded, parentFieldName=""): """See the function description in base.py""" if parentFieldName != "": fieldName = "%s.%s" % (parentFieldName, self.name) else: fieldName = self.name return ({fieldName: ([[0, 0]], "input")}, [fieldName])
def decode(self, encoded, parentFieldName=""): """See the function description in base.py""" if parentFieldName != "": fieldName = "%s.%s" % (parentFieldName, self.name) else: fieldName = self.name return ({fieldName: ([[0, 0]], "input")}, [fieldName])
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/pass_through.py#L100-L108
[ "def", "decode", "(", "self", ",", "encoded", ",", "parentFieldName", "=", "\"\"", ")", ":", "if", "parentFieldName", "!=", "\"\"", ":", "fieldName", "=", "\"%s.%s\"", "%", "(", "parentFieldName", ",", "self", ".", "name", ")", "else", ":", "fieldName", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
PassThroughEncoder.getBucketInfo
See the function description in base.py
src/nupic/encoders/pass_through.py
def getBucketInfo(self, buckets): """See the function description in base.py""" return [EncoderResult(value=0, scalar=0, encoding=numpy.zeros(self.n))]
def getBucketInfo(self, buckets): """See the function description in base.py""" return [EncoderResult(value=0, scalar=0, encoding=numpy.zeros(self.n))]
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/pass_through.py#L111-L113
[ "def", "getBucketInfo", "(", "self", ",", "buckets", ")", ":", "return", "[", "EncoderResult", "(", "value", "=", "0", ",", "scalar", "=", "0", ",", "encoding", "=", "numpy", ".", "zeros", "(", "self", ".", "n", ")", ")", "]" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
PassThroughEncoder.topDownCompute
See the function description in base.py
src/nupic/encoders/pass_through.py
def topDownCompute(self, encoded): """See the function description in base.py""" return EncoderResult(value=0, scalar=0, encoding=numpy.zeros(self.n))
def topDownCompute(self, encoded): """See the function description in base.py""" return EncoderResult(value=0, scalar=0, encoding=numpy.zeros(self.n))
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/pass_through.py#L116-L119
[ "def", "topDownCompute", "(", "self", ",", "encoded", ")", ":", "return", "EncoderResult", "(", "value", "=", "0", ",", "scalar", "=", "0", ",", "encoding", "=", "numpy", ".", "zeros", "(", "self", ".", "n", ")", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
PassThroughEncoder.closenessScores
Does a bitwise compare of the two bitmaps and returns a fractonal value between 0 and 1 of how similar they are. - ``1`` => identical - ``0`` => no overlaping bits ``kwargs`` will have the keyword "fractional", which is assumed by this encoder.
src/nupic/encoders/pass_through.py
def closenessScores(self, expValues, actValues, **kwargs): """ Does a bitwise compare of the two bitmaps and returns a fractonal value between 0 and 1 of how similar they are. - ``1`` => identical - ``0`` => no overlaping bits ``kwargs`` will have the keyword "fractional", which is assumed by ...
def closenessScores(self, expValues, actValues, **kwargs): """ Does a bitwise compare of the two bitmaps and returns a fractonal value between 0 and 1 of how similar they are. - ``1`` => identical - ``0`` => no overlaping bits ``kwargs`` will have the keyword "fractional", which is assumed by ...
[ "Does", "a", "bitwise", "compare", "of", "the", "two", "bitmaps", "and", "returns", "a", "fractonal", "value", "between", "0", "and", "1", "of", "how", "similar", "they", "are", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/pass_through.py#L122-L151
[ "def", "closenessScores", "(", "self", ",", "expValues", ",", "actValues", ",", "*", "*", "kwargs", ")", ":", "ratio", "=", "1.0", "esum", "=", "int", "(", "expValues", ".", "sum", "(", ")", ")", "asum", "=", "int", "(", "actValues", ".", "sum", "(...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
getCallerInfo
Utility function to get information about function callers The information is the tuple (function/method name, filename, class) The class will be None if the caller is just a function and not an object method. :param depth: (int) how far back in the callstack to go to extract the caller info
src/nupic/support/__init__.py
def getCallerInfo(depth=2): """Utility function to get information about function callers The information is the tuple (function/method name, filename, class) The class will be None if the caller is just a function and not an object method. :param depth: (int) how far back in the callstack to go to extract ...
def getCallerInfo(depth=2): """Utility function to get information about function callers The information is the tuple (function/method name, filename, class) The class will be None if the caller is just a function and not an object method. :param depth: (int) how far back in the callstack to go to extract ...
[ "Utility", "function", "to", "get", "information", "about", "function", "callers" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/__init__.py#L53-L73
[ "def", "getCallerInfo", "(", "depth", "=", "2", ")", ":", "f", "=", "sys", ".", "_getframe", "(", "depth", ")", "method_name", "=", "f", ".", "f_code", ".", "co_name", "filename", "=", "f", ".", "f_code", ".", "co_filename", "arg_class", "=", "None", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
title
Utility function to display nice titles It automatically extracts the name of the function/method it is called from and you can add additional text. title() will then print the name of the function/method and the additional text surrounded by tow lines of dashes. If you don't want the name of the function, you...
src/nupic/support/__init__.py
def title(s=None, additional='', stream=sys.stdout): """Utility function to display nice titles It automatically extracts the name of the function/method it is called from and you can add additional text. title() will then print the name of the function/method and the additional text surrounded by tow lines ...
def title(s=None, additional='', stream=sys.stdout): """Utility function to display nice titles It automatically extracts the name of the function/method it is called from and you can add additional text. title() will then print the name of the function/method and the additional text surrounded by tow lines ...
[ "Utility", "function", "to", "display", "nice", "titles" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/__init__.py#L77-L144
[ "def", "title", "(", "s", "=", "None", ",", "additional", "=", "''", ",", "stream", "=", "sys", ".", "stdout", ")", ":", "if", "s", "is", "None", ":", "callable_name", ",", "file_name", ",", "class_name", "=", "getCallerInfo", "(", "2", ")", "s", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
getArgumentDescriptions
Get the arguments, default values, and argument descriptions for a function. Parses the argument descriptions out of the function docstring, using a format something lke this: :: [junk] argument_name: description... description... description... [junk] [more arguments] It wil...
src/nupic/support/__init__.py
def getArgumentDescriptions(f): """ Get the arguments, default values, and argument descriptions for a function. Parses the argument descriptions out of the function docstring, using a format something lke this: :: [junk] argument_name: description... description... description... ...
def getArgumentDescriptions(f): """ Get the arguments, default values, and argument descriptions for a function. Parses the argument descriptions out of the function docstring, using a format something lke this: :: [junk] argument_name: description... description... description... ...
[ "Get", "the", "arguments", "default", "values", "and", "argument", "descriptions", "for", "a", "function", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/__init__.py#L148-L241
[ "def", "getArgumentDescriptions", "(", "f", ")", ":", "# Get the argument names and default values", "argspec", "=", "inspect", ".", "getargspec", "(", "f", ")", "# Scan through the docstring to extract documentation for each argument as", "# follows:", "# Check the first word of...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
initLogging
Initilize NuPic logging by reading in from the logging configuration file. The logging configuration file is named ``nupic-logging.conf`` and is expected to be in the format defined by the python logging module. If the environment variable ``NTA_CONF_PATH`` is defined, then the logging configuration file is ex...
src/nupic/support/__init__.py
def initLogging(verbose=False, console='stdout', consoleLevel='DEBUG'): """ Initilize NuPic logging by reading in from the logging configuration file. The logging configuration file is named ``nupic-logging.conf`` and is expected to be in the format defined by the python logging module. If the environment va...
def initLogging(verbose=False, console='stdout', consoleLevel='DEBUG'): """ Initilize NuPic logging by reading in from the logging configuration file. The logging configuration file is named ``nupic-logging.conf`` and is expected to be in the format defined by the python logging module. If the environment va...
[ "Initilize", "NuPic", "logging", "by", "reading", "in", "from", "the", "logging", "configuration", "file", ".", "The", "logging", "configuration", "file", "is", "named", "nupic", "-", "logging", ".", "conf", "and", "is", "expected", "to", "be", "in", "the", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/__init__.py#L246-L386
[ "def", "initLogging", "(", "verbose", "=", "False", ",", "console", "=", "'stdout'", ",", "consoleLevel", "=", "'DEBUG'", ")", ":", "# NOTE: If you call this twice from the same process there seems to be a", "# bug - logged messages don't show up for loggers that you do another", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_genLoggingFilePath
Generate a filepath for the calling app
src/nupic/support/__init__.py
def _genLoggingFilePath(): """ Generate a filepath for the calling app """ appName = os.path.splitext(os.path.basename(sys.argv[0]))[0] or 'UnknownApp' appLogDir = os.path.abspath(os.path.join( os.environ['NTA_LOG_DIR'], 'numenta-logs-%s' % (os.environ['USER'],), appName)) appLogFileName = '%s-%s-%s...
def _genLoggingFilePath(): """ Generate a filepath for the calling app """ appName = os.path.splitext(os.path.basename(sys.argv[0]))[0] or 'UnknownApp' appLogDir = os.path.abspath(os.path.join( os.environ['NTA_LOG_DIR'], 'numenta-logs-%s' % (os.environ['USER'],), appName)) appLogFileName = '%s-%s-%s...
[ "Generate", "a", "filepath", "for", "the", "calling", "app" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/__init__.py#L390-L399
[ "def", "_genLoggingFilePath", "(", ")", ":", "appName", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "sys", ".", "argv", "[", "0", "]", ")", ")", "[", "0", "]", "or", "'UnknownApp'", "appLogDir", "=", "os",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
aggregationToMonthsSeconds
Return the number of months and seconds from an aggregation dict that represents a date and time. Interval is a dict that contain one or more of the following keys: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', seconds', 'milliseconds', 'microseconds'. For example: :: aggregationMicrosecon...
src/nupic/support/__init__.py
def aggregationToMonthsSeconds(interval): """ Return the number of months and seconds from an aggregation dict that represents a date and time. Interval is a dict that contain one or more of the following keys: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', seconds', 'milliseconds', 'microseconds'...
def aggregationToMonthsSeconds(interval): """ Return the number of months and seconds from an aggregation dict that represents a date and time. Interval is a dict that contain one or more of the following keys: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', seconds', 'milliseconds', 'microseconds'...
[ "Return", "the", "number", "of", "months", "and", "seconds", "from", "an", "aggregation", "dict", "that", "represents", "a", "date", "and", "time", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/__init__.py#L403-L438
[ "def", "aggregationToMonthsSeconds", "(", "interval", ")", ":", "seconds", "=", "interval", ".", "get", "(", "'microseconds'", ",", "0", ")", "*", "0.000001", "seconds", "+=", "interval", ".", "get", "(", "'milliseconds'", ",", "0", ")", "*", "0.001", "sec...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
aggregationDivide
Return the result from dividing two dicts that represent date and time. Both dividend and divisor are dicts that contain one or more of the following keys: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', seconds', 'milliseconds', 'microseconds'. For example: :: aggregationDivide({'hours': 4}, ...
src/nupic/support/__init__.py
def aggregationDivide(dividend, divisor): """ Return the result from dividing two dicts that represent date and time. Both dividend and divisor are dicts that contain one or more of the following keys: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', seconds', 'milliseconds', 'microseconds'. For ex...
def aggregationDivide(dividend, divisor): """ Return the result from dividing two dicts that represent date and time. Both dividend and divisor are dicts that contain one or more of the following keys: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', seconds', 'milliseconds', 'microseconds'. For ex...
[ "Return", "the", "result", "from", "dividing", "two", "dicts", "that", "represent", "date", "and", "time", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/__init__.py#L442-L478
[ "def", "aggregationDivide", "(", "dividend", ",", "divisor", ")", ":", "# Convert each into microseconds", "dividendMonthSec", "=", "aggregationToMonthsSeconds", "(", "dividend", ")", "divisorMonthSec", "=", "aggregationToMonthsSeconds", "(", "divisor", ")", "# It is a usag...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
validateOpfJsonValue
Validate a python object against an OPF json schema file :param value: target python object to validate (typically a dictionary) :param opfJsonSchemaFilename: (string) OPF json schema filename containing the json schema object. (e.g., opfTaskControlSchema.json) :raises: jsonhelpers.ValidationError when ...
src/nupic/frameworks/opf/opf_utils.py
def validateOpfJsonValue(value, opfJsonSchemaFilename): """ Validate a python object against an OPF json schema file :param value: target python object to validate (typically a dictionary) :param opfJsonSchemaFilename: (string) OPF json schema filename containing the json schema object. (e.g., opfTask...
def validateOpfJsonValue(value, opfJsonSchemaFilename): """ Validate a python object against an OPF json schema file :param value: target python object to validate (typically a dictionary) :param opfJsonSchemaFilename: (string) OPF json schema filename containing the json schema object. (e.g., opfTask...
[ "Validate", "a", "python", "object", "against", "an", "OPF", "json", "schema", "file" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_utils.py#L354-L372
[ "def", "validateOpfJsonValue", "(", "value", ",", "opfJsonSchemaFilename", ")", ":", "# Create a path by joining the filename with our local json schema root", "jsonSchemaPath", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
initLogger
Helper function to create a logger object for the current object with the standard Numenta prefix. :param obj: (object) to add a logger to
src/nupic/frameworks/opf/opf_utils.py
def initLogger(obj): """ Helper function to create a logger object for the current object with the standard Numenta prefix. :param obj: (object) to add a logger to """ if inspect.isclass(obj): myClass = obj else: myClass = obj.__class__ logger = logging.getLogger(".".join( ['com.numenta', m...
def initLogger(obj): """ Helper function to create a logger object for the current object with the standard Numenta prefix. :param obj: (object) to add a logger to """ if inspect.isclass(obj): myClass = obj else: myClass = obj.__class__ logger = logging.getLogger(".".join( ['com.numenta', m...
[ "Helper", "function", "to", "create", "a", "logger", "object", "for", "the", "current", "object", "with", "the", "standard", "Numenta", "prefix", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_utils.py#L376-L389
[ "def", "initLogger", "(", "obj", ")", ":", "if", "inspect", ".", "isclass", "(", "obj", ")", ":", "myClass", "=", "obj", "else", ":", "myClass", "=", "obj", ".", "__class__", "logger", "=", "logging", ".", "getLogger", "(", "\".\"", ".", "join", "(",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
matchPatterns
Returns a subset of the keys that match any of the given patterns :param patterns: (list) regular expressions to match :param keys: (list) keys to search for matches
src/nupic/frameworks/opf/opf_utils.py
def matchPatterns(patterns, keys): """ Returns a subset of the keys that match any of the given patterns :param patterns: (list) regular expressions to match :param keys: (list) keys to search for matches """ results = [] if patterns: for pattern in patterns: prog = re.compile(pattern) fo...
def matchPatterns(patterns, keys): """ Returns a subset of the keys that match any of the given patterns :param patterns: (list) regular expressions to match :param keys: (list) keys to search for matches """ results = [] if patterns: for pattern in patterns: prog = re.compile(pattern) fo...
[ "Returns", "a", "subset", "of", "the", "keys", "that", "match", "any", "of", "the", "given", "patterns" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_utils.py#L393-L410
[ "def", "matchPatterns", "(", "patterns", ",", "keys", ")", ":", "results", "=", "[", "]", "if", "patterns", ":", "for", "pattern", "in", "patterns", ":", "prog", "=", "re", ".", "compile", "(", "pattern", ")", "for", "key", "in", "keys", ":", "if", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
LogEncoder._getScaledValue
Convert the input, which is in normal space, into log space
src/nupic/encoders/logarithm.py
def _getScaledValue(self, inpt): """ Convert the input, which is in normal space, into log space """ if inpt == SENTINEL_VALUE_FOR_MISSING_DATA: return None else: val = inpt if val < self.minval: val = self.minval elif val > self.maxval: val = self.maxval ...
def _getScaledValue(self, inpt): """ Convert the input, which is in normal space, into log space """ if inpt == SENTINEL_VALUE_FOR_MISSING_DATA: return None else: val = inpt if val < self.minval: val = self.minval elif val > self.maxval: val = self.maxval ...
[ "Convert", "the", "input", "which", "is", "in", "normal", "space", "into", "log", "space" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/logarithm.py#L131-L145
[ "def", "_getScaledValue", "(", "self", ",", "inpt", ")", ":", "if", "inpt", "==", "SENTINEL_VALUE_FOR_MISSING_DATA", ":", "return", "None", "else", ":", "val", "=", "inpt", "if", "val", "<", "self", ".", "minval", ":", "val", "=", "self", ".", "minval", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
LogEncoder.getBucketIndices
See the function description in base.py
src/nupic/encoders/logarithm.py
def getBucketIndices(self, inpt): """ See the function description in base.py """ # Get the scaled value scaledVal = self._getScaledValue(inpt) if scaledVal is None: return [None] else: return self.encoder.getBucketIndices(scaledVal)
def getBucketIndices(self, inpt): """ See the function description in base.py """ # Get the scaled value scaledVal = self._getScaledValue(inpt) if scaledVal is None: return [None] else: return self.encoder.getBucketIndices(scaledVal)
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/logarithm.py#L148-L159
[ "def", "getBucketIndices", "(", "self", ",", "inpt", ")", ":", "# Get the scaled value", "scaledVal", "=", "self", ".", "_getScaledValue", "(", "inpt", ")", "if", "scaledVal", "is", "None", ":", "return", "[", "None", "]", "else", ":", "return", "self", "....
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
LogEncoder.encodeIntoArray
See the function description in base.py
src/nupic/encoders/logarithm.py
def encodeIntoArray(self, inpt, output): """ See the function description in base.py """ # Get the scaled value scaledVal = self._getScaledValue(inpt) if scaledVal is None: output[0:] = 0 else: self.encoder.encodeIntoArray(scaledVal, output) if self.verbosity >= 2: ...
def encodeIntoArray(self, inpt, output): """ See the function description in base.py """ # Get the scaled value scaledVal = self._getScaledValue(inpt) if scaledVal is None: output[0:] = 0 else: self.encoder.encodeIntoArray(scaledVal, output) if self.verbosity >= 2: ...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/logarithm.py#L162-L177
[ "def", "encodeIntoArray", "(", "self", ",", "inpt", ",", "output", ")", ":", "# Get the scaled value", "scaledVal", "=", "self", ".", "_getScaledValue", "(", "inpt", ")", "if", "scaledVal", "is", "None", ":", "output", "[", "0", ":", "]", "=", "0", "else...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
LogEncoder.decode
See the function description in base.py
src/nupic/encoders/logarithm.py
def decode(self, encoded, parentFieldName=''): """ See the function description in base.py """ # Get the scalar values from the underlying scalar encoder (fieldsDict, fieldNames) = self.encoder.decode(encoded) if len(fieldsDict) == 0: return (fieldsDict, fieldNames) # Expect only 1 f...
def decode(self, encoded, parentFieldName=''): """ See the function description in base.py """ # Get the scalar values from the underlying scalar encoder (fieldsDict, fieldNames) = self.encoder.decode(encoded) if len(fieldsDict) == 0: return (fieldsDict, fieldNames) # Expect only 1 f...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/logarithm.py#L180-L216
[ "def", "decode", "(", "self", ",", "encoded", ",", "parentFieldName", "=", "''", ")", ":", "# Get the scalar values from the underlying scalar encoder", "(", "fieldsDict", ",", "fieldNames", ")", "=", "self", ".", "encoder", ".", "decode", "(", "encoded", ")", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
LogEncoder.getBucketValues
See the function description in base.py
src/nupic/encoders/logarithm.py
def getBucketValues(self): """ See the function description in base.py """ # Need to re-create? if self._bucketValues is None: scaledValues = self.encoder.getBucketValues() self._bucketValues = [] for scaledValue in scaledValues: value = math.pow(10, scaledValue) s...
def getBucketValues(self): """ See the function description in base.py """ # Need to re-create? if self._bucketValues is None: scaledValues = self.encoder.getBucketValues() self._bucketValues = [] for scaledValue in scaledValues: value = math.pow(10, scaledValue) s...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/logarithm.py#L219-L232
[ "def", "getBucketValues", "(", "self", ")", ":", "# Need to re-create?", "if", "self", ".", "_bucketValues", "is", "None", ":", "scaledValues", "=", "self", ".", "encoder", ".", "getBucketValues", "(", ")", "self", ".", "_bucketValues", "=", "[", "]", "for",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
LogEncoder.getBucketInfo
See the function description in base.py
src/nupic/encoders/logarithm.py
def getBucketInfo(self, buckets): """ See the function description in base.py """ scaledResult = self.encoder.getBucketInfo(buckets)[0] scaledValue = scaledResult.value value = math.pow(10, scaledValue) return [EncoderResult(value=value, scalar=value, encoding = sc...
def getBucketInfo(self, buckets): """ See the function description in base.py """ scaledResult = self.encoder.getBucketInfo(buckets)[0] scaledValue = scaledResult.value value = math.pow(10, scaledValue) return [EncoderResult(value=value, scalar=value, encoding = sc...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/logarithm.py#L235-L245
[ "def", "getBucketInfo", "(", "self", ",", "buckets", ")", ":", "scaledResult", "=", "self", ".", "encoder", ".", "getBucketInfo", "(", "buckets", ")", "[", "0", "]", "scaledValue", "=", "scaledResult", ".", "value", "value", "=", "math", ".", "pow", "(",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
LogEncoder.topDownCompute
See the function description in base.py
src/nupic/encoders/logarithm.py
def topDownCompute(self, encoded): """ See the function description in base.py """ scaledResult = self.encoder.topDownCompute(encoded)[0] scaledValue = scaledResult.value value = math.pow(10, scaledValue) return EncoderResult(value=value, scalar=value, encoding = s...
def topDownCompute(self, encoded): """ See the function description in base.py """ scaledResult = self.encoder.topDownCompute(encoded)[0] scaledValue = scaledResult.value value = math.pow(10, scaledValue) return EncoderResult(value=value, scalar=value, encoding = s...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/logarithm.py#L248-L258
[ "def", "topDownCompute", "(", "self", ",", "encoded", ")", ":", "scaledResult", "=", "self", ".", "encoder", ".", "topDownCompute", "(", "encoded", ")", "[", "0", "]", "scaledValue", "=", "scaledResult", ".", "value", "value", "=", "math", ".", "pow", "(...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
LogEncoder.closenessScores
See the function description in base.py
src/nupic/encoders/logarithm.py
def closenessScores(self, expValues, actValues, fractional=True): """ See the function description in base.py """ # Compute the percent error in log space if expValues[0] > 0: expValue = math.log10(expValues[0]) else: expValue = self.minScaledValue if actValues [0] > 0: ...
def closenessScores(self, expValues, actValues, fractional=True): """ See the function description in base.py """ # Compute the percent error in log space if expValues[0] > 0: expValue = math.log10(expValues[0]) else: expValue = self.minScaledValue if actValues [0] > 0: ...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/logarithm.py#L261-L289
[ "def", "closenessScores", "(", "self", ",", "expValues", ",", "actValues", ",", "fractional", "=", "True", ")", ":", "# Compute the percent error in log space", "if", "expValues", "[", "0", "]", ">", "0", ":", "expValue", "=", "math", ".", "log10", "(", "exp...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
NetworkVisualizer.export
Exports a network as a networkx MultiDiGraph intermediate representation suitable for visualization. :return: networkx MultiDiGraph
src/nupic/frameworks/viz/network_visualization.py
def export(self): """ Exports a network as a networkx MultiDiGraph intermediate representation suitable for visualization. :return: networkx MultiDiGraph """ graph = nx.MultiDiGraph() # Add regions to graph as nodes, annotated by name regions = self.network.getRegions() for idx in...
def export(self): """ Exports a network as a networkx MultiDiGraph intermediate representation suitable for visualization. :return: networkx MultiDiGraph """ graph = nx.MultiDiGraph() # Add regions to graph as nodes, annotated by name regions = self.network.getRegions() for idx in...
[ "Exports", "a", "network", "as", "a", "networkx", "MultiDiGraph", "intermediate", "representation", "suitable", "for", "visualization", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/viz/network_visualization.py#L53-L78
[ "def", "export", "(", "self", ")", ":", "graph", "=", "nx", ".", "MultiDiGraph", "(", ")", "# Add regions to graph as nodes, annotated by name", "regions", "=", "self", ".", "network", ".", "getRegions", "(", ")", "for", "idx", "in", "xrange", "(", "regions", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
bitsToString
Returns a string representing a numpy array of 0's and 1's
src/nupic/encoders/utils.py
def bitsToString(arr): """Returns a string representing a numpy array of 0's and 1's""" s = array('c','.'*len(arr)) for i in xrange(len(arr)): if arr[i] == 1: s[i]='*' return s
def bitsToString(arr): """Returns a string representing a numpy array of 0's and 1's""" s = array('c','.'*len(arr)) for i in xrange(len(arr)): if arr[i] == 1: s[i]='*' return s
[ "Returns", "a", "string", "representing", "a", "numpy", "array", "of", "0", "s", "and", "1", "s" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/utils.py#L26-L32
[ "def", "bitsToString", "(", "arr", ")", ":", "s", "=", "array", "(", "'c'", ",", "'.'", "*", "len", "(", "arr", ")", ")", "for", "i", "in", "xrange", "(", "len", "(", "arr", ")", ")", ":", "if", "arr", "[", "i", "]", "==", "1", ":", "s", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
percentOverlap
Computes the percentage of overlap between vectors x1 and x2. @param x1 (array) binary vector @param x2 (array) binary vector @param size (int) length of binary vectors @return percentOverlap (float) percentage overlap between x1 and x2
examples/sp/sp_tutorial.py
def percentOverlap(x1, x2, size): """ Computes the percentage of overlap between vectors x1 and x2. @param x1 (array) binary vector @param x2 (array) binary vector @param size (int) length of binary vectors @return percentOverlap (float) percentage overlap between x1 and x2 """ nonZeroX1 = np.co...
def percentOverlap(x1, x2, size): """ Computes the percentage of overlap between vectors x1 and x2. @param x1 (array) binary vector @param x2 (array) binary vector @param size (int) length of binary vectors @return percentOverlap (float) percentage overlap between x1 and x2 """ nonZeroX1 = np.co...
[ "Computes", "the", "percentage", "of", "overlap", "between", "vectors", "x1", "and", "x2", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/sp/sp_tutorial.py#L46-L62
[ "def", "percentOverlap", "(", "x1", ",", "x2", ",", "size", ")", ":", "nonZeroX1", "=", "np", ".", "count_nonzero", "(", "x1", ")", "nonZeroX2", "=", "np", ".", "count_nonzero", "(", "x2", ")", "minX1X2", "=", "min", "(", "nonZeroX1", ",", "nonZeroX2",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
resetVector
Copies the contents of vector x1 into vector x2. @param x1 (array) binary vector to be copied @param x2 (array) binary vector where x1 is copied
examples/sp/sp_tutorial.py
def resetVector(x1, x2): """ Copies the contents of vector x1 into vector x2. @param x1 (array) binary vector to be copied @param x2 (array) binary vector where x1 is copied """ size = len(x1) for i in range(size): x2[i] = x1[i]
def resetVector(x1, x2): """ Copies the contents of vector x1 into vector x2. @param x1 (array) binary vector to be copied @param x2 (array) binary vector where x1 is copied """ size = len(x1) for i in range(size): x2[i] = x1[i]
[ "Copies", "the", "contents", "of", "vector", "x1", "into", "vector", "x2", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/sp/sp_tutorial.py#L84-L93
[ "def", "resetVector", "(", "x1", ",", "x2", ")", ":", "size", "=", "len", "(", "x1", ")", "for", "i", "in", "range", "(", "size", ")", ":", "x2", "[", "i", "]", "=", "x1", "[", "i", "]" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
runCPU
Poll CPU usage, make predictions, and plot the results. Runs forever.
examples/opf/clients/cpu/cpu.py
def runCPU(): """Poll CPU usage, make predictions, and plot the results. Runs forever.""" # Create the model for predicting CPU usage. model = ModelFactory.create(model_params.MODEL_PARAMS) model.enableInference({'predictedField': 'cpu'}) # The shifter will align prediction and actual values. shifter = Infe...
def runCPU(): """Poll CPU usage, make predictions, and plot the results. Runs forever.""" # Create the model for predicting CPU usage. model = ModelFactory.create(model_params.MODEL_PARAMS) model.enableInference({'predictedField': 'cpu'}) # The shifter will align prediction and actual values. shifter = Infe...
[ "Poll", "CPU", "usage", "make", "predictions", "and", "plot", "the", "results", ".", "Runs", "forever", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/opf/clients/cpu/cpu.py#L46-L90
[ "def", "runCPU", "(", ")", ":", "# Create the model for predicting CPU usage.", "model", "=", "ModelFactory", ".", "create", "(", "model_params", ".", "MODEL_PARAMS", ")", "model", ".", "enableInference", "(", "{", "'predictedField'", ":", "'cpu'", "}", ")", "# Th...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_extractCallingMethodArgs
Returns args dictionary from the calling method
src/nupic/algorithms/backtracking_tm_cpp.py
def _extractCallingMethodArgs(): """ Returns args dictionary from the calling method """ import inspect import copy callingFrame = inspect.stack()[1][0] argNames, _, _, frameLocalVarDict = inspect.getargvalues(callingFrame) argNames.remove("self") args = copy.copy(frameLocalVarDict) for varNam...
def _extractCallingMethodArgs(): """ Returns args dictionary from the calling method """ import inspect import copy callingFrame = inspect.stack()[1][0] argNames, _, _, frameLocalVarDict = inspect.getargvalues(callingFrame) argNames.remove("self") args = copy.copy(frameLocalVarDict) for varNam...
[ "Returns", "args", "dictionary", "from", "the", "calling", "method" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L54-L74
[ "def", "_extractCallingMethodArgs", "(", ")", ":", "import", "inspect", "import", "copy", "callingFrame", "=", "inspect", ".", "stack", "(", ")", "[", "1", "]", "[", "0", "]", "argNames", ",", "_", ",", "_", ",", "frameLocalVarDict", "=", "inspect", ".",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP.write
Populate serialization proto instance. :param proto: (BacktrackingTMCppProto) the proto instance to populate
src/nupic/algorithms/backtracking_tm_cpp.py
def write(self, proto): """Populate serialization proto instance. :param proto: (BacktrackingTMCppProto) the proto instance to populate """ # Write base class to proto.baseTM (BacktrackingTMProto) super(BacktrackingTMCPP, self).write(proto.baseTM) self.cells4.write(proto.cells4) proto.makeC...
def write(self, proto): """Populate serialization proto instance. :param proto: (BacktrackingTMCppProto) the proto instance to populate """ # Write base class to proto.baseTM (BacktrackingTMProto) super(BacktrackingTMCPP, self).write(proto.baseTM) self.cells4.write(proto.cells4) proto.makeC...
[ "Populate", "serialization", "proto", "instance", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L173-L184
[ "def", "write", "(", "self", ",", "proto", ")", ":", "# Write base class to proto.baseTM (BacktrackingTMProto)", "super", "(", "BacktrackingTMCPP", ",", "self", ")", ".", "write", "(", "proto", ".", "baseTM", ")", "self", ".", "cells4", ".", "write", "(", "pro...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP.read
Deserialize from proto instance. :param proto: (BacktrackingTMCppProto) the proto instance to read from
src/nupic/algorithms/backtracking_tm_cpp.py
def read(cls, proto): """Deserialize from proto instance. :param proto: (BacktrackingTMCppProto) the proto instance to read from """ # Use base class to create initial class from proto.baseTM # (BacktrackingTMProto) obj = BacktrackingTM.read(proto.baseTM) obj.__class__ = cls # Addition...
def read(cls, proto): """Deserialize from proto instance. :param proto: (BacktrackingTMCppProto) the proto instance to read from """ # Use base class to create initial class from proto.baseTM # (BacktrackingTMProto) obj = BacktrackingTM.read(proto.baseTM) obj.__class__ = cls # Addition...
[ "Deserialize", "from", "proto", "instance", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L188-L214
[ "def", "read", "(", "cls", ",", "proto", ")", ":", "# Use base class to create initial class from proto.baseTM", "# (BacktrackingTMProto)", "obj", "=", "BacktrackingTM", ".", "read", "(", "proto", ".", "baseTM", ")", "obj", ".", "__class__", "=", "cls", "# Additiona...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP._getEphemeralMembers
List of our member variables that we don't need to be saved
src/nupic/algorithms/backtracking_tm_cpp.py
def _getEphemeralMembers(self): """ List of our member variables that we don't need to be saved """ e = BacktrackingTM._getEphemeralMembers(self) if self.makeCells4Ephemeral: e.extend(['cells4']) return e
def _getEphemeralMembers(self): """ List of our member variables that we don't need to be saved """ e = BacktrackingTM._getEphemeralMembers(self) if self.makeCells4Ephemeral: e.extend(['cells4']) return e
[ "List", "of", "our", "member", "variables", "that", "we", "don", "t", "need", "to", "be", "saved" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L256-L263
[ "def", "_getEphemeralMembers", "(", "self", ")", ":", "e", "=", "BacktrackingTM", ".", "_getEphemeralMembers", "(", "self", ")", "if", "self", ".", "makeCells4Ephemeral", ":", "e", ".", "extend", "(", "[", "'cells4'", "]", ")", "return", "e" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP._initEphemerals
Initialize all ephemeral members after being restored to a pickled state.
src/nupic/algorithms/backtracking_tm_cpp.py
def _initEphemerals(self): """ Initialize all ephemeral members after being restored to a pickled state. """ BacktrackingTM._initEphemerals(self) #--------------------------------------------------------------------------------- # cells4 specific initialization # If True, let C++ allocate m...
def _initEphemerals(self): """ Initialize all ephemeral members after being restored to a pickled state. """ BacktrackingTM._initEphemerals(self) #--------------------------------------------------------------------------------- # cells4 specific initialization # If True, let C++ allocate m...
[ "Initialize", "all", "ephemeral", "members", "after", "being", "restored", "to", "a", "pickled", "state", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L266-L284
[ "def", "_initEphemerals", "(", "self", ")", ":", "BacktrackingTM", ".", "_initEphemerals", "(", "self", ")", "#---------------------------------------------------------------------------------", "# cells4 specific initialization", "# If True, let C++ allocate memory for activeState, pred...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP.compute
Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.compute`.
src/nupic/algorithms/backtracking_tm_cpp.py
def compute(self, bottomUpInput, enableLearn, enableInference=None): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.compute`. """ # The C++ TM takes 32 bit floats as input. uint32 works as well since the # code only checks whether elements are non-zero assert (bottomUpInput...
def compute(self, bottomUpInput, enableLearn, enableInference=None): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.compute`. """ # The C++ TM takes 32 bit floats as input. uint32 works as well since the # code only checks whether elements are non-zero assert (bottomUpInput...
[ "Overrides", ":", "meth", ":", "nupic", ".", "algorithms", ".", "backtracking_tm", ".", "BacktrackingTM", ".", "compute", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L324-L376
[ "def", "compute", "(", "self", ",", "bottomUpInput", ",", "enableLearn", ",", "enableInference", "=", "None", ")", ":", "# The C++ TM takes 32 bit floats as input. uint32 works as well since the", "# code only checks whether elements are non-zero", "assert", "(", "bottomUpInput",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP._copyAllocatedStates
If state is allocated in CPP, copy over the data into our numpy arrays.
src/nupic/algorithms/backtracking_tm_cpp.py
def _copyAllocatedStates(self): """If state is allocated in CPP, copy over the data into our numpy arrays.""" # Get learn states if we need to print them out if self.verbosity > 1 or self.retrieveLearningStates: (activeT, activeT1, predT, predT1) = self.cells4.getLearnStates() self.lrnActiveSta...
def _copyAllocatedStates(self): """If state is allocated in CPP, copy over the data into our numpy arrays.""" # Get learn states if we need to print them out if self.verbosity > 1 or self.retrieveLearningStates: (activeT, activeT1, predT, predT1) = self.cells4.getLearnStates() self.lrnActiveSta...
[ "If", "state", "is", "allocated", "in", "CPP", "copy", "over", "the", "data", "into", "our", "numpy", "arrays", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L396-L418
[ "def", "_copyAllocatedStates", "(", "self", ")", ":", "# Get learn states if we need to print them out", "if", "self", ".", "verbosity", ">", "1", "or", "self", ".", "retrieveLearningStates", ":", "(", "activeT", ",", "activeT1", ",", "predT", ",", "predT1", ")", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP._setStatePointers
If we are having CPP use numpy-allocated buffers, set these buffer pointers. This is a relatively fast operation and, for safety, should be done before every call to the cells4 compute methods. This protects us in situations where code can cause Python or numpy to create copies.
src/nupic/algorithms/backtracking_tm_cpp.py
def _setStatePointers(self): """If we are having CPP use numpy-allocated buffers, set these buffer pointers. This is a relatively fast operation and, for safety, should be done before every call to the cells4 compute methods. This protects us in situations where code can cause Python or numpy to create...
def _setStatePointers(self): """If we are having CPP use numpy-allocated buffers, set these buffer pointers. This is a relatively fast operation and, for safety, should be done before every call to the cells4 compute methods. This protects us in situations where code can cause Python or numpy to create...
[ "If", "we", "are", "having", "CPP", "use", "numpy", "-", "allocated", "buffers", "set", "these", "buffer", "pointers", ".", "This", "is", "a", "relatively", "fast", "operation", "and", "for", "safety", "should", "be", "done", "before", "every", "call", "to...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L420-L430
[ "def", "_setStatePointers", "(", "self", ")", ":", "if", "not", "self", ".", "allocateStatesInCPP", ":", "self", ".", "cells4", ".", "setStatePointers", "(", "self", ".", "infActiveState", "[", "\"t\"", "]", ",", "self", ".", "infActiveState", "[", "\"t-1\""...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP.reset
Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.reset`.
src/nupic/algorithms/backtracking_tm_cpp.py
def reset(self): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.reset`. """ if self.verbosity >= 3: print "TM Reset" self._setStatePointers() self.cells4.reset() BacktrackingTM.reset(self)
def reset(self): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.reset`. """ if self.verbosity >= 3: print "TM Reset" self._setStatePointers() self.cells4.reset() BacktrackingTM.reset(self)
[ "Overrides", ":", "meth", ":", "nupic", ".", "algorithms", ".", "backtracking_tm", ".", "BacktrackingTM", ".", "reset", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L433-L441
[ "def", "reset", "(", "self", ")", ":", "if", "self", ".", "verbosity", ">=", "3", ":", "print", "\"TM Reset\"", "self", ".", "_setStatePointers", "(", ")", "self", ".", "cells4", ".", "reset", "(", ")", "BacktrackingTM", ".", "reset", "(", "self", ")" ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP.trimSegments
Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.trimSegments`.
src/nupic/algorithms/backtracking_tm_cpp.py
def trimSegments(self, minPermanence=None, minNumSyns=None): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.trimSegments`. """ # Fill in defaults if minPermanence is None: minPermanence = 0.0 if minNumSyns is None: minNumSyns = 0 # Print all cells if verbos...
def trimSegments(self, minPermanence=None, minNumSyns=None): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.trimSegments`. """ # Fill in defaults if minPermanence is None: minPermanence = 0.0 if minNumSyns is None: minNumSyns = 0 # Print all cells if verbos...
[ "Overrides", ":", "meth", ":", "nupic", ".", "algorithms", ".", "backtracking_tm", ".", "BacktrackingTM", ".", "trimSegments", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L454-L469
[ "def", "trimSegments", "(", "self", ",", "minPermanence", "=", "None", ",", "minNumSyns", "=", "None", ")", ":", "# Fill in defaults", "if", "minPermanence", "is", "None", ":", "minPermanence", "=", "0.0", "if", "minNumSyns", "is", "None", ":", "minNumSyns", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP.printSegmentUpdates
Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.printSegmentUpdates`.
src/nupic/algorithms/backtracking_tm_cpp.py
def printSegmentUpdates(self): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.printSegmentUpdates`. """ # TODO: need to add C++ accessors to implement this method assert False print "=== SEGMENT UPDATES ===, Num = ", len(self.segmentUpdates) for key, updateList in self....
def printSegmentUpdates(self): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.printSegmentUpdates`. """ # TODO: need to add C++ accessors to implement this method assert False print "=== SEGMENT UPDATES ===, Num = ", len(self.segmentUpdates) for key, updateList in self....
[ "Overrides", ":", "meth", ":", "nupic", ".", "algorithms", ".", "backtracking_tm", ".", "BacktrackingTM", ".", "printSegmentUpdates", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L538-L547
[ "def", "printSegmentUpdates", "(", "self", ")", ":", "# TODO: need to add C++ accessors to implement this method", "assert", "False", "print", "\"=== SEGMENT UPDATES ===, Num = \"", ",", "len", "(", "self", ".", "segmentUpdates", ")", "for", "key", ",", "updateList", "in"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP._slowIsSegmentActive
A segment is active if it has >= activationThreshold connected synapses that are active due to infActiveState.
src/nupic/algorithms/backtracking_tm_cpp.py
def _slowIsSegmentActive(self, seg, timeStep): """ A segment is active if it has >= activationThreshold connected synapses that are active due to infActiveState. """ numSyn = seg.size() numActiveSyns = 0 for synIdx in xrange(numSyn): if seg.getPermanence(synIdx) < self.connectedPerm:...
def _slowIsSegmentActive(self, seg, timeStep): """ A segment is active if it has >= activationThreshold connected synapses that are active due to infActiveState. """ numSyn = seg.size() numActiveSyns = 0 for synIdx in xrange(numSyn): if seg.getPermanence(synIdx) < self.connectedPerm:...
[ "A", "segment", "is", "active", "if", "it", "has", ">", "=", "activationThreshold", "connected", "synapses", "that", "are", "active", "due", "to", "infActiveState", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L550-L568
[ "def", "_slowIsSegmentActive", "(", "self", ",", "seg", ",", "timeStep", ")", ":", "numSyn", "=", "seg", ".", "size", "(", ")", "numActiveSyns", "=", "0", "for", "synIdx", "in", "xrange", "(", "numSyn", ")", ":", "if", "seg", ".", "getPermanence", "(",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP.printCell
Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.printCell`.
src/nupic/algorithms/backtracking_tm_cpp.py
def printCell(self, c, i, onlyActiveSegments=False): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.printCell`. """ nSegs = self.cells4.nSegmentsOnCell(c,i) if nSegs > 0: segList = self.cells4.getNonEmptySegList(c,i) gidx = c * self.cellsPerColumn + i print "C...
def printCell(self, c, i, onlyActiveSegments=False): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.printCell`. """ nSegs = self.cells4.nSegmentsOnCell(c,i) if nSegs > 0: segList = self.cells4.getNonEmptySegList(c,i) gidx = c * self.cellsPerColumn + i print "C...
[ "Overrides", ":", "meth", ":", "nupic", ".", "algorithms", ".", "backtracking_tm", ".", "BacktrackingTM", ".", "printCell", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L571-L602
[ "def", "printCell", "(", "self", ",", "c", ",", "i", ",", "onlyActiveSegments", "=", "False", ")", ":", "nSegs", "=", "self", ".", "cells4", ".", "nSegmentsOnCell", "(", "c", ",", "i", ")", "if", "nSegs", ">", "0", ":", "segList", "=", "self", ".",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP.getColCellIdx
Get column and cell within column from a global cell index. The global index is ``idx = colIdx * nCellsPerCol() + cellIdxInCol`` :param idx: (int) global cell index :returns: (tuple) (colIdx, cellIdxInCol)
src/nupic/algorithms/backtracking_tm_cpp.py
def getColCellIdx(self, idx): """ Get column and cell within column from a global cell index. The global index is ``idx = colIdx * nCellsPerCol() + cellIdxInCol`` :param idx: (int) global cell index :returns: (tuple) (colIdx, cellIdxInCol) """ c = idx//self.cellsPerColumn i = idx - ...
def getColCellIdx(self, idx): """ Get column and cell within column from a global cell index. The global index is ``idx = colIdx * nCellsPerCol() + cellIdxInCol`` :param idx: (int) global cell index :returns: (tuple) (colIdx, cellIdxInCol) """ c = idx//self.cellsPerColumn i = idx - ...
[ "Get", "column", "and", "cell", "within", "column", "from", "a", "global", "cell", "index", ".", "The", "global", "index", "is", "idx", "=", "colIdx", "*", "nCellsPerCol", "()", "+", "cellIdxInCol", ":", "param", "idx", ":", "(", "int", ")", "global", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L612-L622
[ "def", "getColCellIdx", "(", "self", ",", "idx", ")", ":", "c", "=", "idx", "//", "self", ".", "cellsPerColumn", "i", "=", "idx", "-", "c", "*", "self", ".", "cellsPerColumn", "return", "c", ",", "i" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP.getSegmentOnCell
Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.getSegmentOnCell`.
src/nupic/algorithms/backtracking_tm_cpp.py
def getSegmentOnCell(self, c, i, segIdx): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.getSegmentOnCell`. """ segList = self.cells4.getNonEmptySegList(c,i) seg = self.cells4.getSegment(c, i, segList[segIdx]) numSyn = seg.size() assert numSyn != 0 # Accumulate seg...
def getSegmentOnCell(self, c, i, segIdx): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.getSegmentOnCell`. """ segList = self.cells4.getNonEmptySegList(c,i) seg = self.cells4.getSegment(c, i, segList[segIdx]) numSyn = seg.size() assert numSyn != 0 # Accumulate seg...
[ "Overrides", ":", "meth", ":", "nupic", ".", "algorithms", ".", "backtracking_tm", ".", "BacktrackingTM", ".", "getSegmentOnCell", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L625-L646
[ "def", "getSegmentOnCell", "(", "self", ",", "c", ",", "i", ",", "segIdx", ")", ":", "segList", "=", "self", ".", "cells4", ".", "getNonEmptySegList", "(", "c", ",", "i", ")", "seg", "=", "self", ".", "cells4", ".", "getSegment", "(", "c", ",", "i"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTMCPP.getSegmentInfo
Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.getSegmentInfo`.
src/nupic/algorithms/backtracking_tm_cpp.py
def getSegmentInfo(self, collectActiveData = False): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.getSegmentInfo`. """ # Requires appropriate accessors in C++ cells4 (currently unimplemented) assert collectActiveData == False nSegments, nSynapses = self.getNumSegments(),...
def getSegmentInfo(self, collectActiveData = False): """ Overrides :meth:`nupic.algorithms.backtracking_tm.BacktrackingTM.getSegmentInfo`. """ # Requires appropriate accessors in C++ cells4 (currently unimplemented) assert collectActiveData == False nSegments, nSynapses = self.getNumSegments(),...
[ "Overrides", ":", "meth", ":", "nupic", ".", "algorithms", ".", "backtracking_tm", ".", "BacktrackingTM", ".", "getSegmentInfo", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm_cpp.py#L670-L726
[ "def", "getSegmentInfo", "(", "self", ",", "collectActiveData", "=", "False", ")", ":", "# Requires appropriate accessors in C++ cells4 (currently unimplemented)", "assert", "collectActiveData", "==", "False", "nSegments", ",", "nSynapses", "=", "self", ".", "getNumSegments...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
main
The main function of the HypersearchWorker script. This parses the command line arguments, instantiates a HypersearchWorker instance, and then runs it. Parameters: ---------------------------------------------------------------------- retval: jobID of the job we ran. This is used by unit test code ...
src/nupic/swarming/hypersearch_worker.py
def main(argv): """ The main function of the HypersearchWorker script. This parses the command line arguments, instantiates a HypersearchWorker instance, and then runs it. Parameters: ---------------------------------------------------------------------- retval: jobID of the job we ran. This is used ...
def main(argv): """ The main function of the HypersearchWorker script. This parses the command line arguments, instantiates a HypersearchWorker instance, and then runs it. Parameters: ---------------------------------------------------------------------- retval: jobID of the job we ran. This is used ...
[ "The", "main", "function", "of", "the", "HypersearchWorker", "script", ".", "This", "parses", "the", "command", "line", "arguments", "instantiates", "a", "HypersearchWorker", "instance", "and", "then", "runs", "it", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch_worker.py#L480-L591
[ "def", "main", "(", "argv", ")", ":", "parser", "=", "OptionParser", "(", "helpString", ")", "parser", ".", "add_option", "(", "\"--jobID\"", ",", "action", "=", "\"store\"", ",", "type", "=", "\"int\"", ",", "default", "=", "None", ",", "help", "=", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
HypersearchWorker._processUpdatedModels
For all models that modified their results since last time this method was called, send their latest results to the Hypersearch implementation.
src/nupic/swarming/hypersearch_worker.py
def _processUpdatedModels(self, cjDAO): """ For all models that modified their results since last time this method was called, send their latest results to the Hypersearch implementation. """ # Get the latest update counters. This returns a list of tuples: # (modelID, updateCounter) curModelI...
def _processUpdatedModels(self, cjDAO): """ For all models that modified their results since last time this method was called, send their latest results to the Hypersearch implementation. """ # Get the latest update counters. This returns a list of tuples: # (modelID, updateCounter) curModelI...
[ "For", "all", "models", "that", "modified", "their", "results", "since", "last", "time", "this", "method", "was", "called", "send", "their", "latest", "results", "to", "the", "Hypersearch", "implementation", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch_worker.py#L127-L231
[ "def", "_processUpdatedModels", "(", "self", ",", "cjDAO", ")", ":", "# Get the latest update counters. This returns a list of tuples:", "# (modelID, updateCounter)", "curModelIDCtrList", "=", "cjDAO", ".", "modelsGetUpdateCounters", "(", "self", ".", "_options", ".", "jobID...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
HypersearchWorker.run
Run this worker. Parameters: ---------------------------------------------------------------------- retval: jobID of the job we ran. This is used by unit test code when calling this working using the --params command line option (which tells this worker to insert the...
src/nupic/swarming/hypersearch_worker.py
def run(self): """ Run this worker. Parameters: ---------------------------------------------------------------------- retval: jobID of the job we ran. This is used by unit test code when calling this working using the --params command line option (which tells th...
def run(self): """ Run this worker. Parameters: ---------------------------------------------------------------------- retval: jobID of the job we ran. This is used by unit test code when calling this working using the --params command line option (which tells th...
[ "Run", "this", "worker", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch_worker.py#L234-L468
[ "def", "run", "(", "self", ")", ":", "# Easier access to options", "options", "=", "self", ".", "_options", "# ---------------------------------------------------------------------", "# Connect to the jobs database", "self", ".", "logger", ".", "info", "(", "\"Connecting to t...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RandomDistributedScalarEncoder.getBucketIndices
See method description in base.py
src/nupic/encoders/random_distributed_scalar.py
def getBucketIndices(self, x): """ See method description in base.py """ if ((isinstance(x, float) and math.isnan(x)) or x == SENTINEL_VALUE_FOR_MISSING_DATA): return [None] if self._offset is None: self._offset = x bucketIdx = ( (self._maxBuckets/2) + int(round((x - self....
def getBucketIndices(self, x): """ See method description in base.py """ if ((isinstance(x, float) and math.isnan(x)) or x == SENTINEL_VALUE_FOR_MISSING_DATA): return [None] if self._offset is None: self._offset = x bucketIdx = ( (self._maxBuckets/2) + int(round((x - self....
[ "See", "method", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/random_distributed_scalar.py#L200-L219
[ "def", "getBucketIndices", "(", "self", ",", "x", ")", ":", "if", "(", "(", "isinstance", "(", "x", ",", "float", ")", "and", "math", ".", "isnan", "(", "x", ")", ")", "or", "x", "==", "SENTINEL_VALUE_FOR_MISSING_DATA", ")", ":", "return", "[", "None...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RandomDistributedScalarEncoder.mapBucketIndexToNonZeroBits
Given a bucket index, return the list of non-zero bits. If the bucket index does not exist, it is created. If the index falls outside our range we clip it. :param index The bucket index to get non-zero bits for. @returns numpy array of indices of non-zero bits for specified index.
src/nupic/encoders/random_distributed_scalar.py
def mapBucketIndexToNonZeroBits(self, index): """ Given a bucket index, return the list of non-zero bits. If the bucket index does not exist, it is created. If the index falls outside our range we clip it. :param index The bucket index to get non-zero bits for. @returns numpy array of indices o...
def mapBucketIndexToNonZeroBits(self, index): """ Given a bucket index, return the list of non-zero bits. If the bucket index does not exist, it is created. If the index falls outside our range we clip it. :param index The bucket index to get non-zero bits for. @returns numpy array of indices o...
[ "Given", "a", "bucket", "index", "return", "the", "list", "of", "non", "-", "zero", "bits", ".", "If", "the", "bucket", "index", "does", "not", "exist", "it", "is", "created", ".", "If", "the", "index", "falls", "outside", "our", "range", "we", "clip",...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/random_distributed_scalar.py#L222-L241
[ "def", "mapBucketIndexToNonZeroBits", "(", "self", ",", "index", ")", ":", "if", "index", "<", "0", ":", "index", "=", "0", "if", "index", ">=", "self", ".", "_maxBuckets", ":", "index", "=", "self", ".", "_maxBuckets", "-", "1", "if", "not", "self", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RandomDistributedScalarEncoder.encodeIntoArray
See method description in base.py
src/nupic/encoders/random_distributed_scalar.py
def encodeIntoArray(self, x, output): """ See method description in base.py """ if x is not None and not isinstance(x, numbers.Number): raise TypeError( "Expected a scalar input but got input of type %s" % type(x)) # Get the bucket index to use bucketIdx = self.getBucketIndices(x)[0] ...
def encodeIntoArray(self, x, output): """ See method description in base.py """ if x is not None and not isinstance(x, numbers.Number): raise TypeError( "Expected a scalar input but got input of type %s" % type(x)) # Get the bucket index to use bucketIdx = self.getBucketIndices(x)[0] ...
[ "See", "method", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/random_distributed_scalar.py#L244-L257
[ "def", "encodeIntoArray", "(", "self", ",", "x", ",", "output", ")", ":", "if", "x", "is", "not", "None", "and", "not", "isinstance", "(", "x", ",", "numbers", ".", "Number", ")", ":", "raise", "TypeError", "(", "\"Expected a scalar input but got input of ty...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RandomDistributedScalarEncoder._createBucket
Create the given bucket index. Recursively create as many in-between bucket indices as necessary.
src/nupic/encoders/random_distributed_scalar.py
def _createBucket(self, index): """ Create the given bucket index. Recursively create as many in-between bucket indices as necessary. """ if index < self.minIndex: if index == self.minIndex - 1: # Create a new representation that has exactly w-1 overlapping bits # as the min re...
def _createBucket(self, index): """ Create the given bucket index. Recursively create as many in-between bucket indices as necessary. """ if index < self.minIndex: if index == self.minIndex - 1: # Create a new representation that has exactly w-1 overlapping bits # as the min re...
[ "Create", "the", "given", "bucket", "index", ".", "Recursively", "create", "as", "many", "in", "-", "between", "bucket", "indices", "as", "necessary", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/random_distributed_scalar.py#L260-L286
[ "def", "_createBucket", "(", "self", ",", "index", ")", ":", "if", "index", "<", "self", ".", "minIndex", ":", "if", "index", "==", "self", ".", "minIndex", "-", "1", ":", "# Create a new representation that has exactly w-1 overlapping bits", "# as the min represent...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RandomDistributedScalarEncoder._newRepresentation
Return a new representation for newIndex that overlaps with the representation at index by exactly w-1 bits
src/nupic/encoders/random_distributed_scalar.py
def _newRepresentation(self, index, newIndex): """ Return a new representation for newIndex that overlaps with the representation at index by exactly w-1 bits """ newRepresentation = self.bucketMap[index].copy() # Choose the bit we will replace in this representation. We need to shift # thi...
def _newRepresentation(self, index, newIndex): """ Return a new representation for newIndex that overlaps with the representation at index by exactly w-1 bits """ newRepresentation = self.bucketMap[index].copy() # Choose the bit we will replace in this representation. We need to shift # thi...
[ "Return", "a", "new", "representation", "for", "newIndex", "that", "overlaps", "with", "the", "representation", "at", "index", "by", "exactly", "w", "-", "1", "bits" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/random_distributed_scalar.py#L289-L311
[ "def", "_newRepresentation", "(", "self", ",", "index", ",", "newIndex", ")", ":", "newRepresentation", "=", "self", ".", "bucketMap", "[", "index", "]", ".", "copy", "(", ")", "# Choose the bit we will replace in this representation. We need to shift", "# this bit dete...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RandomDistributedScalarEncoder._newRepresentationOK
Return True if this new candidate representation satisfies all our overlap rules. Since we know that neighboring representations differ by at most one bit, we compute running overlaps.
src/nupic/encoders/random_distributed_scalar.py
def _newRepresentationOK(self, newRep, newIndex): """ Return True if this new candidate representation satisfies all our overlap rules. Since we know that neighboring representations differ by at most one bit, we compute running overlaps. """ if newRep.size != self.w: return False if (...
def _newRepresentationOK(self, newRep, newIndex): """ Return True if this new candidate representation satisfies all our overlap rules. Since we know that neighboring representations differ by at most one bit, we compute running overlaps. """ if newRep.size != self.w: return False if (...
[ "Return", "True", "if", "this", "new", "candidate", "representation", "satisfies", "all", "our", "overlap", "rules", ".", "Since", "we", "know", "that", "neighboring", "representations", "differ", "by", "at", "most", "one", "bit", "we", "compute", "running", "...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/random_distributed_scalar.py#L314-L368
[ "def", "_newRepresentationOK", "(", "self", ",", "newRep", ",", "newIndex", ")", ":", "if", "newRep", ".", "size", "!=", "self", ".", "w", ":", "return", "False", "if", "(", "newIndex", "<", "self", ".", "minIndex", "-", "1", ")", "or", "(", "newInde...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RandomDistributedScalarEncoder._countOverlapIndices
Return the overlap between bucket indices i and j
src/nupic/encoders/random_distributed_scalar.py
def _countOverlapIndices(self, i, j): """ Return the overlap between bucket indices i and j """ if self.bucketMap.has_key(i) and self.bucketMap.has_key(j): iRep = self.bucketMap[i] jRep = self.bucketMap[j] return self._countOverlap(iRep, jRep) else: raise ValueError("Either i...
def _countOverlapIndices(self, i, j): """ Return the overlap between bucket indices i and j """ if self.bucketMap.has_key(i) and self.bucketMap.has_key(j): iRep = self.bucketMap[i] jRep = self.bucketMap[j] return self._countOverlap(iRep, jRep) else: raise ValueError("Either i...
[ "Return", "the", "overlap", "between", "bucket", "indices", "i", "and", "j" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/random_distributed_scalar.py#L371-L380
[ "def", "_countOverlapIndices", "(", "self", ",", "i", ",", "j", ")", ":", "if", "self", ".", "bucketMap", ".", "has_key", "(", "i", ")", "and", "self", ".", "bucketMap", ".", "has_key", "(", "j", ")", ":", "iRep", "=", "self", ".", "bucketMap", "["...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RandomDistributedScalarEncoder._countOverlap
Return the overlap between two representations. rep1 and rep2 are lists of non-zero indices.
src/nupic/encoders/random_distributed_scalar.py
def _countOverlap(rep1, rep2): """ Return the overlap between two representations. rep1 and rep2 are lists of non-zero indices. """ overlap = 0 for e in rep1: if e in rep2: overlap += 1 return overlap
def _countOverlap(rep1, rep2): """ Return the overlap between two representations. rep1 and rep2 are lists of non-zero indices. """ overlap = 0 for e in rep1: if e in rep2: overlap += 1 return overlap
[ "Return", "the", "overlap", "between", "two", "representations", ".", "rep1", "and", "rep2", "are", "lists", "of", "non", "-", "zero", "indices", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/random_distributed_scalar.py#L384-L393
[ "def", "_countOverlap", "(", "rep1", ",", "rep2", ")", ":", "overlap", "=", "0", "for", "e", "in", "rep1", ":", "if", "e", "in", "rep2", ":", "overlap", "+=", "1", "return", "overlap" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RandomDistributedScalarEncoder._overlapOK
Return True if the given overlap between bucket indices i and j are acceptable. If overlap is not specified, calculate it from the bucketMap
src/nupic/encoders/random_distributed_scalar.py
def _overlapOK(self, i, j, overlap=None): """ Return True if the given overlap between bucket indices i and j are acceptable. If overlap is not specified, calculate it from the bucketMap """ if overlap is None: overlap = self._countOverlapIndices(i, j) if abs(i-j) < self.w: if overla...
def _overlapOK(self, i, j, overlap=None): """ Return True if the given overlap between bucket indices i and j are acceptable. If overlap is not specified, calculate it from the bucketMap """ if overlap is None: overlap = self._countOverlapIndices(i, j) if abs(i-j) < self.w: if overla...
[ "Return", "True", "if", "the", "given", "overlap", "between", "bucket", "indices", "i", "and", "j", "are", "acceptable", ".", "If", "overlap", "is", "not", "specified", "calculate", "it", "from", "the", "bucketMap" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/random_distributed_scalar.py#L396-L412
[ "def", "_overlapOK", "(", "self", ",", "i", ",", "j", ",", "overlap", "=", "None", ")", ":", "if", "overlap", "is", "None", ":", "overlap", "=", "self", ".", "_countOverlapIndices", "(", "i", ",", "j", ")", "if", "abs", "(", "i", "-", "j", ")", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RandomDistributedScalarEncoder._initializeBucketMap
Initialize the bucket map assuming the given number of maxBuckets.
src/nupic/encoders/random_distributed_scalar.py
def _initializeBucketMap(self, maxBuckets, offset): """ Initialize the bucket map assuming the given number of maxBuckets. """ # The first bucket index will be _maxBuckets / 2 and bucket indices will be # allowed to grow lower or higher as long as they don't become negative. # _maxBuckets is req...
def _initializeBucketMap(self, maxBuckets, offset): """ Initialize the bucket map assuming the given number of maxBuckets. """ # The first bucket index will be _maxBuckets / 2 and bucket indices will be # allowed to grow lower or higher as long as they don't become negative. # _maxBuckets is req...
[ "Initialize", "the", "bucket", "map", "assuming", "the", "given", "number", "of", "maxBuckets", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/random_distributed_scalar.py#L415-L447
[ "def", "_initializeBucketMap", "(", "self", ",", "maxBuckets", ",", "offset", ")", ":", "# The first bucket index will be _maxBuckets / 2 and bucket indices will be", "# allowed to grow lower or higher as long as they don't become negative.", "# _maxBuckets is required because the current SD...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
retrySQL
Return a closure suitable for use as a decorator for retrying a pymysql DAO function on certain failures that warrant retries ( e.g., RDS/MySQL server down temporarily, transaction deadlock, etc.). We share this function across multiple scripts (e.g., ClientJobsDAO, StreamMgr) for consitent behavior. .. note...
src/nupic/support/pymysql_helpers.py
def retrySQL(timeoutSec=60*5, logger=None): """ Return a closure suitable for use as a decorator for retrying a pymysql DAO function on certain failures that warrant retries ( e.g., RDS/MySQL server down temporarily, transaction deadlock, etc.). We share this function across multiple scripts (e.g., ClientJobsDA...
def retrySQL(timeoutSec=60*5, logger=None): """ Return a closure suitable for use as a decorator for retrying a pymysql DAO function on certain failures that warrant retries ( e.g., RDS/MySQL server down temporarily, transaction deadlock, etc.). We share this function across multiple scripts (e.g., ClientJobsDA...
[ "Return", "a", "closure", "suitable", "for", "use", "as", "a", "decorator", "for", "retrying", "a", "pymysql", "DAO", "function", "on", "certain", "failures", "that", "warrant", "retries", "(", "e", ".", "g", ".", "RDS", "/", "MySQL", "server", "down", "...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/pymysql_helpers.py#L95-L147
[ "def", "retrySQL", "(", "timeoutSec", "=", "60", "*", "5", ",", "logger", "=", "None", ")", ":", "if", "logger", "is", "None", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "def", "retryFilter", "(", "e", ",", "args", ",", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
SDRClassifierFactory.create
Create a SDR classifier factory. The implementation of the SDR Classifier can be specified with the "implementation" keyword argument. The SDRClassifierFactory uses the implementation as specified in `Default NuPIC Configuration <default-config.html>`_.
src/nupic/algorithms/sdr_classifier_factory.py
def create(*args, **kwargs): """ Create a SDR classifier factory. The implementation of the SDR Classifier can be specified with the "implementation" keyword argument. The SDRClassifierFactory uses the implementation as specified in `Default NuPIC Configuration <default-config.html>`_. """...
def create(*args, **kwargs): """ Create a SDR classifier factory. The implementation of the SDR Classifier can be specified with the "implementation" keyword argument. The SDRClassifierFactory uses the implementation as specified in `Default NuPIC Configuration <default-config.html>`_. """...
[ "Create", "a", "SDR", "classifier", "factory", ".", "The", "implementation", "of", "the", "SDR", "Classifier", "can", "be", "specified", "with", "the", "implementation", "keyword", "argument", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/sdr_classifier_factory.py#L36-L56
[ "def", "create", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "impl", "=", "kwargs", ".", "pop", "(", "'implementation'", ",", "None", ")", "if", "impl", "is", "None", ":", "impl", "=", "Configuration", ".", "get", "(", "'nupic.opf.sdrClassifie...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
SDRClassifierFactory.read
:param proto: SDRClassifierRegionProto capnproto object
src/nupic/algorithms/sdr_classifier_factory.py
def read(proto): """ :param proto: SDRClassifierRegionProto capnproto object """ impl = proto.implementation if impl == 'py': return SDRClassifier.read(proto.sdrClassifier) elif impl == 'cpp': return FastSDRClassifier.read(proto.sdrClassifier) elif impl == 'diff': return SD...
def read(proto): """ :param proto: SDRClassifierRegionProto capnproto object """ impl = proto.implementation if impl == 'py': return SDRClassifier.read(proto.sdrClassifier) elif impl == 'cpp': return FastSDRClassifier.read(proto.sdrClassifier) elif impl == 'diff': return SD...
[ ":", "param", "proto", ":", "SDRClassifierRegionProto", "capnproto", "object" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/sdr_classifier_factory.py#L60-L73
[ "def", "read", "(", "proto", ")", ":", "impl", "=", "proto", ".", "implementation", "if", "impl", "==", "'py'", ":", "return", "SDRClassifier", ".", "read", "(", "proto", ".", "sdrClassifier", ")", "elif", "impl", "==", "'cpp'", ":", "return", "FastSDRCl...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
cross_list
From: http://book.opensourceproject.org.cn/lamp/python/pythoncook2/opensource/0596007973/pythoncook2-chp-19-sect-9.html
src/nupic/math/cross.py
def cross_list(*sequences): """ From: http://book.opensourceproject.org.cn/lamp/python/pythoncook2/opensource/0596007973/pythoncook2-chp-19-sect-9.html """ result = [[ ]] for seq in sequences: result = [sublist+[item] for sublist in result for item in seq] return result
def cross_list(*sequences): """ From: http://book.opensourceproject.org.cn/lamp/python/pythoncook2/opensource/0596007973/pythoncook2-chp-19-sect-9.html """ result = [[ ]] for seq in sequences: result = [sublist+[item] for sublist in result for item in seq] return result
[ "From", ":", "http", ":", "//", "book", ".", "opensourceproject", ".", "org", ".", "cn", "/", "lamp", "/", "python", "/", "pythoncook2", "/", "opensource", "/", "0596007973", "/", "pythoncook2", "-", "chp", "-", "19", "-", "sect", "-", "9", ".", "htm...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/cross.py#L25-L32
[ "def", "cross_list", "(", "*", "sequences", ")", ":", "result", "=", "[", "[", "]", "]", "for", "seq", "in", "sequences", ":", "result", "=", "[", "sublist", "+", "[", "item", "]", "for", "sublist", "in", "result", "for", "item", "in", "seq", "]", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
cross
From: http://book.opensourceproject.org.cn/lamp/python/pythoncook2/opensource/0596007973/pythoncook2-chp-19-sect-9.html
src/nupic/math/cross.py
def cross(*sequences): """ From: http://book.opensourceproject.org.cn/lamp/python/pythoncook2/opensource/0596007973/pythoncook2-chp-19-sect-9.html """ # visualize an odometer, with "wheels" displaying "digits"...: wheels = map(iter, sequences) digits = [it.next( ) for it in wheels] while True: yield t...
def cross(*sequences): """ From: http://book.opensourceproject.org.cn/lamp/python/pythoncook2/opensource/0596007973/pythoncook2-chp-19-sect-9.html """ # visualize an odometer, with "wheels" displaying "digits"...: wheels = map(iter, sequences) digits = [it.next( ) for it in wheels] while True: yield t...
[ "From", ":", "http", ":", "//", "book", ".", "opensourceproject", ".", "org", ".", "cn", "/", "lamp", "/", "python", "/", "pythoncook2", "/", "opensource", "/", "0596007973", "/", "pythoncook2", "-", "chp", "-", "19", "-", "sect", "-", "9", ".", "htm...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/cross.py#L34-L51
[ "def", "cross", "(", "*", "sequences", ")", ":", "# visualize an odometer, with \"wheels\" displaying \"digits\"...:", "wheels", "=", "map", "(", "iter", ",", "sequences", ")", "digits", "=", "[", "it", ".", "next", "(", ")", "for", "it", "in", "wheels", "]", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
dcross
Similar to cross(), but generates output dictionaries instead of tuples.
src/nupic/math/cross.py
def dcross(**keywords): """ Similar to cross(), but generates output dictionaries instead of tuples. """ keys = keywords.keys() # Could use keywords.values(), but unsure whether the order # the values come out in is guaranteed to be the same as that of keys # (appears to be anecdotally true). sequences ...
def dcross(**keywords): """ Similar to cross(), but generates output dictionaries instead of tuples. """ keys = keywords.keys() # Could use keywords.values(), but unsure whether the order # the values come out in is guaranteed to be the same as that of keys # (appears to be anecdotally true). sequences ...
[ "Similar", "to", "cross", "()", "but", "generates", "output", "dictionaries", "instead", "of", "tuples", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/cross.py#L53-L75
[ "def", "dcross", "(", "*", "*", "keywords", ")", ":", "keys", "=", "keywords", ".", "keys", "(", ")", "# Could use keywords.values(), but unsure whether the order", "# the values come out in is guaranteed to be the same as that of keys", "# (appears to be anecdotally true).", "se...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
TemporalMemoryMonitorMixin.mmGetMetricFromTrace
Convenience method to compute a metric over an indices trace, excluding resets. @param (IndicesTrace) Trace of indices @return (Metric) Metric over trace excluding resets
src/nupic/algorithms/monitor_mixin/temporal_memory_monitor_mixin.py
def mmGetMetricFromTrace(self, trace): """ Convenience method to compute a metric over an indices trace, excluding resets. @param (IndicesTrace) Trace of indices @return (Metric) Metric over trace excluding resets """ return Metric.createFromTrace(trace.makeCountsTrace(), ...
def mmGetMetricFromTrace(self, trace): """ Convenience method to compute a metric over an indices trace, excluding resets. @param (IndicesTrace) Trace of indices @return (Metric) Metric over trace excluding resets """ return Metric.createFromTrace(trace.makeCountsTrace(), ...
[ "Convenience", "method", "to", "compute", "a", "metric", "over", "an", "indices", "trace", "excluding", "resets", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/monitor_mixin/temporal_memory_monitor_mixin.py#L131-L141
[ "def", "mmGetMetricFromTrace", "(", "self", ",", "trace", ")", ":", "return", "Metric", ".", "createFromTrace", "(", "trace", ".", "makeCountsTrace", "(", ")", ",", "excludeResets", "=", "self", ".", "mmGetTraceResets", "(", ")", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
TemporalMemoryMonitorMixin.mmGetMetricSequencesPredictedActiveCellsPerColumn
Metric for number of predicted => active cells per column for each sequence @return (Metric) metric
src/nupic/algorithms/monitor_mixin/temporal_memory_monitor_mixin.py
def mmGetMetricSequencesPredictedActiveCellsPerColumn(self): """ Metric for number of predicted => active cells per column for each sequence @return (Metric) metric """ self._mmComputeTransitionTraces() numCellsPerColumn = [] for predictedActiveCells in ( self._mmData["predictedAc...
def mmGetMetricSequencesPredictedActiveCellsPerColumn(self): """ Metric for number of predicted => active cells per column for each sequence @return (Metric) metric """ self._mmComputeTransitionTraces() numCellsPerColumn = [] for predictedActiveCells in ( self._mmData["predictedAc...
[ "Metric", "for", "number", "of", "predicted", "=", ">", "active", "cells", "per", "column", "for", "each", "sequence" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/monitor_mixin/temporal_memory_monitor_mixin.py#L144-L161
[ "def", "mmGetMetricSequencesPredictedActiveCellsPerColumn", "(", "self", ")", ":", "self", ".", "_mmComputeTransitionTraces", "(", ")", "numCellsPerColumn", "=", "[", "]", "for", "predictedActiveCells", "in", "(", "self", ".", "_mmData", "[", "\"predictedActiveCellsForS...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
TemporalMemoryMonitorMixin.mmGetMetricSequencesPredictedActiveCellsShared
Metric for number of sequences each predicted => active cell appears in Note: This metric is flawed when it comes to high-order sequences. @return (Metric) metric
src/nupic/algorithms/monitor_mixin/temporal_memory_monitor_mixin.py
def mmGetMetricSequencesPredictedActiveCellsShared(self): """ Metric for number of sequences each predicted => active cell appears in Note: This metric is flawed when it comes to high-order sequences. @return (Metric) metric """ self._mmComputeTransitionTraces() numSequencesForCell = defa...
def mmGetMetricSequencesPredictedActiveCellsShared(self): """ Metric for number of sequences each predicted => active cell appears in Note: This metric is flawed when it comes to high-order sequences. @return (Metric) metric """ self._mmComputeTransitionTraces() numSequencesForCell = defa...
[ "Metric", "for", "number", "of", "sequences", "each", "predicted", "=", ">", "active", "cell", "appears", "in" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/monitor_mixin/temporal_memory_monitor_mixin.py#L164-L183
[ "def", "mmGetMetricSequencesPredictedActiveCellsShared", "(", "self", ")", ":", "self", ".", "_mmComputeTransitionTraces", "(", ")", "numSequencesForCell", "=", "defaultdict", "(", "lambda", ":", "0", ")", "for", "predictedActiveCells", "in", "(", "self", ".", "_mmD...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
TemporalMemoryMonitorMixin.mmPrettyPrintConnections
Pretty print the connections in the temporal memory. TODO: Use PrettyTable. @return (string) Pretty-printed text
src/nupic/algorithms/monitor_mixin/temporal_memory_monitor_mixin.py
def mmPrettyPrintConnections(self): """ Pretty print the connections in the temporal memory. TODO: Use PrettyTable. @return (string) Pretty-printed text """ text = "" text += ("Segments: (format => " "(#) [(source cell=permanence ...), ...]\n") text += "------------...
def mmPrettyPrintConnections(self): """ Pretty print the connections in the temporal memory. TODO: Use PrettyTable. @return (string) Pretty-printed text """ text = "" text += ("Segments: (format => " "(#) [(source cell=permanence ...), ...]\n") text += "------------...
[ "Pretty", "print", "the", "connections", "in", "the", "temporal", "memory", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/monitor_mixin/temporal_memory_monitor_mixin.py#L186-L231
[ "def", "mmPrettyPrintConnections", "(", "self", ")", ":", "text", "=", "\"\"", "text", "+=", "(", "\"Segments: (format => \"", "\"(#) [(source cell=permanence ...), ...]\\n\"", ")", "text", "+=", "\"------------------------------------\\n\"", "columns", "=", "range", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
TemporalMemoryMonitorMixin.mmPrettyPrintSequenceCellRepresentations
Pretty print the cell representations for sequences in the history. @param sortby (string) Column of table to sort by @return (string) Pretty-printed text
src/nupic/algorithms/monitor_mixin/temporal_memory_monitor_mixin.py
def mmPrettyPrintSequenceCellRepresentations(self, sortby="Column"): """ Pretty print the cell representations for sequences in the history. @param sortby (string) Column of table to sort by @return (string) Pretty-printed text """ self._mmComputeTransitionTraces() table = PrettyTable(["Pa...
def mmPrettyPrintSequenceCellRepresentations(self, sortby="Column"): """ Pretty print the cell representations for sequences in the history. @param sortby (string) Column of table to sort by @return (string) Pretty-printed text """ self._mmComputeTransitionTraces() table = PrettyTable(["Pa...
[ "Pretty", "print", "the", "cell", "representations", "for", "sequences", "in", "the", "history", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/monitor_mixin/temporal_memory_monitor_mixin.py#L234-L251
[ "def", "mmPrettyPrintSequenceCellRepresentations", "(", "self", ",", "sortby", "=", "\"Column\"", ")", ":", "self", ".", "_mmComputeTransitionTraces", "(", ")", "table", "=", "PrettyTable", "(", "[", "\"Pattern\"", ",", "\"Column\"", ",", "\"predicted=>active cells\""...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
createTemporalAnomaly
Generates a Network with connected RecordSensor, SP, TM. This function takes care of generating regions and the canonical links. The network has a sensor region reading data from a specified input and passing the encoded representation to an SPRegion. The SPRegion output is passed to a TMRegion. Note: this ...
examples/network/temporal_anomaly_network_demo.py
def createTemporalAnomaly(recordParams, spatialParams=_SP_PARAMS, temporalParams=_TM_PARAMS, verbosity=_VERBOSITY): """Generates a Network with connected RecordSensor, SP, TM. This function takes care of generating regions and the canonical links. The network...
def createTemporalAnomaly(recordParams, spatialParams=_SP_PARAMS, temporalParams=_TM_PARAMS, verbosity=_VERBOSITY): """Generates a Network with connected RecordSensor, SP, TM. This function takes care of generating regions and the canonical links. The network...
[ "Generates", "a", "Network", "with", "connected", "RecordSensor", "SP", "TM", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/network/temporal_anomaly_network_demo.py#L79-L161
[ "def", "createTemporalAnomaly", "(", "recordParams", ",", "spatialParams", "=", "_SP_PARAMS", ",", "temporalParams", "=", "_TM_PARAMS", ",", "verbosity", "=", "_VERBOSITY", ")", ":", "inputFilePath", "=", "recordParams", "[", "\"inputFilePath\"", "]", "scalarEncoderAr...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
runNetwork
Run the network and write output to writer. :param network: a Network instance to run :param writer: a csv.writer instance to write output to
examples/network/temporal_anomaly_network_demo.py
def runNetwork(network, writer): """Run the network and write output to writer. :param network: a Network instance to run :param writer: a csv.writer instance to write output to """ sensorRegion = network.regions["sensor"] temporalPoolerRegion = network.regions["temporalPoolerRegion"] for i in xrange(_N...
def runNetwork(network, writer): """Run the network and write output to writer. :param network: a Network instance to run :param writer: a csv.writer instance to write output to """ sensorRegion = network.regions["sensor"] temporalPoolerRegion = network.regions["temporalPoolerRegion"] for i in xrange(_N...
[ "Run", "the", "network", "and", "write", "output", "to", "writer", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/network/temporal_anomaly_network_demo.py#L165-L182
[ "def", "runNetwork", "(", "network", ",", "writer", ")", ":", "sensorRegion", "=", "network", ".", "regions", "[", "\"sensor\"", "]", "temporalPoolerRegion", "=", "network", ".", "regions", "[", "\"temporalPoolerRegion\"", "]", "for", "i", "in", "xrange", "(",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
PeriodicActivityMgr.__appendActivities
periodicActivities: A sequence of PeriodicActivityRequest elements
src/nupic/frameworks/opf/periodic.py
def __appendActivities(self, periodicActivities): """ periodicActivities: A sequence of PeriodicActivityRequest elements """ for req in periodicActivities: act = self.Activity(repeating=req.repeating, period=req.period, cb=req.cb, ...
def __appendActivities(self, periodicActivities): """ periodicActivities: A sequence of PeriodicActivityRequest elements """ for req in periodicActivities: act = self.Activity(repeating=req.repeating, period=req.period, cb=req.cb, ...
[ "periodicActivities", ":", "A", "sequence", "of", "PeriodicActivityRequest", "elements" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/periodic.py#L96-L108
[ "def", "__appendActivities", "(", "self", ",", "periodicActivities", ")", ":", "for", "req", "in", "periodicActivities", ":", "act", "=", "self", ".", "Activity", "(", "repeating", "=", "req", ".", "repeating", ",", "period", "=", "req", ".", "period", ","...
5922fafffdccc8812e72b3324965ad2f7d4bbdad