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
add
Adds a value over a range of rows. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. column: The column of data to modify. start: The first row in the range to modify. end: The last row in the range to modify. value: The value ...
src/nupic/data/generators/anomalyzer.py
def add(reader, writer, column, start, stop, value): """Adds a value over a range of rows. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. column: The column of data to modify. start: The first row in the range to modify. end: ...
def add(reader, writer, column, start, stop, value): """Adds a value over a range of rows. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. column: The column of data to modify. start: The first row in the range to modify. end: ...
[ "Adds", "a", "value", "over", "a", "range", "of", "rows", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/anomalyzer.py#L66-L80
[ "def", "add", "(", "reader", ",", "writer", ",", "column", ",", "start", ",", "stop", ",", "value", ")", ":", "for", "i", ",", "row", "in", "enumerate", "(", "reader", ")", ":", "if", "i", ">=", "start", "and", "i", "<=", "stop", ":", "row", "[...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
scale
Multiplies a value over a range of rows. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. column: The column of data to modify. start: The first row in the range to modify. end: The last row in the range to modify. multiple: ...
src/nupic/data/generators/anomalyzer.py
def scale(reader, writer, column, start, stop, multiple): """Multiplies a value over a range of rows. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. column: The column of data to modify. start: The first row in the range to modif...
def scale(reader, writer, column, start, stop, multiple): """Multiplies a value over a range of rows. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. column: The column of data to modify. start: The first row in the range to modif...
[ "Multiplies", "a", "value", "over", "a", "range", "of", "rows", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/anomalyzer.py#L84-L98
[ "def", "scale", "(", "reader", ",", "writer", ",", "column", ",", "start", ",", "stop", ",", "multiple", ")", ":", "for", "i", ",", "row", "in", "enumerate", "(", "reader", ")", ":", "if", "i", ">=", "start", "and", "i", "<=", "stop", ":", "row",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
copy
Copies a range of values to a new location in the data set. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. start: The first row in the range to copy. stop: The last row in the range to copy. insertLocation: The location to inser...
src/nupic/data/generators/anomalyzer.py
def copy(reader, writer, start, stop, insertLocation=None, tsCol=None): """Copies a range of values to a new location in the data set. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. start: The first row in the range to copy. stop:...
def copy(reader, writer, start, stop, insertLocation=None, tsCol=None): """Copies a range of values to a new location in the data set. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. start: The first row in the range to copy. stop:...
[ "Copies", "a", "range", "of", "values", "to", "a", "new", "location", "in", "the", "data", "set", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/anomalyzer.py#L102-L138
[ "def", "copy", "(", "reader", ",", "writer", ",", "start", ",", "stop", ",", "insertLocation", "=", "None", ",", "tsCol", "=", "None", ")", ":", "assert", "stop", ">=", "start", "startRows", "=", "[", "]", "copyRows", "=", "[", "]", "ts", "=", "Non...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
sample
Samples n rows. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. n: The number of elements to sample. start: The first row in the range to sample from. stop: The last row in the range to sample from. tsCol: If specified, the t...
src/nupic/data/generators/anomalyzer.py
def sample(reader, writer, n, start=None, stop=None, tsCol=None, writeSampleOnly=True): """Samples n rows. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. n: The number of elements to sample. start: The first row in the ...
def sample(reader, writer, n, start=None, stop=None, tsCol=None, writeSampleOnly=True): """Samples n rows. Args: reader: A FileRecordStream object with input data. writer: A FileRecordStream object to write output data to. n: The number of elements to sample. start: The first row in the ...
[ "Samples", "n", "rows", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/anomalyzer.py#L142-L182
[ "def", "sample", "(", "reader", ",", "writer", ",", "n", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "tsCol", "=", "None", ",", "writeSampleOnly", "=", "True", ")", ":", "rows", "=", "list", "(", "reader", ")", "if", "tsCol", "is", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder._initEncoder
(helper function) There are three different ways of thinking about the representation. Handle each case here.
src/nupic/encoders/scalar.py
def _initEncoder(self, w, minval, maxval, n, radius, resolution): """ (helper function) There are three different ways of thinking about the representation. Handle each case here.""" if n != 0: if (radius !=0 or resolution != 0): raise ValueError("Only one of n/radius/resolution can be speci...
def _initEncoder(self, w, minval, maxval, n, radius, resolution): """ (helper function) There are three different ways of thinking about the representation. Handle each case here.""" if n != 0: if (radius !=0 or resolution != 0): raise ValueError("Only one of n/radius/resolution can be speci...
[ "(", "helper", "function", ")", "There", "are", "three", "different", "ways", "of", "thinking", "about", "the", "representation", ".", "Handle", "each", "case", "here", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L265-L306
[ "def", "_initEncoder", "(", "self", ",", "w", ",", "minval", ",", "maxval", ",", "n", ",", "radius", ",", "resolution", ")", ":", "if", "n", "!=", "0", ":", "if", "(", "radius", "!=", "0", "or", "resolution", "!=", "0", ")", ":", "raise", "ValueE...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder._getFirstOnBit
Return the bit offset of the first bit to be set in the encoder output. For periodic encoders, this can be a negative number when the encoded output wraps around.
src/nupic/encoders/scalar.py
def _getFirstOnBit(self, input): """ Return the bit offset of the first bit to be set in the encoder output. For periodic encoders, this can be a negative number when the encoded output wraps around. """ if input == SENTINEL_VALUE_FOR_MISSING_DATA: return [None] else: if input < self.m...
def _getFirstOnBit(self, input): """ Return the bit offset of the first bit to be set in the encoder output. For periodic encoders, this can be a negative number when the encoded output wraps around. """ if input == SENTINEL_VALUE_FOR_MISSING_DATA: return [None] else: if input < self.m...
[ "Return", "the", "bit", "offset", "of", "the", "first", "bit", "to", "be", "set", "in", "the", "encoder", "output", ".", "For", "periodic", "encoders", "this", "can", "be", "a", "negative", "number", "when", "the", "encoded", "output", "wraps", "around", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L348-L394
[ "def", "_getFirstOnBit", "(", "self", ",", "input", ")", ":", "if", "input", "==", "SENTINEL_VALUE_FOR_MISSING_DATA", ":", "return", "[", "None", "]", "else", ":", "if", "input", "<", "self", ".", "minval", ":", "# Don't clip periodic inputs. Out-of-range input is...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder.getBucketIndices
See method description in base.py
src/nupic/encoders/scalar.py
def getBucketIndices(self, input): """ See method description in base.py """ if type(input) is float and math.isnan(input): input = SENTINEL_VALUE_FOR_MISSING_DATA if input == SENTINEL_VALUE_FOR_MISSING_DATA: return [None] minbin = self._getFirstOnBit(input)[0] # For periodic encoder...
def getBucketIndices(self, input): """ See method description in base.py """ if type(input) is float and math.isnan(input): input = SENTINEL_VALUE_FOR_MISSING_DATA if input == SENTINEL_VALUE_FOR_MISSING_DATA: return [None] minbin = self._getFirstOnBit(input)[0] # For periodic encoder...
[ "See", "method", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L397-L418
[ "def", "getBucketIndices", "(", "self", ",", "input", ")", ":", "if", "type", "(", "input", ")", "is", "float", "and", "math", ".", "isnan", "(", "input", ")", ":", "input", "=", "SENTINEL_VALUE_FOR_MISSING_DATA", "if", "input", "==", "SENTINEL_VALUE_FOR_MIS...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder.encodeIntoArray
See method description in base.py
src/nupic/encoders/scalar.py
def encodeIntoArray(self, input, output, learn=True): """ See method description in base.py """ if input is not None and not isinstance(input, numbers.Number): raise TypeError( "Expected a scalar input but got input of type %s" % type(input)) if type(input) is float and math.isnan(input): ...
def encodeIntoArray(self, input, output, learn=True): """ See method description in base.py """ if input is not None and not isinstance(input, numbers.Number): raise TypeError( "Expected a scalar input but got input of type %s" % type(input)) if type(input) is float and math.isnan(input): ...
[ "See", "method", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L421-L468
[ "def", "encodeIntoArray", "(", "self", ",", "input", ",", "output", ",", "learn", "=", "True", ")", ":", "if", "input", "is", "not", "None", "and", "not", "isinstance", "(", "input", ",", "numbers", ".", "Number", ")", ":", "raise", "TypeError", "(", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder.decode
See the function description in base.py
src/nupic/encoders/scalar.py
def decode(self, encoded, parentFieldName=''): """ See the function description in base.py """ # For now, we simply assume any top-down output greater than 0 # is ON. Eventually, we will probably want to incorporate the strength # of each top-down output. tmpOutput = numpy.array(encoded[:self...
def decode(self, encoded, parentFieldName=''): """ See the function description in base.py """ # For now, we simply assume any top-down output greater than 0 # is ON. Eventually, we will probably want to incorporate the strength # of each top-down output. tmpOutput = numpy.array(encoded[:self...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L471-L588
[ "def", "decode", "(", "self", ",", "encoded", ",", "parentFieldName", "=", "''", ")", ":", "# For now, we simply assume any top-down output greater than 0", "# is ON. Eventually, we will probably want to incorporate the strength", "# of each top-down output.", "tmpOutput", "=", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder._generateRangeDescription
generate description from a text description of the ranges
src/nupic/encoders/scalar.py
def _generateRangeDescription(self, ranges): """generate description from a text description of the ranges""" desc = "" numRanges = len(ranges) for i in xrange(numRanges): if ranges[i][0] != ranges[i][1]: desc += "%.2f-%.2f" % (ranges[i][0], ranges[i][1]) else: desc += "%.2f"...
def _generateRangeDescription(self, ranges): """generate description from a text description of the ranges""" desc = "" numRanges = len(ranges) for i in xrange(numRanges): if ranges[i][0] != ranges[i][1]: desc += "%.2f-%.2f" % (ranges[i][0], ranges[i][1]) else: desc += "%.2f"...
[ "generate", "description", "from", "a", "text", "description", "of", "the", "ranges" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L591-L602
[ "def", "_generateRangeDescription", "(", "self", ",", "ranges", ")", ":", "desc", "=", "\"\"", "numRanges", "=", "len", "(", "ranges", ")", "for", "i", "in", "xrange", "(", "numRanges", ")", ":", "if", "ranges", "[", "i", "]", "[", "0", "]", "!=", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder._getTopDownMapping
Return the interal _topDownMappingM matrix used for handling the bucketInfo() and topDownCompute() methods. This is a matrix, one row per category (bucket) where each row contains the encoded output for that category.
src/nupic/encoders/scalar.py
def _getTopDownMapping(self): """ Return the interal _topDownMappingM matrix used for handling the bucketInfo() and topDownCompute() methods. This is a matrix, one row per category (bucket) where each row contains the encoded output for that category. """ # Do we need to build up our reverse ma...
def _getTopDownMapping(self): """ Return the interal _topDownMappingM matrix used for handling the bucketInfo() and topDownCompute() methods. This is a matrix, one row per category (bucket) where each row contains the encoded output for that category. """ # Do we need to build up our reverse ma...
[ "Return", "the", "interal", "_topDownMappingM", "matrix", "used", "for", "handling", "the", "bucketInfo", "()", "and", "topDownCompute", "()", "methods", ".", "This", "is", "a", "matrix", "one", "row", "per", "category", "(", "bucket", ")", "where", "each", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L605-L638
[ "def", "_getTopDownMapping", "(", "self", ")", ":", "# Do we need to build up our reverse mapping table?", "if", "self", ".", "_topDownMappingM", "is", "None", ":", "# The input scalar value corresponding to each possible output encoding", "if", "self", ".", "periodic", ":", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder.getBucketValues
See the function description in base.py
src/nupic/encoders/scalar.py
def getBucketValues(self): """ See the function description in base.py """ # Need to re-create? if self._bucketValues is None: topDownMappingM = self._getTopDownMapping() numBuckets = topDownMappingM.nRows() self._bucketValues = [] for bucketIdx in range(numBuckets): self._b...
def getBucketValues(self): """ See the function description in base.py """ # Need to re-create? if self._bucketValues is None: topDownMappingM = self._getTopDownMapping() numBuckets = topDownMappingM.nRows() self._bucketValues = [] for bucketIdx in range(numBuckets): self._b...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L641-L652
[ "def", "getBucketValues", "(", "self", ")", ":", "# Need to re-create?", "if", "self", ".", "_bucketValues", "is", "None", ":", "topDownMappingM", "=", "self", ".", "_getTopDownMapping", "(", ")", "numBuckets", "=", "topDownMappingM", ".", "nRows", "(", ")", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder.getBucketInfo
See the function description in base.py
src/nupic/encoders/scalar.py
def getBucketInfo(self, buckets): """ See the function description in base.py """ # Get/generate the topDown mapping table #NOTE: although variable topDownMappingM is unused, some (bad-style) actions #are executed during _getTopDownMapping() so this line must stay here topDownMappingM = self._getTo...
def getBucketInfo(self, buckets): """ See the function description in base.py """ # Get/generate the topDown mapping table #NOTE: although variable topDownMappingM is unused, some (bad-style) actions #are executed during _getTopDownMapping() so this line must stay here topDownMappingM = self._getTo...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L655-L674
[ "def", "getBucketInfo", "(", "self", ",", "buckets", ")", ":", "# Get/generate the topDown mapping table", "#NOTE: although variable topDownMappingM is unused, some (bad-style) actions", "#are executed during _getTopDownMapping() so this line must stay here", "topDownMappingM", "=", "self"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder.topDownCompute
See the function description in base.py
src/nupic/encoders/scalar.py
def topDownCompute(self, encoded): """ See the function description in base.py """ # Get/generate the topDown mapping table topDownMappingM = self._getTopDownMapping() # See which "category" we match the closest. category = topDownMappingM.rightVecProd(encoded).argmax() # Return that buck...
def topDownCompute(self, encoded): """ See the function description in base.py """ # Get/generate the topDown mapping table topDownMappingM = self._getTopDownMapping() # See which "category" we match the closest. category = topDownMappingM.rightVecProd(encoded).argmax() # Return that buck...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L677-L688
[ "def", "topDownCompute", "(", "self", ",", "encoded", ")", ":", "# Get/generate the topDown mapping table", "topDownMappingM", "=", "self", ".", "_getTopDownMapping", "(", ")", "# See which \"category\" we match the closest.", "category", "=", "topDownMappingM", ".", "right...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ScalarEncoder.closenessScores
See the function description in base.py
src/nupic/encoders/scalar.py
def closenessScores(self, expValues, actValues, fractional=True): """ See the function description in base.py """ expValue = expValues[0] actValue = actValues[0] if self.periodic: expValue = expValue % self.maxval actValue = actValue % self.maxval err = abs(expValue - actValue) ...
def closenessScores(self, expValues, actValues, fractional=True): """ See the function description in base.py """ expValue = expValues[0] actValue = actValues[0] if self.periodic: expValue = expValue % self.maxval actValue = actValue % self.maxval err = abs(expValue - actValue) ...
[ "See", "the", "function", "description", "in", "base", ".", "py" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L691-L711
[ "def", "closenessScores", "(", "self", ",", "expValues", ",", "actValues", ",", "fractional", "=", "True", ")", ":", "expValue", "=", "expValues", "[", "0", "]", "actValue", "=", "actValues", "[", "0", "]", "if", "self", ".", "periodic", ":", "expValue",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._initEphemerals
Initialize all ephemeral members after being restored to a pickled state.
src/nupic/algorithms/backtracking_tm.py
def _initEphemerals(self): """ Initialize all ephemeral members after being restored to a pickled state. """ ## We store the lists of segments updates, per cell, so that they can be # applied later during learning, when the cell gets bottom-up activation. # We store one list per cell. The lists ...
def _initEphemerals(self): """ Initialize all ephemeral members after being restored to a pickled state. """ ## We store the lists of segments updates, per cell, so that they can be # applied later during learning, when the cell gets bottom-up activation. # We store one list per cell. The lists ...
[ "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.py#L332-L390
[ "def", "_initEphemerals", "(", "self", ")", ":", "## We store the lists of segments updates, per cell, so that they can be", "# applied later during learning, when the cell gets bottom-up activation.", "# We store one list per cell. The lists are identified with a hash key which", "# is a tuple (c...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.write
Populate serialization proto instance. :param proto: (BacktrackingTMProto) the proto instance to populate
src/nupic/algorithms/backtracking_tm.py
def write(self, proto): """Populate serialization proto instance. :param proto: (BacktrackingTMProto) the proto instance to populate """ proto.version = TM_VERSION self._random.write(proto.random) proto.numberOfCols = self.numberOfCols proto.cellsPerColumn = self.cellsPerColumn proto.in...
def write(self, proto): """Populate serialization proto instance. :param proto: (BacktrackingTMProto) the proto instance to populate """ proto.version = TM_VERSION self._random.write(proto.random) proto.numberOfCols = self.numberOfCols proto.cellsPerColumn = self.cellsPerColumn proto.in...
[ "Populate", "serialization", "proto", "instance", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L428-L531
[ "def", "write", "(", "self", ",", "proto", ")", ":", "proto", ".", "version", "=", "TM_VERSION", "self", ".", "_random", ".", "write", "(", "proto", ".", "random", ")", "proto", ".", "numberOfCols", "=", "self", ".", "numberOfCols", "proto", ".", "cell...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.read
Deserialize from proto instance. :param proto: (BacktrackingTMProto) the proto instance to read from
src/nupic/algorithms/backtracking_tm.py
def read(cls, proto): """Deserialize from proto instance. :param proto: (BacktrackingTMProto) the proto instance to read from """ assert proto.version == TM_VERSION obj = object.__new__(cls) obj._random = Random() obj._random.read(proto.random) obj.numberOfCols = int(proto.numberOfCols)...
def read(cls, proto): """Deserialize from proto instance. :param proto: (BacktrackingTMProto) the proto instance to read from """ assert proto.version == TM_VERSION obj = object.__new__(cls) obj._random = Random() obj._random.read(proto.random) obj.numberOfCols = int(proto.numberOfCols)...
[ "Deserialize", "from", "proto", "instance", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L535-L655
[ "def", "read", "(", "cls", ",", "proto", ")", ":", "assert", "proto", ".", "version", "==", "TM_VERSION", "obj", "=", "object", ".", "__new__", "(", "cls", ")", "obj", ".", "_random", "=", "Random", "(", ")", "obj", ".", "_random", ".", "read", "("...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.reset
Reset the state of all cells. This is normally used between sequences while training. All internal states are reset to 0.
src/nupic/algorithms/backtracking_tm.py
def reset(self,): """ Reset the state of all cells. This is normally used between sequences while training. All internal states are reset to 0. """ if self.verbosity >= 3: print "\n==== RESET =====" self.lrnActiveState['t-1'].fill(0) self.lrnActiveState['t'].fill(0) self.lrnP...
def reset(self,): """ Reset the state of all cells. This is normally used between sequences while training. All internal states are reset to 0. """ if self.verbosity >= 3: print "\n==== RESET =====" self.lrnActiveState['t-1'].fill(0) self.lrnActiveState['t'].fill(0) self.lrnP...
[ "Reset", "the", "state", "of", "all", "cells", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L775-L828
[ "def", "reset", "(", "self", ",", ")", ":", "if", "self", ".", "verbosity", ">=", "3", ":", "print", "\"\\n==== RESET =====\"", "self", ".", "lrnActiveState", "[", "'t-1'", "]", ".", "fill", "(", "0", ")", "self", ".", "lrnActiveState", "[", "'t'", "]"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._updateStatsInferEnd
Called at the end of learning and inference, this routine will update a number of stats in our _internalStats dictionary, including our computed prediction score. :param stats internal stats dictionary :param bottomUpNZ list of the active bottom-up inputs :param predictedState Th...
src/nupic/algorithms/backtracking_tm.py
def _updateStatsInferEnd(self, stats, bottomUpNZ, predictedState, colConfidence): """ Called at the end of learning and inference, this routine will update a number of stats in our _internalStats dictionary, including our computed prediction score. :param stats ...
def _updateStatsInferEnd(self, stats, bottomUpNZ, predictedState, colConfidence): """ Called at the end of learning and inference, this routine will update a number of stats in our _internalStats dictionary, including our computed prediction score. :param stats ...
[ "Called", "at", "the", "end", "of", "learning", "and", "inference", "this", "routine", "will", "update", "a", "number", "of", "stats", "in", "our", "_internalStats", "dictionary", "including", "our", "computed", "prediction", "score", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L931-L996
[ "def", "_updateStatsInferEnd", "(", "self", ",", "stats", ",", "bottomUpNZ", ",", "predictedState", ",", "colConfidence", ")", ":", "# Return if not collecting stats", "if", "not", "self", ".", "collectStats", ":", "return", "stats", "[", "'nInfersSinceReset'", "]",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printState
Print an integer array that is the same shape as activeState. :param aState: TODO: document
src/nupic/algorithms/backtracking_tm.py
def printState(self, aState): """ Print an integer array that is the same shape as activeState. :param aState: TODO: document """ def formatRow(var, i): s = '' for c in range(self.numberOfCols): if c > 0 and c % 10 == 0: s += ' ' s += str(var[c, i]) s += ...
def printState(self, aState): """ Print an integer array that is the same shape as activeState. :param aState: TODO: document """ def formatRow(var, i): s = '' for c in range(self.numberOfCols): if c > 0 and c % 10 == 0: s += ' ' s += str(var[c, i]) s += ...
[ "Print", "an", "integer", "array", "that", "is", "the", "same", "shape", "as", "activeState", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L999-L1015
[ "def", "printState", "(", "self", ",", "aState", ")", ":", "def", "formatRow", "(", "var", ",", "i", ")", ":", "s", "=", "''", "for", "c", "in", "range", "(", "self", ".", "numberOfCols", ")", ":", "if", "c", ">", "0", "and", "c", "%", "10", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printConfidence
Print a floating point array that is the same shape as activeState. :param aState: TODO: document :param maxCols: TODO: document
src/nupic/algorithms/backtracking_tm.py
def printConfidence(self, aState, maxCols = 20): """ Print a floating point array that is the same shape as activeState. :param aState: TODO: document :param maxCols: TODO: document """ def formatFPRow(var, i): s = '' for c in range(min(maxCols, self.numberOfCols)): if c > 0...
def printConfidence(self, aState, maxCols = 20): """ Print a floating point array that is the same shape as activeState. :param aState: TODO: document :param maxCols: TODO: document """ def formatFPRow(var, i): s = '' for c in range(min(maxCols, self.numberOfCols)): if c > 0...
[ "Print", "a", "floating", "point", "array", "that", "is", "the", "same", "shape", "as", "activeState", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1018-L1035
[ "def", "printConfidence", "(", "self", ",", "aState", ",", "maxCols", "=", "20", ")", ":", "def", "formatFPRow", "(", "var", ",", "i", ")", ":", "s", "=", "''", "for", "c", "in", "range", "(", "min", "(", "maxCols", ",", "self", ".", "numberOfCols"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printColConfidence
Print up to maxCols number from a flat floating point array. :param aState: TODO: document :param maxCols: TODO: document
src/nupic/algorithms/backtracking_tm.py
def printColConfidence(self, aState, maxCols = 20): """ Print up to maxCols number from a flat floating point array. :param aState: TODO: document :param maxCols: TODO: document """ def formatFPRow(var): s = '' for c in range(min(maxCols, self.numberOfCols)): if c > 0 and c ...
def printColConfidence(self, aState, maxCols = 20): """ Print up to maxCols number from a flat floating point array. :param aState: TODO: document :param maxCols: TODO: document """ def formatFPRow(var): s = '' for c in range(min(maxCols, self.numberOfCols)): if c > 0 and c ...
[ "Print", "up", "to", "maxCols", "number", "from", "a", "flat", "floating", "point", "array", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1038-L1054
[ "def", "printColConfidence", "(", "self", ",", "aState", ",", "maxCols", "=", "20", ")", ":", "def", "formatFPRow", "(", "var", ")", ":", "s", "=", "''", "for", "c", "in", "range", "(", "min", "(", "maxCols", ",", "self", ".", "numberOfCols", ")", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printStates
TODO: document :param printPrevious: :param printLearnState: :return:
src/nupic/algorithms/backtracking_tm.py
def printStates(self, printPrevious = True, printLearnState = True): """ TODO: document :param printPrevious: :param printLearnState: :return: """ def formatRow(var, i): s = '' for c in range(self.numberOfCols): if c > 0 and c % 10 == 0: s += ' ' ...
def printStates(self, printPrevious = True, printLearnState = True): """ TODO: document :param printPrevious: :param printLearnState: :return: """ def formatRow(var, i): s = '' for c in range(self.numberOfCols): if c > 0 and c % 10 == 0: s += ' ' ...
[ "TODO", ":", "document", ":", "param", "printPrevious", ":", ":", "param", "printLearnState", ":", ":", "return", ":" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1056-L1096
[ "def", "printStates", "(", "self", ",", "printPrevious", "=", "True", ",", "printLearnState", "=", "True", ")", ":", "def", "formatRow", "(", "var", ",", "i", ")", ":", "s", "=", "''", "for", "c", "in", "range", "(", "self", ".", "numberOfCols", ")",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printOutput
TODO: document :param y: :return:
src/nupic/algorithms/backtracking_tm.py
def printOutput(self, y): """ TODO: document :param y: :return: """ print "Output" for i in xrange(self.cellsPerColumn): for c in xrange(self.numberOfCols): print int(y[c, i]), print
def printOutput(self, y): """ TODO: document :param y: :return: """ print "Output" for i in xrange(self.cellsPerColumn): for c in xrange(self.numberOfCols): print int(y[c, i]), print
[ "TODO", ":", "document", ":", "param", "y", ":", ":", "return", ":" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1099-L1110
[ "def", "printOutput", "(", "self", ",", "y", ")", ":", "print", "\"Output\"", "for", "i", "in", "xrange", "(", "self", ".", "cellsPerColumn", ")", ":", "for", "c", "in", "xrange", "(", "self", ".", "numberOfCols", ")", ":", "print", "int", "(", "y", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printInput
TODO: document :param x: :return:
src/nupic/algorithms/backtracking_tm.py
def printInput(self, x): """ TODO: document :param x: :return: """ print "Input" for c in xrange(self.numberOfCols): print int(x[c]), print
def printInput(self, x): """ TODO: document :param x: :return: """ print "Input" for c in xrange(self.numberOfCols): print int(x[c]), print
[ "TODO", ":", "document", ":", "param", "x", ":", ":", "return", ":" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1113-L1123
[ "def", "printInput", "(", "self", ",", "x", ")", ":", "print", "\"Input\"", "for", "c", "in", "xrange", "(", "self", ".", "numberOfCols", ")", ":", "print", "int", "(", "x", "[", "c", "]", ")", ",", "print" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printParameters
Print the parameter settings for the TM.
src/nupic/algorithms/backtracking_tm.py
def printParameters(self): """ Print the parameter settings for the TM. """ print "numberOfCols=", self.numberOfCols print "cellsPerColumn=", self.cellsPerColumn print "minThreshold=", self.minThreshold print "newSynapseCount=", self.newSynapseCount print "activationThreshold=", self.act...
def printParameters(self): """ Print the parameter settings for the TM. """ print "numberOfCols=", self.numberOfCols print "cellsPerColumn=", self.cellsPerColumn print "minThreshold=", self.minThreshold print "newSynapseCount=", self.newSynapseCount print "activationThreshold=", self.act...
[ "Print", "the", "parameter", "settings", "for", "the", "TM", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1126-L1145
[ "def", "printParameters", "(", "self", ")", ":", "print", "\"numberOfCols=\"", ",", "self", ".", "numberOfCols", "print", "\"cellsPerColumn=\"", ",", "self", ".", "cellsPerColumn", "print", "\"minThreshold=\"", ",", "self", ".", "minThreshold", "print", "\"newSynaps...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printActiveIndices
Print the list of ``[column, cellIdx]`` indices for each of the active cells in state. :param state: TODO: document :param andValues: TODO: document
src/nupic/algorithms/backtracking_tm.py
def printActiveIndices(self, state, andValues=False): """ Print the list of ``[column, cellIdx]`` indices for each of the active cells in state. :param state: TODO: document :param andValues: TODO: document """ if len(state.shape) == 2: (cols, cellIdxs) = state.nonzero() else: ...
def printActiveIndices(self, state, andValues=False): """ Print the list of ``[column, cellIdx]`` indices for each of the active cells in state. :param state: TODO: document :param andValues: TODO: document """ if len(state.shape) == 2: (cols, cellIdxs) = state.nonzero() else: ...
[ "Print", "the", "list", "of", "[", "column", "cellIdx", "]", "indices", "for", "each", "of", "the", "active", "cells", "in", "state", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1148-L1182
[ "def", "printActiveIndices", "(", "self", ",", "state", ",", "andValues", "=", "False", ")", ":", "if", "len", "(", "state", ".", "shape", ")", "==", "2", ":", "(", "cols", ",", "cellIdxs", ")", "=", "state", ".", "nonzero", "(", ")", "else", ":", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printComputeEnd
Called at the end of inference to print out various diagnostic information based on the current verbosity level. :param output: TODO: document :param learn: TODO: document
src/nupic/algorithms/backtracking_tm.py
def printComputeEnd(self, output, learn=False): """ Called at the end of inference to print out various diagnostic information based on the current verbosity level. :param output: TODO: document :param learn: TODO: document """ if self.verbosity >= 3: print "----- computeEnd summary: ...
def printComputeEnd(self, output, learn=False): """ Called at the end of inference to print out various diagnostic information based on the current verbosity level. :param output: TODO: document :param learn: TODO: document """ if self.verbosity >= 3: print "----- computeEnd summary: ...
[ "Called", "at", "the", "end", "of", "inference", "to", "print", "out", "various", "diagnostic", "information", "based", "on", "the", "current", "verbosity", "level", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1185-L1256
[ "def", "printComputeEnd", "(", "self", ",", "output", ",", "learn", "=", "False", ")", ":", "if", "self", ".", "verbosity", ">=", "3", ":", "print", "\"----- computeEnd summary: \"", "print", "\"learn:\"", ",", "learn", "print", "\"numBurstingCols: %s, \"", "%",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printCell
TODO: document :param c: :param i: :param onlyActiveSegments: :return:
src/nupic/algorithms/backtracking_tm.py
def printCell(self, c, i, onlyActiveSegments=False): """ TODO: document :param c: :param i: :param onlyActiveSegments: :return: """ if len(self.cells[c][i]) > 0: print "Column", c, "Cell", i, ":", print len(self.cells[c][i]), "segment(s)" for j, s in enumerate...
def printCell(self, c, i, onlyActiveSegments=False): """ TODO: document :param c: :param i: :param onlyActiveSegments: :return: """ if len(self.cells[c][i]) > 0: print "Column", c, "Cell", i, ":", print len(self.cells[c][i]), "segment(s)" for j, s in enumerate...
[ "TODO", ":", "document", ":", "param", "c", ":", ":", "param", "i", ":", ":", "param", "onlyActiveSegments", ":", ":", "return", ":" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1271-L1289
[ "def", "printCell", "(", "self", ",", "c", ",", "i", ",", "onlyActiveSegments", "=", "False", ")", ":", "if", "len", "(", "self", ".", "cells", "[", "c", "]", "[", "i", "]", ")", ">", "0", ":", "print", "\"Column\"", ",", "c", ",", "\"Cell\"", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.printCells
TODO: document :param predictedOnly: :return:
src/nupic/algorithms/backtracking_tm.py
def printCells(self, predictedOnly=False): """ TODO: document :param predictedOnly: :return: """ if predictedOnly: print "--- PREDICTED CELLS ---" else: print "--- ALL CELLS ---" print "Activation threshold=", self.activationThreshold, print "min threshold=", self....
def printCells(self, predictedOnly=False): """ TODO: document :param predictedOnly: :return: """ if predictedOnly: print "--- PREDICTED CELLS ---" else: print "--- ALL CELLS ---" print "Activation threshold=", self.activationThreshold, print "min threshold=", self....
[ "TODO", ":", "document", ":", "param", "predictedOnly", ":", ":", "return", ":" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1292-L1310
[ "def", "printCells", "(", "self", ",", "predictedOnly", "=", "False", ")", ":", "if", "predictedOnly", ":", "print", "\"--- PREDICTED CELLS ---\"", "else", ":", "print", "\"--- ALL CELLS ---\"", "print", "\"Activation threshold=\"", ",", "self", ".", "activationThresh...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.getSegmentOnCell
:param c: (int) column index :param i: (int) cell index in column :param segIdx: (int) segment index to match :returns: (list) representing the the segment on cell (c, i) with index ``segIdx``. :: [ [segmentID, sequenceSegmentFlag, positiveActivations, totalActiva...
src/nupic/algorithms/backtracking_tm.py
def getSegmentOnCell(self, c, i, segIdx): """ :param c: (int) column index :param i: (int) cell index in column :param segIdx: (int) segment index to match :returns: (list) representing the the segment on cell (c, i) with index ``segIdx``. :: [ [segmentID, sequenceSegme...
def getSegmentOnCell(self, c, i, segIdx): """ :param c: (int) column index :param i: (int) cell index in column :param segIdx: (int) segment index to match :returns: (list) representing the the segment on cell (c, i) with index ``segIdx``. :: [ [segmentID, sequenceSegme...
[ ":", "param", "c", ":", "(", "int", ")", "column", "index", ":", "param", "i", ":", "(", "int", ")", "cell", "index", "in", "column", ":", "param", "segIdx", ":", "(", "int", ")", "segment", "index", "to", "match" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1352-L1375
[ "def", "getSegmentOnCell", "(", "self", ",", "c", ",", "i", ",", "segIdx", ")", ":", "seg", "=", "self", ".", "cells", "[", "c", "]", "[", "i", "]", "[", "segIdx", "]", "retlist", "=", "[", "[", "seg", ".", "segID", ",", "seg", ".", "isSequence...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._addToSegmentUpdates
Store a dated potential segment update. The "date" (iteration index) is used later to determine whether the update is too old and should be forgotten. This is controlled by parameter ``segUpdateValidDuration``. :param c: TODO: document :param i: TODO: document :param segUpdate: TODO: document
src/nupic/algorithms/backtracking_tm.py
def _addToSegmentUpdates(self, c, i, segUpdate): """ Store a dated potential segment update. The "date" (iteration index) is used later to determine whether the update is too old and should be forgotten. This is controlled by parameter ``segUpdateValidDuration``. :param c: TODO: document :param...
def _addToSegmentUpdates(self, c, i, segUpdate): """ Store a dated potential segment update. The "date" (iteration index) is used later to determine whether the update is too old and should be forgotten. This is controlled by parameter ``segUpdateValidDuration``. :param c: TODO: document :param...
[ "Store", "a", "dated", "potential", "segment", "update", ".", "The", "date", "(", "iteration", "index", ")", "is", "used", "later", "to", "determine", "whether", "the", "update", "is", "too", "old", "and", "should", "be", "forgotten", ".", "This", "is", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1440-L1461
[ "def", "_addToSegmentUpdates", "(", "self", ",", "c", ",", "i", ",", "segUpdate", ")", ":", "# Sometimes we might be passed an empty update", "if", "segUpdate", "is", "None", "or", "len", "(", "segUpdate", ".", "activeSynapses", ")", "==", "0", ":", "return", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._computeOutput
Computes output for both learning and inference. In both cases, the output is the boolean OR of ``activeState`` and ``predictedState`` at ``t``. Stores ``currentOutput`` for ``checkPrediction``. :returns: TODO: document
src/nupic/algorithms/backtracking_tm.py
def _computeOutput(self): """ Computes output for both learning and inference. In both cases, the output is the boolean OR of ``activeState`` and ``predictedState`` at ``t``. Stores ``currentOutput`` for ``checkPrediction``. :returns: TODO: document """ # TODO: This operation can be spe...
def _computeOutput(self): """ Computes output for both learning and inference. In both cases, the output is the boolean OR of ``activeState`` and ``predictedState`` at ``t``. Stores ``currentOutput`` for ``checkPrediction``. :returns: TODO: document """ # TODO: This operation can be spe...
[ "Computes", "output", "for", "both", "learning", "and", "inference", ".", "In", "both", "cases", "the", "output", "is", "the", "boolean", "OR", "of", "activeState", "and", "predictedState", "at", "t", ".", "Stores", "currentOutput", "for", "checkPrediction", "...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1479-L1523
[ "def", "_computeOutput", "(", "self", ")", ":", "# TODO: This operation can be sped up by:", "# 1.) Pre-allocating space for the currentOutput", "# 2.) Making predictedState and activeState of type 'float32' up front", "# 3.) Using logical_or(self.predictedState['t'], self.activeState['t'],"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.predict
This function gives the future predictions for <nSteps> timesteps starting from the current TM state. The TM is returned to its original state at the end before returning. 1. We save the TM state. 2. Loop for nSteps a. Turn-on with lateral support from the current active cells b. Set the...
src/nupic/algorithms/backtracking_tm.py
def predict(self, nSteps): """ This function gives the future predictions for <nSteps> timesteps starting from the current TM state. The TM is returned to its original state at the end before returning. 1. We save the TM state. 2. Loop for nSteps a. Turn-on with lateral support from the...
def predict(self, nSteps): """ This function gives the future predictions for <nSteps> timesteps starting from the current TM state. The TM is returned to its original state at the end before returning. 1. We save the TM state. 2. Loop for nSteps a. Turn-on with lateral support from the...
[ "This", "function", "gives", "the", "future", "predictions", "for", "<nSteps", ">", "timesteps", "starting", "from", "the", "current", "TM", "state", ".", "The", "TM", "is", "returned", "to", "its", "original", "state", "at", "the", "end", "before", "returni...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1547-L1608
[ "def", "predict", "(", "self", ",", "nSteps", ")", ":", "# Save the TM dynamic state, we will use to revert back in the end", "pristineTPDynamicState", "=", "self", ".", "_getTPDynamicState", "(", ")", "assert", "(", "nSteps", ">", "0", ")", "# multiStepColumnPredictions ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._getTPDynamicState
Parameters: -------------------------------------------- retval: A dict with all the dynamic state variable names as keys and their values at this instant as values.
src/nupic/algorithms/backtracking_tm.py
def _getTPDynamicState(self,): """ Parameters: -------------------------------------------- retval: A dict with all the dynamic state variable names as keys and their values at this instant as values. """ tpDynamicState = dict() for variableName in self._getTPDynamicS...
def _getTPDynamicState(self,): """ Parameters: -------------------------------------------- retval: A dict with all the dynamic state variable names as keys and their values at this instant as values. """ tpDynamicState = dict() for variableName in self._getTPDynamicS...
[ "Parameters", ":", "--------------------------------------------", "retval", ":", "A", "dict", "with", "all", "the", "dynamic", "state", "variable", "names", "as", "keys", "and", "their", "values", "at", "this", "instant", "as", "values", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1628-L1638
[ "def", "_getTPDynamicState", "(", "self", ",", ")", ":", "tpDynamicState", "=", "dict", "(", ")", "for", "variableName", "in", "self", ".", "_getTPDynamicStateVariableNames", "(", ")", ":", "tpDynamicState", "[", "variableName", "]", "=", "copy", ".", "deepcop...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._setTPDynamicState
Set all the dynamic state variables from the <tpDynamicState> dict. <tpDynamicState> dict has all the dynamic state variable names as keys and their values at this instant as values. We set the dynamic state variables in the tm object with these items.
src/nupic/algorithms/backtracking_tm.py
def _setTPDynamicState(self, tpDynamicState): """ Set all the dynamic state variables from the <tpDynamicState> dict. <tpDynamicState> dict has all the dynamic state variable names as keys and their values at this instant as values. We set the dynamic state variables in the tm object with these it...
def _setTPDynamicState(self, tpDynamicState): """ Set all the dynamic state variables from the <tpDynamicState> dict. <tpDynamicState> dict has all the dynamic state variable names as keys and their values at this instant as values. We set the dynamic state variables in the tm object with these it...
[ "Set", "all", "the", "dynamic", "state", "variables", "from", "the", "<tpDynamicState", ">", "dict", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1641-L1651
[ "def", "_setTPDynamicState", "(", "self", ",", "tpDynamicState", ")", ":", "for", "variableName", "in", "self", ".", "_getTPDynamicStateVariableNames", "(", ")", ":", "self", ".", "__dict__", "[", "variableName", "]", "=", "tpDynamicState", ".", "pop", "(", "v...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._updateAvgLearnedSeqLength
Update our moving average of learned sequence length.
src/nupic/algorithms/backtracking_tm.py
def _updateAvgLearnedSeqLength(self, prevSeqLength): """Update our moving average of learned sequence length.""" if self.lrnIterationIdx < 100: alpha = 0.5 else: alpha = 0.1 self.avgLearnedSeqLength = ((1.0 - alpha) * self.avgLearnedSeqLength + (alpha * prevS...
def _updateAvgLearnedSeqLength(self, prevSeqLength): """Update our moving average of learned sequence length.""" if self.lrnIterationIdx < 100: alpha = 0.5 else: alpha = 0.1 self.avgLearnedSeqLength = ((1.0 - alpha) * self.avgLearnedSeqLength + (alpha * prevS...
[ "Update", "our", "moving", "average", "of", "learned", "sequence", "length", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1654-L1662
[ "def", "_updateAvgLearnedSeqLength", "(", "self", ",", "prevSeqLength", ")", ":", "if", "self", ".", "lrnIterationIdx", "<", "100", ":", "alpha", "=", "0.5", "else", ":", "alpha", "=", "0.1", "self", ".", "avgLearnedSeqLength", "=", "(", "(", "1.0", "-", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._inferBacktrack
This "backtracks" our inference state, trying to see if we can lock onto the current set of inputs by assuming the sequence started up to N steps ago on start cells. This will adjust @ref infActiveState['t'] if it does manage to lock on to a sequence that started earlier. It will also compute infPredic...
src/nupic/algorithms/backtracking_tm.py
def _inferBacktrack(self, activeColumns): """ This "backtracks" our inference state, trying to see if we can lock onto the current set of inputs by assuming the sequence started up to N steps ago on start cells. This will adjust @ref infActiveState['t'] if it does manage to lock on to a sequenc...
def _inferBacktrack(self, activeColumns): """ This "backtracks" our inference state, trying to see if we can lock onto the current set of inputs by assuming the sequence started up to N steps ago on start cells. This will adjust @ref infActiveState['t'] if it does manage to lock on to a sequenc...
[ "This", "backtracks", "our", "inference", "state", "trying", "to", "see", "if", "we", "can", "lock", "onto", "the", "current", "set", "of", "inputs", "by", "assuming", "the", "sequence", "started", "up", "to", "N", "steps", "ago", "on", "start", "cells", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1672-L1924
[ "def", "_inferBacktrack", "(", "self", ",", "activeColumns", ")", ":", "# How much input history have we accumulated?", "# The current input is always at the end of self._prevInfPatterns (at", "# index -1), but it is also evaluated as a potential starting point by", "# turning on it's start ce...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._inferPhase1
Update the inference active state from the last set of predictions and the current bottom-up. This looks at: - ``infPredictedState['t-1']`` This modifies: - ``infActiveState['t']`` :param activeColumns: (list) active bottom-ups :param useStartCells: (bool) If true, ignore previous ...
src/nupic/algorithms/backtracking_tm.py
def _inferPhase1(self, activeColumns, useStartCells): """ Update the inference active state from the last set of predictions and the current bottom-up. This looks at: - ``infPredictedState['t-1']`` This modifies: - ``infActiveState['t']`` :param activeColumns: (list) active bot...
def _inferPhase1(self, activeColumns, useStartCells): """ Update the inference active state from the last set of predictions and the current bottom-up. This looks at: - ``infPredictedState['t-1']`` This modifies: - ``infActiveState['t']`` :param activeColumns: (list) active bot...
[ "Update", "the", "inference", "active", "state", "from", "the", "last", "set", "of", "predictions", "and", "the", "current", "bottom", "-", "up", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1927-L1973
[ "def", "_inferPhase1", "(", "self", ",", "activeColumns", ",", "useStartCells", ")", ":", "# Init to zeros to start", "self", ".", "infActiveState", "[", "'t'", "]", ".", "fill", "(", "0", ")", "# Phase 1 - turn on predicted cells in each column receiving bottom-up", "#...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._inferPhase2
Phase 2 for the inference state. The computes the predicted state, then checks to insure that the predicted state is not over-saturated, i.e. look too close like a burst. This indicates that there were so many separate paths learned from the current input columns to the predicted input columns that burs...
src/nupic/algorithms/backtracking_tm.py
def _inferPhase2(self): """ Phase 2 for the inference state. The computes the predicted state, then checks to insure that the predicted state is not over-saturated, i.e. look too close like a burst. This indicates that there were so many separate paths learned from the current input columns to the p...
def _inferPhase2(self): """ Phase 2 for the inference state. The computes the predicted state, then checks to insure that the predicted state is not over-saturated, i.e. look too close like a burst. This indicates that there were so many separate paths learned from the current input columns to the p...
[ "Phase", "2", "for", "the", "inference", "state", ".", "The", "computes", "the", "predicted", "state", "then", "checks", "to", "insure", "that", "the", "predicted", "state", "is", "not", "over", "-", "saturated", "i", ".", "e", ".", "look", "too", "close...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L1976-L2044
[ "def", "_inferPhase2", "(", "self", ")", ":", "# Init to zeros to start", "self", ".", "infPredictedState", "[", "'t'", "]", ".", "fill", "(", "0", ")", "self", ".", "cellConfidence", "[", "'t'", "]", ".", "fill", "(", "0", ")", "self", ".", "colConfiden...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._updateInferenceState
Update the inference state. Called from :meth:`compute` on every iteration. :param activeColumns: (list) active column indices.
src/nupic/algorithms/backtracking_tm.py
def _updateInferenceState(self, activeColumns): """ Update the inference state. Called from :meth:`compute` on every iteration. :param activeColumns: (list) active column indices. """ # Copy t to t-1 self.infActiveState['t-1'][:, :] = self.infActiveState['t'][:, :] self.infPredictedState['t...
def _updateInferenceState(self, activeColumns): """ Update the inference state. Called from :meth:`compute` on every iteration. :param activeColumns: (list) active column indices. """ # Copy t to t-1 self.infActiveState['t-1'][:, :] = self.infActiveState['t'][:, :] self.infPredictedState['t...
[ "Update", "the", "inference", "state", ".", "Called", "from", ":", "meth", ":", "compute", "on", "every", "iteration", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2047-L2089
[ "def", "_updateInferenceState", "(", "self", ",", "activeColumns", ")", ":", "# Copy t to t-1", "self", ".", "infActiveState", "[", "'t-1'", "]", "[", ":", ",", ":", "]", "=", "self", ".", "infActiveState", "[", "'t'", "]", "[", ":", ",", ":", "]", "se...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._learnBacktrackFrom
A utility method called from learnBacktrack. This will backtrack starting from the given startOffset in our prevLrnPatterns queue. It returns True if the backtrack was successful and we managed to get predictions all the way up to the current time step. If readOnly, then no segments are updated or mod...
src/nupic/algorithms/backtracking_tm.py
def _learnBacktrackFrom(self, startOffset, readOnly=True): """ A utility method called from learnBacktrack. This will backtrack starting from the given startOffset in our prevLrnPatterns queue. It returns True if the backtrack was successful and we managed to get predictions all the way up to the c...
def _learnBacktrackFrom(self, startOffset, readOnly=True): """ A utility method called from learnBacktrack. This will backtrack starting from the given startOffset in our prevLrnPatterns queue. It returns True if the backtrack was successful and we managed to get predictions all the way up to the c...
[ "A", "utility", "method", "called", "from", "learnBacktrack", ".", "This", "will", "backtrack", "starting", "from", "the", "given", "startOffset", "in", "our", "prevLrnPatterns", "queue", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2092-L2188
[ "def", "_learnBacktrackFrom", "(", "self", ",", "startOffset", ",", "readOnly", "=", "True", ")", ":", "# How much input history have we accumulated?", "# The current input is always at the end of self._prevInfPatterns (at", "# index -1), but it is also evaluated as a potential starting ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._learnBacktrack
This "backtracks" our learning state, trying to see if we can lock onto the current set of inputs by assuming the sequence started up to N steps ago on start cells. This will adjust @ref lrnActiveState['t'] if it does manage to lock on to a sequence that started earlier. :returns: >0 if w...
src/nupic/algorithms/backtracking_tm.py
def _learnBacktrack(self): """ This "backtracks" our learning state, trying to see if we can lock onto the current set of inputs by assuming the sequence started up to N steps ago on start cells. This will adjust @ref lrnActiveState['t'] if it does manage to lock on to a sequence that started e...
def _learnBacktrack(self): """ This "backtracks" our learning state, trying to see if we can lock onto the current set of inputs by assuming the sequence started up to N steps ago on start cells. This will adjust @ref lrnActiveState['t'] if it does manage to lock on to a sequence that started e...
[ "This", "backtracks", "our", "learning", "state", "trying", "to", "see", "if", "we", "can", "lock", "onto", "the", "current", "set", "of", "inputs", "by", "assuming", "the", "sequence", "started", "up", "to", "N", "steps", "ago", "on", "start", "cells", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2190-L2298
[ "def", "_learnBacktrack", "(", "self", ")", ":", "# How much input history have we accumulated?", "# The current input is always at the end of self._prevInfPatterns (at", "# index -1), and is not a valid startingOffset to evaluate.", "numPrevPatterns", "=", "len", "(", "self", ".", "_p...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._learnPhase1
Compute the learning active state given the predicted state and the bottom-up input. :param activeColumns list of active bottom-ups :param readOnly True if being called from backtracking logic. This tells us not to increment any segment duty cycles or ...
src/nupic/algorithms/backtracking_tm.py
def _learnPhase1(self, activeColumns, readOnly=False): """ Compute the learning active state given the predicted state and the bottom-up input. :param activeColumns list of active bottom-ups :param readOnly True if being called from backtracking logic. This tells us no...
def _learnPhase1(self, activeColumns, readOnly=False): """ Compute the learning active state given the predicted state and the bottom-up input. :param activeColumns list of active bottom-ups :param readOnly True if being called from backtracking logic. This tells us no...
[ "Compute", "the", "learning", "active", "state", "given", "the", "predicted", "state", "and", "the", "bottom", "-", "up", "input", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2301-L2381
[ "def", "_learnPhase1", "(", "self", ",", "activeColumns", ",", "readOnly", "=", "False", ")", ":", "# Save previous active state and start out on a clean slate", "self", ".", "lrnActiveState", "[", "'t'", "]", ".", "fill", "(", "0", ")", "# For each column, turn on th...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._learnPhase2
Compute the predicted segments given the current set of active cells. :param readOnly True if being called from backtracking logic. This tells us not to increment any segment duty cycles or queue up any updates. This computes the lrnPredictedState['t']...
src/nupic/algorithms/backtracking_tm.py
def _learnPhase2(self, readOnly=False): """ Compute the predicted segments given the current set of active cells. :param readOnly True if being called from backtracking logic. This tells us not to increment any segment duty cycles or queue up any up...
def _learnPhase2(self, readOnly=False): """ Compute the predicted segments given the current set of active cells. :param readOnly True if being called from backtracking logic. This tells us not to increment any segment duty cycles or queue up any up...
[ "Compute", "the", "predicted", "segments", "given", "the", "current", "set", "of", "active", "cells", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2384-L2439
[ "def", "_learnPhase2", "(", "self", ",", "readOnly", "=", "False", ")", ":", "# Clear out predicted state to start with", "self", ".", "lrnPredictedState", "[", "'t'", "]", ".", "fill", "(", "0", ")", "# Compute new predicted state. When computing predictions for", "# p...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._updateLearningState
Update the learning state. Called from compute() on every iteration :param activeColumns List of active column indices
src/nupic/algorithms/backtracking_tm.py
def _updateLearningState(self, activeColumns): """ Update the learning state. Called from compute() on every iteration :param activeColumns List of active column indices """ # Copy predicted and active states into t-1 self.lrnPredictedState['t-1'][:, :] = self.lrnPredictedState['t'][:, :] se...
def _updateLearningState(self, activeColumns): """ Update the learning state. Called from compute() on every iteration :param activeColumns List of active column indices """ # Copy predicted and active states into t-1 self.lrnPredictedState['t-1'][:, :] = self.lrnPredictedState['t'][:, :] se...
[ "Update", "the", "learning", "state", ".", "Called", "from", "compute", "()", "on", "every", "iteration", ":", "param", "activeColumns", "List", "of", "active", "column", "indices" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2442-L2545
[ "def", "_updateLearningState", "(", "self", ",", "activeColumns", ")", ":", "# Copy predicted and active states into t-1", "self", ".", "lrnPredictedState", "[", "'t-1'", "]", "[", ":", ",", ":", "]", "=", "self", ".", "lrnPredictedState", "[", "'t'", "]", "[", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.compute
Handle one compute, possibly learning. .. note:: It is an error to have both ``enableLearn`` and ``enableInference`` set to False .. note:: By default, we don't compute the inference output when learning because it slows things down, but you can override this by passing ...
src/nupic/algorithms/backtracking_tm.py
def compute(self, bottomUpInput, enableLearn, enableInference=None): """ Handle one compute, possibly learning. .. note:: It is an error to have both ``enableLearn`` and ``enableInference`` set to False .. note:: By default, we don't compute the inference output when learning ...
def compute(self, bottomUpInput, enableLearn, enableInference=None): """ Handle one compute, possibly learning. .. note:: It is an error to have both ``enableLearn`` and ``enableInference`` set to False .. note:: By default, we don't compute the inference output when learning ...
[ "Handle", "one", "compute", "possibly", "learning", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2548-L2672
[ "def", "compute", "(", "self", ",", "bottomUpInput", ",", "enableLearn", ",", "enableInference", "=", "None", ")", ":", "# As a speed optimization for now (until we need online learning), skip", "# computing the inference output while learning", "if", "enableInference", "is", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.learn
TODO: document :param bottomUpInput: :param enableInference: :return:
src/nupic/algorithms/backtracking_tm.py
def learn(self, bottomUpInput, enableInference=None): """ TODO: document :param bottomUpInput: :param enableInference: :return: """ return self.compute(bottomUpInput, enableLearn=True, enableInference=enableInference)
def learn(self, bottomUpInput, enableInference=None): """ TODO: document :param bottomUpInput: :param enableInference: :return: """ return self.compute(bottomUpInput, enableLearn=True, enableInference=enableInference)
[ "TODO", ":", "document" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2685-L2694
[ "def", "learn", "(", "self", ",", "bottomUpInput", ",", "enableInference", "=", "None", ")", ":", "return", "self", ".", "compute", "(", "bottomUpInput", ",", "enableLearn", "=", "True", ",", "enableInference", "=", "enableInference", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._trimSegmentsInCell
This method goes through a list of segments for a given cell and deletes all synapses whose permanence is less than minPermanence and deletes any segments that have less than minNumSyns synapses remaining. :param colIdx Column index :param cellIdx Cell index within the column :param se...
src/nupic/algorithms/backtracking_tm.py
def _trimSegmentsInCell(self, colIdx, cellIdx, segList, minPermanence, minNumSyns): """ This method goes through a list of segments for a given cell and deletes all synapses whose permanence is less than minPermanence and deletes any segments that have less than minNumSyns syna...
def _trimSegmentsInCell(self, colIdx, cellIdx, segList, minPermanence, minNumSyns): """ This method goes through a list of segments for a given cell and deletes all synapses whose permanence is less than minPermanence and deletes any segments that have less than minNumSyns syna...
[ "This", "method", "goes", "through", "a", "list", "of", "segments", "for", "a", "given", "cell", "and", "deletes", "all", "synapses", "whose", "permanence", "is", "less", "than", "minPermanence", "and", "deletes", "any", "segments", "that", "have", "less", "...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2719-L2768
[ "def", "_trimSegmentsInCell", "(", "self", ",", "colIdx", ",", "cellIdx", ",", "segList", ",", "minPermanence", ",", "minNumSyns", ")", ":", "# Fill in defaults", "if", "minPermanence", "is", "None", ":", "minPermanence", "=", "self", ".", "connectedPerm", "if",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.trimSegments
This method deletes all synapses whose permanence is less than minPermanence and deletes any segments that have less than minNumSyns synapses remaining. :param minPermanence: (float) Any syn whose permanence is 0 or < ``minPermanence`` will be deleted. If None is passed in, then ``...
src/nupic/algorithms/backtracking_tm.py
def trimSegments(self, minPermanence=None, minNumSyns=None): """ This method deletes all synapses whose permanence is less than minPermanence and deletes any segments that have less than minNumSyns synapses remaining. :param minPermanence: (float) Any syn whose permanence is 0 or < ``mi...
def trimSegments(self, minPermanence=None, minNumSyns=None): """ This method deletes all synapses whose permanence is less than minPermanence and deletes any segments that have less than minNumSyns synapses remaining. :param minPermanence: (float) Any syn whose permanence is 0 or < ``mi...
[ "This", "method", "deletes", "all", "synapses", "whose", "permanence", "is", "less", "than", "minPermanence", "and", "deletes", "any", "segments", "that", "have", "less", "than", "minNumSyns", "synapses", "remaining", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2771-L2807
[ "def", "trimSegments", "(", "self", ",", "minPermanence", "=", "None", ",", "minNumSyns", "=", "None", ")", ":", "# Fill in defaults", "if", "minPermanence", "is", "None", ":", "minPermanence", "=", "self", ".", "connectedPerm", "if", "minNumSyns", "is", "None...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._cleanUpdatesList
Removes any update that would be for the given col, cellIdx, segIdx. NOTE: logically, we need to do this when we delete segments, so that if an update refers to a segment that was just deleted, we also remove that update from the update list. However, I haven't seen it trigger in any of the unit tests ...
src/nupic/algorithms/backtracking_tm.py
def _cleanUpdatesList(self, col, cellIdx, seg): """ Removes any update that would be for the given col, cellIdx, segIdx. NOTE: logically, we need to do this when we delete segments, so that if an update refers to a segment that was just deleted, we also remove that update from the update list. Howe...
def _cleanUpdatesList(self, col, cellIdx, seg): """ Removes any update that would be for the given col, cellIdx, segIdx. NOTE: logically, we need to do this when we delete segments, so that if an update refers to a segment that was just deleted, we also remove that update from the update list. Howe...
[ "Removes", "any", "update", "that", "would", "be", "for", "the", "given", "col", "cellIdx", "segIdx", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2810-L2827
[ "def", "_cleanUpdatesList", "(", "self", ",", "col", ",", "cellIdx", ",", "seg", ")", ":", "# TODO: check if the situation described in the docstring above actually", "# occurs.", "for", "key", ",", "updateList", "in", "self", ".", "segmentUpdates", ".", "iteritem...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM.finishLearning
Called when learning has been completed. This method just calls :meth:`trimSegments` and then clears out caches.
src/nupic/algorithms/backtracking_tm.py
def finishLearning(self): """ Called when learning has been completed. This method just calls :meth:`trimSegments` and then clears out caches. """ # Keep weakly formed synapses around because they contain confidence scores # for paths out of learned sequenced and produce a better prediction than...
def finishLearning(self): """ Called when learning has been completed. This method just calls :meth:`trimSegments` and then clears out caches. """ # Keep weakly formed synapses around because they contain confidence scores # for paths out of learned sequenced and produce a better prediction than...
[ "Called", "when", "learning", "has", "been", "completed", ".", "This", "method", "just", "calls", ":", "meth", ":", "trimSegments", "and", "then", "clears", "out", "caches", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L2830-L2851
[ "def", "finishLearning", "(", "self", ")", ":", "# Keep weakly formed synapses around because they contain confidence scores", "# for paths out of learned sequenced and produce a better prediction than", "# chance.", "self", ".", "trimSegments", "(", "minPermanence", "=", "0.0001", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._getBestMatchingCell
Find weakly activated cell in column with at least minThreshold active synapses. :param c which column to look at :param activeState the active cells :param minThreshold minimum number of synapses required :returns: tuple (cellIdx, segment, numActiveSynapses)
src/nupic/algorithms/backtracking_tm.py
def _getBestMatchingCell(self, c, activeState, minThreshold): """ Find weakly activated cell in column with at least minThreshold active synapses. :param c which column to look at :param activeState the active cells :param minThreshold minimum number of synapses required :retur...
def _getBestMatchingCell(self, c, activeState, minThreshold): """ Find weakly activated cell in column with at least minThreshold active synapses. :param c which column to look at :param activeState the active cells :param minThreshold minimum number of synapses required :retur...
[ "Find", "weakly", "activated", "cell", "in", "column", "with", "at", "least", "minThreshold", "active", "synapses", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L3009-L3048
[ "def", "_getBestMatchingCell", "(", "self", ",", "c", ",", "activeState", ",", "minThreshold", ")", ":", "# Collect all cells in column c that have at least minThreshold in the most", "# activated segment", "bestActivityInCol", "=", "minThreshold", "bestSegIdxInCol", "=", "-", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._getBestMatchingSegment
For the given cell, find the segment with the largest number of active synapses. This routine is aggressive in finding the best match. The permanence value of synapses is allowed to be below connectedPerm. The number of active synapses is allowed to be below activationThreshold, but must be above minThr...
src/nupic/algorithms/backtracking_tm.py
def _getBestMatchingSegment(self, c, i, activeState): """ For the given cell, find the segment with the largest number of active synapses. This routine is aggressive in finding the best match. The permanence value of synapses is allowed to be below connectedPerm. The number of active synapses is all...
def _getBestMatchingSegment(self, c, i, activeState): """ For the given cell, find the segment with the largest number of active synapses. This routine is aggressive in finding the best match. The permanence value of synapses is allowed to be below connectedPerm. The number of active synapses is all...
[ "For", "the", "given", "cell", "find", "the", "segment", "with", "the", "largest", "number", "of", "active", "synapses", ".", "This", "routine", "is", "aggressive", "in", "finding", "the", "best", "match", ".", "The", "permanence", "value", "of", "synapses",...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L3051-L3076
[ "def", "_getBestMatchingSegment", "(", "self", ",", "c", ",", "i", ",", "activeState", ")", ":", "maxActivity", ",", "which", "=", "self", ".", "minThreshold", ",", "-", "1", "for", "j", ",", "s", "in", "enumerate", "(", "self", ".", "cells", "[", "c...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._getCellForNewSegment
Return the index of a cell in this column which is a good candidate for adding a new segment. When we have fixed size resources in effect, we insure that we pick a cell which does not already have the max number of allowed segments. If none exists, we choose the least used segment in the column to re-a...
src/nupic/algorithms/backtracking_tm.py
def _getCellForNewSegment(self, colIdx): """ Return the index of a cell in this column which is a good candidate for adding a new segment. When we have fixed size resources in effect, we insure that we pick a cell which does not already have the max number of allowed segments. If none exists, w...
def _getCellForNewSegment(self, colIdx): """ Return the index of a cell in this column which is a good candidate for adding a new segment. When we have fixed size resources in effect, we insure that we pick a cell which does not already have the max number of allowed segments. If none exists, w...
[ "Return", "the", "index", "of", "a", "cell", "in", "this", "column", "which", "is", "a", "good", "candidate", "for", "adding", "a", "new", "segment", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L3079-L3151
[ "def", "_getCellForNewSegment", "(", "self", ",", "colIdx", ")", ":", "# Not fixed size CLA, just choose a cell randomly", "if", "self", ".", "maxSegmentsPerCell", "<", "0", ":", "if", "self", ".", "cellsPerColumn", ">", "1", ":", "# Don't ever choose the start cell (ce...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._getSegmentActiveSynapses
Return a segmentUpdate data structure containing a list of proposed changes to segment s. Let activeSynapses be the list of active synapses where the originating cells have their activeState output = 1 at time step t. (This list is empty if s is None since the segment doesn't exist.) newSynapses is an o...
src/nupic/algorithms/backtracking_tm.py
def _getSegmentActiveSynapses(self, c, i, s, activeState, newSynapses=False): """ Return a segmentUpdate data structure containing a list of proposed changes to segment s. Let activeSynapses be the list of active synapses where the originating cells have their activeState output = 1 at time step t. ...
def _getSegmentActiveSynapses(self, c, i, s, activeState, newSynapses=False): """ Return a segmentUpdate data structure containing a list of proposed changes to segment s. Let activeSynapses be the list of active synapses where the originating cells have their activeState output = 1 at time step t. ...
[ "Return", "a", "segmentUpdate", "data", "structure", "containing", "a", "list", "of", "proposed", "changes", "to", "segment", "s", ".", "Let", "activeSynapses", "be", "the", "list", "of", "active", "synapses", "where", "the", "originating", "cells", "have", "t...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L3154-L3196
[ "def", "_getSegmentActiveSynapses", "(", "self", ",", "c", ",", "i", ",", "s", ",", "activeState", ",", "newSynapses", "=", "False", ")", ":", "activeSynapses", "=", "[", "]", "if", "s", "is", "not", "None", ":", "# s can be None, if adding a new segment", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._chooseCellsToLearnFrom
Choose n random cells to learn from. This function is called several times while learning with timeStep = t-1, so we cache the set of candidates for that case. It's also called once with timeStep = t, and we cache that set of candidates. :returns: tuple (column index, cell index).
src/nupic/algorithms/backtracking_tm.py
def _chooseCellsToLearnFrom(self, c, i, s, n, activeState): """ Choose n random cells to learn from. This function is called several times while learning with timeStep = t-1, so we cache the set of candidates for that case. It's also called once with timeStep = t, and we cache that set of candidate...
def _chooseCellsToLearnFrom(self, c, i, s, n, activeState): """ Choose n random cells to learn from. This function is called several times while learning with timeStep = t-1, so we cache the set of candidates for that case. It's also called once with timeStep = t, and we cache that set of candidate...
[ "Choose", "n", "random", "cells", "to", "learn", "from", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L3199-L3241
[ "def", "_chooseCellsToLearnFrom", "(", "self", ",", "c", ",", "i", ",", "s", ",", "n", ",", "activeState", ")", ":", "if", "n", "<=", "0", ":", "return", "[", "]", "tmpCandidates", "=", "numpy", ".", "where", "(", "activeState", "==", "1", ")", "# ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._processSegmentUpdates
Go through the list of accumulated segment updates and process them as follows: if the segment update is too old, remove the update else if the cell received bottom-up, update its permanences else if it's still being predicted, leave it in the queue else remove it. :param activeColumns TODO: d...
src/nupic/algorithms/backtracking_tm.py
def _processSegmentUpdates(self, activeColumns): """ Go through the list of accumulated segment updates and process them as follows: if the segment update is too old, remove the update else if the cell received bottom-up, update its permanences else if it's still being predicted, leave it in th...
def _processSegmentUpdates(self, activeColumns): """ Go through the list of accumulated segment updates and process them as follows: if the segment update is too old, remove the update else if the cell received bottom-up, update its permanences else if it's still being predicted, leave it in th...
[ "Go", "through", "the", "list", "of", "accumulated", "segment", "updates", "and", "process", "them", "as", "follows", ":" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L3244-L3313
[ "def", "_processSegmentUpdates", "(", "self", ",", "activeColumns", ")", ":", "# The segmentUpdates dict has keys which are the column,cellIdx of the", "# owner cell. The values are lists of segment updates for that cell", "removeKeys", "=", "[", "]", "trimSegments", "=", "[", "]",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
BacktrackingTM._adaptSegment
This function applies segment update information to a segment in a cell. Synapses on the active list get their permanence counts incremented by permanenceInc. All other synapses get their permanence counts decremented by permanenceDec. We also increment the positiveActivations count of the segment...
src/nupic/algorithms/backtracking_tm.py
def _adaptSegment(self, segUpdate): """ This function applies segment update information to a segment in a cell. Synapses on the active list get their permanence counts incremented by permanenceInc. All other synapses get their permanence counts decremented by permanenceDec. We also increm...
def _adaptSegment(self, segUpdate): """ This function applies segment update information to a segment in a cell. Synapses on the active list get their permanence counts incremented by permanenceInc. All other synapses get their permanence counts decremented by permanenceDec. We also increm...
[ "This", "function", "applies", "segment", "update", "information", "to", "a", "segment", "in", "a", "cell", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L3316-L3409
[ "def", "_adaptSegment", "(", "self", ",", "segUpdate", ")", ":", "# This will be set to True if detect that any syapses were decremented to", "# 0", "trimSegment", "=", "False", "# segUpdate.segment is None when creating a new segment", "c", ",", "i", ",", "segment", "=", "s...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Segment.dutyCycle
Compute/update and return the positive activations duty cycle of this segment. This is a measure of how often this segment is providing good predictions. :param active True if segment just provided a good prediction :param readOnly If True, compute the updated duty cycle, but don't change ...
src/nupic/algorithms/backtracking_tm.py
def dutyCycle(self, active=False, readOnly=False): """Compute/update and return the positive activations duty cycle of this segment. This is a measure of how often this segment is providing good predictions. :param active True if segment just provided a good prediction :param readOnly If True, c...
def dutyCycle(self, active=False, readOnly=False): """Compute/update and return the positive activations duty cycle of this segment. This is a measure of how often this segment is providing good predictions. :param active True if segment just provided a good prediction :param readOnly If True, c...
[ "Compute", "/", "update", "and", "return", "the", "positive", "activations", "duty", "cycle", "of", "this", "segment", ".", "This", "is", "a", "measure", "of", "how", "often", "this", "segment", "is", "providing", "good", "predictions", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L3599-L3669
[ "def", "dutyCycle", "(", "self", ",", "active", "=", "False", ",", "readOnly", "=", "False", ")", ":", "# For tier #0, compute it from total number of positive activations seen", "if", "self", ".", "tm", ".", "lrnIterationIdx", "<=", "self", ".", "dutyCycleTiers", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Segment.addSynapse
Add a new synapse :param srcCellCol source cell column :param srcCellIdx source cell index within the column :param perm initial permanence
src/nupic/algorithms/backtracking_tm.py
def addSynapse(self, srcCellCol, srcCellIdx, perm): """Add a new synapse :param srcCellCol source cell column :param srcCellIdx source cell index within the column :param perm initial permanence """ self.syns.append([int(srcCellCol), int(srcCellIdx), numpy.float32(perm)])
def addSynapse(self, srcCellCol, srcCellIdx, perm): """Add a new synapse :param srcCellCol source cell column :param srcCellIdx source cell index within the column :param perm initial permanence """ self.syns.append([int(srcCellCol), int(srcCellIdx), numpy.float32(perm)])
[ "Add", "a", "new", "synapse" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/backtracking_tm.py#L3778-L3785
[ "def", "addSynapse", "(", "self", ",", "srcCellCol", ",", "srcCellIdx", ",", "perm", ")", ":", "self", ".", "syns", ".", "append", "(", "[", "int", "(", "srcCellCol", ")", ",", "int", "(", "srcCellIdx", ")", ",", "numpy", ".", "float32", "(", "perm",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
logExceptions
Returns a closure suitable for use as function/method decorator for logging exceptions that leave the scope of the decorated function. Exceptions are logged at ERROR level. logger: user-supplied logger instance. Defaults to logging.getLogger. Usage Example: NOTE: logging must be initialized *before* an...
src/nupic/support/decorators.py
def logExceptions(logger=None): """ Returns a closure suitable for use as function/method decorator for logging exceptions that leave the scope of the decorated function. Exceptions are logged at ERROR level. logger: user-supplied logger instance. Defaults to logging.getLogger. Usage Example: NOTE: l...
def logExceptions(logger=None): """ Returns a closure suitable for use as function/method decorator for logging exceptions that leave the scope of the decorated function. Exceptions are logged at ERROR level. logger: user-supplied logger instance. Defaults to logging.getLogger. Usage Example: NOTE: l...
[ "Returns", "a", "closure", "suitable", "for", "use", "as", "function", "/", "method", "decorator", "for", "logging", "exceptions", "that", "leave", "the", "scope", "of", "the", "decorated", "function", ".", "Exceptions", "are", "logged", "at", "ERROR", "level"...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/decorators.py#L33-L65
[ "def", "logExceptions", "(", "logger", "=", "None", ")", ":", "logger", "=", "(", "logger", "if", "logger", "is", "not", "None", "else", "logging", ".", "getLogger", "(", "__name__", ")", ")", "def", "exceptionLoggingDecorator", "(", "func", ")", ":", "@...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
logEntryExit
Returns a closure suitable for use as function/method decorator for logging entry/exit of function/method. getLoggerCallback: user-supplied callback function that takes no args and returns the logger instance to use for logging. entryExitLogLevel: Log level for logging entry/exit ...
src/nupic/support/decorators.py
def logEntryExit(getLoggerCallback=logging.getLogger, entryExitLogLevel=logging.DEBUG, logArgs=False, logTraceback=False): """ Returns a closure suitable for use as function/method decorator for logging entry/exit of function/method. getLoggerCallback: user-supplied callback ...
def logEntryExit(getLoggerCallback=logging.getLogger, entryExitLogLevel=logging.DEBUG, logArgs=False, logTraceback=False): """ Returns a closure suitable for use as function/method decorator for logging entry/exit of function/method. getLoggerCallback: user-supplied callback ...
[ "Returns", "a", "closure", "suitable", "for", "use", "as", "function", "/", "method", "decorator", "for", "logging", "entry", "/", "exit", "of", "function", "/", "method", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/decorators.py#L69-L137
[ "def", "logEntryExit", "(", "getLoggerCallback", "=", "logging", ".", "getLogger", ",", "entryExitLogLevel", "=", "logging", ".", "DEBUG", ",", "logArgs", "=", "False", ",", "logTraceback", "=", "False", ")", ":", "def", "entryExitLoggingDecorator", "(", "func",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
retry
Returns a closure suitable for use as function/method decorator for retrying a function being decorated. timeoutSec: How many seconds from time of initial call to stop retrying (floating point); 0 = no retries initialRetryDelaySec: Number of seconds to wait for first retry. ...
src/nupic/support/decorators.py
def retry(timeoutSec, initialRetryDelaySec, maxRetryDelaySec, retryExceptions=(Exception,), retryFilter=lambda e, args, kwargs: True, logger=None, clientLabel=""): """ Returns a closure suitable for use as function/method decorator for retrying a function being decorated. timeoutSec...
def retry(timeoutSec, initialRetryDelaySec, maxRetryDelaySec, retryExceptions=(Exception,), retryFilter=lambda e, args, kwargs: True, logger=None, clientLabel=""): """ Returns a closure suitable for use as function/method decorator for retrying a function being decorated. timeoutSec...
[ "Returns", "a", "closure", "suitable", "for", "use", "as", "function", "/", "method", "decorator", "for", "retrying", "a", "function", "being", "decorated", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/decorators.py#L141-L253
[ "def", "retry", "(", "timeoutSec", ",", "initialRetryDelaySec", ",", "maxRetryDelaySec", ",", "retryExceptions", "=", "(", "Exception", ",", ")", ",", "retryFilter", "=", "lambda", "e", ",", "args", ",", "kwargs", ":", "True", ",", "logger", "=", "None", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
getSimplePatterns
Very simple patterns. Each pattern has numOnes consecutive bits on. The amount of overlap between consecutive patterns is configurable, via the patternOverlap parameter. Parameters: ----------------------------------------------------------------------- numOnes: Number of bits ON in each pattern num...
examples/tm/tm_overlapping_sequences.py
def getSimplePatterns(numOnes, numPatterns, patternOverlap=0): """Very simple patterns. Each pattern has numOnes consecutive bits on. The amount of overlap between consecutive patterns is configurable, via the patternOverlap parameter. Parameters: -------------------------------------------------------------...
def getSimplePatterns(numOnes, numPatterns, patternOverlap=0): """Very simple patterns. Each pattern has numOnes consecutive bits on. The amount of overlap between consecutive patterns is configurable, via the patternOverlap parameter. Parameters: -------------------------------------------------------------...
[ "Very", "simple", "patterns", ".", "Each", "pattern", "has", "numOnes", "consecutive", "bits", "on", ".", "The", "amount", "of", "overlap", "between", "consecutive", "patterns", "is", "configurable", "via", "the", "patternOverlap", "parameter", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/tm/tm_overlapping_sequences.py#L80-L109
[ "def", "getSimplePatterns", "(", "numOnes", ",", "numPatterns", ",", "patternOverlap", "=", "0", ")", ":", "assert", "(", "patternOverlap", "<", "numOnes", ")", "# How many new bits are introduced in each successive pattern?", "numNewBitsInEachPattern", "=", "numOnes", "-...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
buildOverlappedSequences
Create training sequences that share some elements in the middle. Parameters: ----------------------------------------------------- numSequences: Number of unique training sequences to generate seqLen: Overall length of each sequence sharedElements: Which element indices of each s...
examples/tm/tm_overlapping_sequences.py
def buildOverlappedSequences( numSequences = 2, seqLen = 5, sharedElements = [3,4], numOnBitsPerPattern = 3, patternOverlap = 0, seqOverlap = 0, ...
def buildOverlappedSequences( numSequences = 2, seqLen = 5, sharedElements = [3,4], numOnBitsPerPattern = 3, patternOverlap = 0, seqOverlap = 0, ...
[ "Create", "training", "sequences", "that", "share", "some", "elements", "in", "the", "middle", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/tm/tm_overlapping_sequences.py#L113-L176
[ "def", "buildOverlappedSequences", "(", "numSequences", "=", "2", ",", "seqLen", "=", "5", ",", "sharedElements", "=", "[", "3", ",", "4", "]", ",", "numOnBitsPerPattern", "=", "3", ",", "patternOverlap", "=", "0", ",", "seqOverlap", "=", "0", ",", "*", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
buildSequencePool
Create a bunch of sequences of various lengths, all built from a fixed set of patterns. Parameters: ----------------------------------------------------- numSequences: Number of training sequences to generate seqLen: List of possible sequence lengths numPatterns: How many pos...
examples/tm/tm_overlapping_sequences.py
def buildSequencePool(numSequences = 10, seqLen = [2,3,4], numPatterns = 5, numOnBitsPerPattern = 3, patternOverlap = 0, **kwargs ): """ Create a bunch of sequences of various lengths, a...
def buildSequencePool(numSequences = 10, seqLen = [2,3,4], numPatterns = 5, numOnBitsPerPattern = 3, patternOverlap = 0, **kwargs ): """ Create a bunch of sequences of various lengths, a...
[ "Create", "a", "bunch", "of", "sequences", "of", "various", "lengths", "all", "built", "from", "a", "fixed", "set", "of", "patterns", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/tm/tm_overlapping_sequences.py#L180-L232
[ "def", "buildSequencePool", "(", "numSequences", "=", "10", ",", "seqLen", "=", "[", "2", ",", "3", ",", "4", "]", ",", "numPatterns", "=", "5", ",", "numOnBitsPerPattern", "=", "3", ",", "patternOverlap", "=", "0", ",", "*", "*", "kwargs", ")", ":",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
createTMs
Create one or more TM instances, placing each into a dict keyed by name. Parameters: ------------------------------------------------------------------ retval: tms - dict of TM instances
examples/tm/tm_overlapping_sequences.py
def createTMs(includeCPP = True, includePy = True, numCols = 100, cellsPerCol = 4, activationThreshold = 3, minThreshold = 3, newSynapseCount = 3, initialPerm = 0.6, permanenceInc = 0.1, permane...
def createTMs(includeCPP = True, includePy = True, numCols = 100, cellsPerCol = 4, activationThreshold = 3, minThreshold = 3, newSynapseCount = 3, initialPerm = 0.6, permanenceInc = 0.1, permane...
[ "Create", "one", "or", "more", "TM", "instances", "placing", "each", "into", "a", "dict", "keyed", "by", "name", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/tm/tm_overlapping_sequences.py#L236-L315
[ "def", "createTMs", "(", "includeCPP", "=", "True", ",", "includePy", "=", "True", ",", "numCols", "=", "100", ",", "cellsPerCol", "=", "4", ",", "activationThreshold", "=", "3", ",", "minThreshold", "=", "3", ",", "newSynapseCount", "=", "3", ",", "init...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
assertNoTMDiffs
Check for diffs among the TM instances in the passed in tms dict and raise an assert if any are detected Parameters: --------------------------------------------------------------------- tms: dict of TM instances
examples/tm/tm_overlapping_sequences.py
def assertNoTMDiffs(tms): """ Check for diffs among the TM instances in the passed in tms dict and raise an assert if any are detected Parameters: --------------------------------------------------------------------- tms: dict of TM instances """ if len(tms) == 1: return if len(...
def assertNoTMDiffs(tms): """ Check for diffs among the TM instances in the passed in tms dict and raise an assert if any are detected Parameters: --------------------------------------------------------------------- tms: dict of TM instances """ if len(tms) == 1: return if len(...
[ "Check", "for", "diffs", "among", "the", "TM", "instances", "in", "the", "passed", "in", "tms", "dict", "and", "raise", "an", "assert", "if", "any", "are", "detected" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/tm/tm_overlapping_sequences.py#L319-L336
[ "def", "assertNoTMDiffs", "(", "tms", ")", ":", "if", "len", "(", "tms", ")", "==", "1", ":", "return", "if", "len", "(", "tms", ")", ">", "2", ":", "raise", "\"Not implemented for more than 2 TMs\"", "same", "=", "fdrutils", ".", "tmDiff2", "(", "tms", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
evalSequences
Train the TMs on the entire training set for nTrainRepetitions in a row. Then run the test set through inference once and return the inference stats. Parameters: --------------------------------------------------------------------- tms: dict of TM instances trainingSequences: list of trai...
examples/tm/tm_overlapping_sequences.py
def evalSequences(tms, trainingSequences, testSequences = None, nTrainRepetitions = 1, doResets = True, **kwargs): """Train the TMs on the entire training set for nTrainRepetitions in a row. Then run the test set through infe...
def evalSequences(tms, trainingSequences, testSequences = None, nTrainRepetitions = 1, doResets = True, **kwargs): """Train the TMs on the entire training set for nTrainRepetitions in a row. Then run the test set through infe...
[ "Train", "the", "TMs", "on", "the", "entire", "training", "set", "for", "nTrainRepetitions", "in", "a", "row", ".", "Then", "run", "the", "test", "set", "through", "inference", "once", "and", "return", "the", "inference", "stats", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/tm/tm_overlapping_sequences.py#L340-L588
[ "def", "evalSequences", "(", "tms", ",", "trainingSequences", ",", "testSequences", "=", "None", ",", "nTrainRepetitions", "=", "1", ",", "doResets", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# If no test sequence is specified, use the first training sequence",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
needsquoting
Decide whether a particular character needs to be quoted. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521.
third_party/stdlib/quopri.py
def needsquoting(c, quotetabs, header): """Decide whether a particular character needs to be quoted. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. """ if c in ' \t': return qu...
def needsquoting(c, quotetabs, header): """Decide whether a particular character needs to be quoted. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. """ if c in ' \t': return qu...
[ "Decide", "whether", "a", "particular", "character", "needs", "to", "be", "quoted", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/quopri.py#L21-L33
[ "def", "needsquoting", "(", "c", ",", "quotetabs", ",", "header", ")", ":", "if", "c", "in", "' \\t'", ":", "return", "quotetabs", "# if header, we have to escape _ because _ is used to escape space", "if", "c", "==", "'_'", ":", "return", "header", "return", "c",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
quote
Quote a single character.
third_party/stdlib/quopri.py
def quote(c): """Quote a single character.""" i = ord(c) return ESCAPE + HEX[i//16] + HEX[i%16]
def quote(c): """Quote a single character.""" i = ord(c) return ESCAPE + HEX[i//16] + HEX[i%16]
[ "Quote", "a", "single", "character", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/quopri.py#L35-L38
[ "def", "quote", "(", "c", ")", ":", "i", "=", "ord", "(", "c", ")", "return", "ESCAPE", "+", "HEX", "[", "i", "//", "16", "]", "+", "HEX", "[", "i", "%", "16", "]" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
encode
Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. The...
third_party/stdlib/quopri.py
def encode(input, output, quotetabs, header = 0): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs an...
def encode(input, output, quotetabs, header = 0): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs an...
[ "Read", "input", "apply", "quoted", "-", "printable", "encoding", "and", "write", "to", "output", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/quopri.py#L42-L103
[ "def", "encode", "(", "input", ",", "output", ",", "quotetabs", ",", "header", "=", "0", ")", ":", "if", "b2a_qp", "is", "not", "None", ":", "data", "=", "input", ".", "read", "(", ")", "odata", "=", "b2a_qp", "(", "data", ",", "quotetabs", "=", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
decode
Read 'input', apply quoted-printable decoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. If 'header' is true, decode underscore as space (per RFC 1522).
third_party/stdlib/quopri.py
def decode(input, output, header = 0): """Read 'input', apply quoted-printable decoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. If 'header' is true, decode underscore as space (per RFC 1522).""" if a2b_qp is not None: data = input.read() ...
def decode(input, output, header = 0): """Read 'input', apply quoted-printable decoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. If 'header' is true, decode underscore as space (per RFC 1522).""" if a2b_qp is not None: data = input.read() ...
[ "Read", "input", "apply", "quoted", "-", "printable", "decoding", "and", "write", "to", "output", ".", "input", "and", "output", "are", "files", "with", "readline", "()", "and", "write", "()", "methods", ".", "If", "header", "is", "true", "decode", "unders...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/quopri.py#L116-L157
[ "def", "decode", "(", "input", ",", "output", ",", "header", "=", "0", ")", ":", "if", "a2b_qp", "is", "not", "None", ":", "data", "=", "input", ".", "read", "(", ")", "odata", "=", "a2b_qp", "(", "data", ",", "header", "=", "header", ")", "outpu...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
unhex
Get the integer value of a hexadecimal number.
third_party/stdlib/quopri.py
def unhex(s): """Get the integer value of a hexadecimal number.""" bits = 0 for c in s: if '0' <= c <= '9': i = ord('0') elif 'a' <= c <= 'f': i = ord('a')-10 elif 'A' <= c <= 'F': i = ord('A')-10 else: break bits = bits...
def unhex(s): """Get the integer value of a hexadecimal number.""" bits = 0 for c in s: if '0' <= c <= '9': i = ord('0') elif 'a' <= c <= 'f': i = ord('a')-10 elif 'A' <= c <= 'F': i = ord('A')-10 else: break bits = bits...
[ "Get", "the", "integer", "value", "of", "a", "hexadecimal", "number", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/quopri.py#L175-L188
[ "def", "unhex", "(", "s", ")", ":", "bits", "=", "0", "for", "c", "in", "s", ":", "if", "'0'", "<=", "c", "<=", "'9'", ":", "i", "=", "ord", "(", "'0'", ")", "elif", "'a'", "<=", "c", "<=", "'f'", ":", "i", "=", "ord", "(", "'a'", ")", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
b64encode
Encode a string using Base64. s is the string to encode. Optional altchars must be a string of at least length 2 (additional characters are ignored) which specifies an alternative alphabet for the '+' and '/' characters. This allows an application to e.g. generate url or filesystem safe Base64 string...
third_party/stdlib/base64.py
def b64encode(s, altchars=None): """Encode a string using Base64. s is the string to encode. Optional altchars must be a string of at least length 2 (additional characters are ignored) which specifies an alternative alphabet for the '+' and '/' characters. This allows an application to e.g. gener...
def b64encode(s, altchars=None): """Encode a string using Base64. s is the string to encode. Optional altchars must be a string of at least length 2 (additional characters are ignored) which specifies an alternative alphabet for the '+' and '/' characters. This allows an application to e.g. gener...
[ "Encode", "a", "string", "using", "Base64", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/base64.py#L44-L58
[ "def", "b64encode", "(", "s", ",", "altchars", "=", "None", ")", ":", "# Strip off the trailing newline", "encoded", "=", "binascii", ".", "b2a_base64", "(", "s", ")", "[", ":", "-", "1", "]", "if", "altchars", "is", "not", "None", ":", "return", "encode...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
b64decode
Decode a Base64 encoded string. s is the string to decode. Optional altchars must be a string of at least length 2 (additional characters are ignored) which specifies the alternative alphabet used instead of the '+' and '/' characters. The decoded string is returned. A TypeError is raised if s is ...
third_party/stdlib/base64.py
def b64decode(s, altchars=None): """Decode a Base64 encoded string. s is the string to decode. Optional altchars must be a string of at least length 2 (additional characters are ignored) which specifies the alternative alphabet used instead of the '+' and '/' characters. The decoded string is ret...
def b64decode(s, altchars=None): """Decode a Base64 encoded string. s is the string to decode. Optional altchars must be a string of at least length 2 (additional characters are ignored) which specifies the alternative alphabet used instead of the '+' and '/' characters. The decoded string is ret...
[ "Decode", "a", "Base64", "encoded", "string", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/base64.py#L61-L79
[ "def", "b64decode", "(", "s", ",", "altchars", "=", "None", ")", ":", "if", "altchars", "is", "not", "None", ":", "s", "=", "s", ".", "translate", "(", "string", ".", "maketrans", "(", "altchars", "[", ":", "2", "]", ",", "'+/'", ")", ")", "try",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
b32encode
Encode a string using Base32. s is the string to encode. The encoded string is returned.
third_party/stdlib/base64.py
def b32encode(s): """Encode a string using Base32. s is the string to encode. The encoded string is returned. """ parts = [] quanta, leftover = divmod(len(s), 5) # Pad the last quantum with zero bits if necessary if leftover: s += ('\0' * (5 - leftover)) quanta += 1 for...
def b32encode(s): """Encode a string using Base32. s is the string to encode. The encoded string is returned. """ parts = [] quanta, leftover = divmod(len(s), 5) # Pad the last quantum with zero bits if necessary if leftover: s += ('\0' * (5 - leftover)) quanta += 1 for...
[ "Encode", "a", "string", "using", "Base32", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/base64.py#L143-L182
[ "def", "b32encode", "(", "s", ")", ":", "parts", "=", "[", "]", "quanta", ",", "leftover", "=", "divmod", "(", "len", "(", "s", ")", ",", "5", ")", "# Pad the last quantum with zero bits if necessary", "if", "leftover", ":", "s", "+=", "(", "'\\0'", "*",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
b32decode
Decode a Base32 encoded string. s is the string to decode. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. RFC 3548 allows for optional mapping of the digit 0 (zero) to the letter O (oh), and for optional ma...
third_party/stdlib/base64.py
def b32decode(s, casefold=False, map01=None): """Decode a Base32 encoded string. s is the string to decode. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. RFC 3548 allows for optional mapping of the digit 0...
def b32decode(s, casefold=False, map01=None): """Decode a Base32 encoded string. s is the string to decode. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. RFC 3548 allows for optional mapping of the digit 0...
[ "Decode", "a", "Base32", "encoded", "string", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/base64.py#L185-L252
[ "def", "b32decode", "(", "s", ",", "casefold", "=", "False", ",", "map01", "=", "None", ")", ":", "quanta", ",", "leftover", "=", "divmod", "(", "len", "(", "s", ")", ",", "8", ")", "if", "leftover", ":", "raise", "TypeError", "(", "'Incorrect paddin...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
b16decode
Decode a Base16 encoded string. s is the string to decode. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. The decoded string is returned. A TypeError is raised if s is incorrectly padded or if there are no...
third_party/stdlib/base64.py
def b16decode(s, casefold=False): """Decode a Base16 encoded string. s is the string to decode. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. The decoded string is returned. A TypeError is raised if s is ...
def b16decode(s, casefold=False): """Decode a Base16 encoded string. s is the string to decode. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. The decoded string is returned. A TypeError is raised if s is ...
[ "Decode", "a", "Base16", "encoded", "string", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/base64.py#L267-L282
[ "def", "b16decode", "(", "s", ",", "casefold", "=", "False", ")", ":", "if", "casefold", ":", "s", "=", "s", ".", "upper", "(", ")", "if", "re", ".", "search", "(", "'[^0-9A-F]'", ",", "s", ")", ":", "raise", "TypeError", "(", "'Non-base16 digit foun...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
encode
Encode a file.
third_party/stdlib/base64.py
def encode(input, output): """Encode a file.""" while True: s = input.read(MAXBINSIZE) if not s: break while len(s) < MAXBINSIZE: ns = input.read(MAXBINSIZE-len(s)) if not ns: break s += ns line = binascii.b2a_base64...
def encode(input, output): """Encode a file.""" while True: s = input.read(MAXBINSIZE) if not s: break while len(s) < MAXBINSIZE: ns = input.read(MAXBINSIZE-len(s)) if not ns: break s += ns line = binascii.b2a_base64...
[ "Encode", "a", "file", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/base64.py#L293-L305
[ "def", "encode", "(", "input", ",", "output", ")", ":", "while", "True", ":", "s", "=", "input", ".", "read", "(", "MAXBINSIZE", ")", "if", "not", "s", ":", "break", "while", "len", "(", "s", ")", "<", "MAXBINSIZE", ":", "ns", "=", "input", ".", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
decode
Decode a file.
third_party/stdlib/base64.py
def decode(input, output): """Decode a file.""" while True: line = input.readline() if not line: break s = binascii.a2b_base64(line) output.write(s)
def decode(input, output): """Decode a file.""" while True: line = input.readline() if not line: break s = binascii.a2b_base64(line) output.write(s)
[ "Decode", "a", "file", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/base64.py#L308-L315
[ "def", "decode", "(", "input", ",", "output", ")", ":", "while", "True", ":", "line", "=", "input", ".", "readline", "(", ")", "if", "not", "line", ":", "break", "s", "=", "binascii", ".", "a2b_base64", "(", "line", ")", "output", ".", "write", "("...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
encodestring
Encode a string into multiple lines of base-64 data.
third_party/stdlib/base64.py
def encodestring(s): """Encode a string into multiple lines of base-64 data.""" pieces = [] for i in range(0, len(s), MAXBINSIZE): chunk = s[i : i + MAXBINSIZE] pieces.append(binascii.b2a_base64(chunk)) return "".join(pieces)
def encodestring(s): """Encode a string into multiple lines of base-64 data.""" pieces = [] for i in range(0, len(s), MAXBINSIZE): chunk = s[i : i + MAXBINSIZE] pieces.append(binascii.b2a_base64(chunk)) return "".join(pieces)
[ "Encode", "a", "string", "into", "multiple", "lines", "of", "base", "-", "64", "data", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/base64.py#L318-L324
[ "def", "encodestring", "(", "s", ")", ":", "pieces", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "s", ")", ",", "MAXBINSIZE", ")", ":", "chunk", "=", "s", "[", "i", ":", "i", "+", "MAXBINSIZE", "]", "pieces", ".", "ap...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Buffer.source_line
Returns line ``lineno`` from source, taking ``first_line`` into account, or raises :exc:`IndexError` if ``lineno`` is out of range.
third_party/pythonparser/source.py
def source_line(self, lineno): """ Returns line ``lineno`` from source, taking ``first_line`` into account, or raises :exc:`IndexError` if ``lineno`` is out of range. """ line_begins = self._extract_line_begins() lineno = lineno - self.first_line if lineno >= 0 an...
def source_line(self, lineno): """ Returns line ``lineno`` from source, taking ``first_line`` into account, or raises :exc:`IndexError` if ``lineno`` is out of range. """ line_begins = self._extract_line_begins() lineno = lineno - self.first_line if lineno >= 0 an...
[ "Returns", "line", "lineno", "from", "source", "taking", "first_line", "into", "account", "or", "raises", ":", "exc", ":", "IndexError", "if", "lineno", "is", "out", "of", "range", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L34-L47
[ "def", "source_line", "(", "self", ",", "lineno", ")", ":", "line_begins", "=", "self", ".", "_extract_line_begins", "(", ")", "lineno", "=", "lineno", "-", "self", ".", "first_line", "if", "lineno", ">=", "0", "and", "lineno", "+", "1", "<", "len", "(...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Buffer.decompose_position
Returns a ``line, column`` tuple for a character offset into the source, orraises :exc:`IndexError` if ``lineno`` is out of range.
third_party/pythonparser/source.py
def decompose_position(self, offset): """ Returns a ``line, column`` tuple for a character offset into the source, orraises :exc:`IndexError` if ``lineno`` is out of range. """ line_begins = self._extract_line_begins() lineno = bisect.bisect_right(line_begins, offset) - 1...
def decompose_position(self, offset): """ Returns a ``line, column`` tuple for a character offset into the source, orraises :exc:`IndexError` if ``lineno`` is out of range. """ line_begins = self._extract_line_begins() lineno = bisect.bisect_right(line_begins, offset) - 1...
[ "Returns", "a", "line", "column", "tuple", "for", "a", "character", "offset", "into", "the", "source", "orraises", ":", "exc", ":", "IndexError", "if", "lineno", "is", "out", "of", "range", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L49-L59
[ "def", "decompose_position", "(", "self", ",", "offset", ")", ":", "line_begins", "=", "self", ".", "_extract_line_begins", "(", ")", "lineno", "=", "bisect", ".", "bisect_right", "(", "line_begins", ",", "offset", ")", "-", "1", "if", "offset", ">=", "0",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Range.chain
Returns a range identical to this one, but indicating that it was expanded from the range `expanded_from`.
third_party/pythonparser/source.py
def chain(self, expanded_from): """ Returns a range identical to this one, but indicating that it was expanded from the range `expanded_from`. """ return Range(self.source_buffer, self.begin_pos, self.begin_pos, expanded_from=expanded_from)
def chain(self, expanded_from): """ Returns a range identical to this one, but indicating that it was expanded from the range `expanded_from`. """ return Range(self.source_buffer, self.begin_pos, self.begin_pos, expanded_from=expanded_from)
[ "Returns", "a", "range", "identical", "to", "this", "one", "but", "indicating", "that", "it", "was", "expanded", "from", "the", "range", "expanded_from", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L118-L124
[ "def", "chain", "(", "self", ",", "expanded_from", ")", ":", "return", "Range", "(", "self", ".", "source_buffer", ",", "self", ".", "begin_pos", ",", "self", ".", "begin_pos", ",", "expanded_from", "=", "expanded_from", ")" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Range.begin
Returns a zero-length range located just before the beginning of this range.
third_party/pythonparser/source.py
def begin(self): """ Returns a zero-length range located just before the beginning of this range. """ return Range(self.source_buffer, self.begin_pos, self.begin_pos, expanded_from=self.expanded_from)
def begin(self): """ Returns a zero-length range located just before the beginning of this range. """ return Range(self.source_buffer, self.begin_pos, self.begin_pos, expanded_from=self.expanded_from)
[ "Returns", "a", "zero", "-", "length", "range", "located", "just", "before", "the", "beginning", "of", "this", "range", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L126-L131
[ "def", "begin", "(", "self", ")", ":", "return", "Range", "(", "self", ".", "source_buffer", ",", "self", ".", "begin_pos", ",", "self", ".", "begin_pos", ",", "expanded_from", "=", "self", ".", "expanded_from", ")" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Range.end
Returns a zero-length range located just after the end of this range.
third_party/pythonparser/source.py
def end(self): """ Returns a zero-length range located just after the end of this range. """ return Range(self.source_buffer, self.end_pos, self.end_pos, expanded_from=self.expanded_from)
def end(self): """ Returns a zero-length range located just after the end of this range. """ return Range(self.source_buffer, self.end_pos, self.end_pos, expanded_from=self.expanded_from)
[ "Returns", "a", "zero", "-", "length", "range", "located", "just", "after", "the", "end", "of", "this", "range", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L133-L138
[ "def", "end", "(", "self", ")", ":", "return", "Range", "(", "self", ".", "source_buffer", ",", "self", ".", "end_pos", ",", "self", ".", "end_pos", ",", "expanded_from", "=", "self", ".", "expanded_from", ")" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Range.column
Returns a zero-based column number of the beginning of this range.
third_party/pythonparser/source.py
def column(self): """ Returns a zero-based column number of the beginning of this range. """ line, column = self.source_buffer.decompose_position(self.begin_pos) return column
def column(self): """ Returns a zero-based column number of the beginning of this range. """ line, column = self.source_buffer.decompose_position(self.begin_pos) return column
[ "Returns", "a", "zero", "-", "based", "column", "number", "of", "the", "beginning", "of", "this", "range", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L146-L151
[ "def", "column", "(", "self", ")", ":", "line", ",", "column", "=", "self", ".", "source_buffer", ".", "decompose_position", "(", "self", ".", "begin_pos", ")", "return", "column" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Range.column_range
Returns a [*begin*, *end*) tuple describing the range of columns spanned by this range. If range spans more than one line, returned *end* is the last column of the line.
third_party/pythonparser/source.py
def column_range(self): """ Returns a [*begin*, *end*) tuple describing the range of columns spanned by this range. If range spans more than one line, returned *end* is the last column of the line. """ if self.begin().line() == self.end().line(): return self.b...
def column_range(self): """ Returns a [*begin*, *end*) tuple describing the range of columns spanned by this range. If range spans more than one line, returned *end* is the last column of the line. """ if self.begin().line() == self.end().line(): return self.b...
[ "Returns", "a", "[", "*", "begin", "*", "*", "end", "*", ")", "tuple", "describing", "the", "range", "of", "columns", "spanned", "by", "this", "range", ".", "If", "range", "spans", "more", "than", "one", "line", "returned", "*", "end", "*", "is", "th...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L153-L162
[ "def", "column_range", "(", "self", ")", ":", "if", "self", ".", "begin", "(", ")", ".", "line", "(", ")", "==", "self", ".", "end", "(", ")", ".", "line", "(", ")", ":", "return", "self", ".", "begin", "(", ")", ".", "column", "(", ")", ",",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Range.line
Returns the line number of the beginning of this range.
third_party/pythonparser/source.py
def line(self): """ Returns the line number of the beginning of this range. """ line, column = self.source_buffer.decompose_position(self.begin_pos) return line
def line(self): """ Returns the line number of the beginning of this range. """ line, column = self.source_buffer.decompose_position(self.begin_pos) return line
[ "Returns", "the", "line", "number", "of", "the", "beginning", "of", "this", "range", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L164-L169
[ "def", "line", "(", "self", ")", ":", "line", ",", "column", "=", "self", ".", "source_buffer", ".", "decompose_position", "(", "self", ".", "begin_pos", ")", "return", "line" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Range.join
Returns the smallest possible range spanning both this range and other. Raises :exc:`ValueError` if the ranges do not belong to the same :class:`Buffer`.
third_party/pythonparser/source.py
def join(self, other): """ Returns the smallest possible range spanning both this range and other. Raises :exc:`ValueError` if the ranges do not belong to the same :class:`Buffer`. """ if self.source_buffer != other.source_buffer: raise ValueError if s...
def join(self, other): """ Returns the smallest possible range spanning both this range and other. Raises :exc:`ValueError` if the ranges do not belong to the same :class:`Buffer`. """ if self.source_buffer != other.source_buffer: raise ValueError if s...
[ "Returns", "the", "smallest", "possible", "range", "spanning", "both", "this", "range", "and", "other", ".", "Raises", ":", "exc", ":", "ValueError", "if", "the", "ranges", "do", "not", "belong", "to", "the", "same", ":", "class", ":", "Buffer", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L171-L186
[ "def", "join", "(", "self", ",", "other", ")", ":", "if", "self", ".", "source_buffer", "!=", "other", ".", "source_buffer", ":", "raise", "ValueError", "if", "self", ".", "expanded_from", "==", "other", ".", "expanded_from", ":", "expanded_from", "=", "se...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Range.source_lines
Returns the lines of source code containing the entirety of this range.
third_party/pythonparser/source.py
def source_lines(self): """ Returns the lines of source code containing the entirety of this range. """ return [self.source_buffer.source_line(line) for line in range(self.line(), self.end().line() + 1)]
def source_lines(self): """ Returns the lines of source code containing the entirety of this range. """ return [self.source_buffer.source_line(line) for line in range(self.line(), self.end().line() + 1)]
[ "Returns", "the", "lines", "of", "source", "code", "containing", "the", "entirety", "of", "this", "range", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L200-L205
[ "def", "source_lines", "(", "self", ")", ":", "return", "[", "self", ".", "source_buffer", ".", "source_line", "(", "line", ")", "for", "line", "in", "range", "(", "self", ".", "line", "(", ")", ",", "self", ".", "end", "(", ")", ".", "line", "(", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Rewriter.rewrite
Return the rewritten source. May raise :class:`RewriterConflict`.
third_party/pythonparser/source.py
def rewrite(self): """Return the rewritten source. May raise :class:`RewriterConflict`.""" self._sort() self._check() rewritten, pos = [], 0 for range, replacement in self.ranges: rewritten.append(self.buffer.source[pos:range.begin_pos]) rewritten.append(...
def rewrite(self): """Return the rewritten source. May raise :class:`RewriterConflict`.""" self._sort() self._check() rewritten, pos = [], 0 for range, replacement in self.ranges: rewritten.append(self.buffer.source[pos:range.begin_pos]) rewritten.append(...
[ "Return", "the", "rewritten", "source", ".", "May", "raise", ":", "class", ":", "RewriterConflict", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/source.py#L290-L302
[ "def", "rewrite", "(", "self", ")", ":", "self", ".", "_sort", "(", ")", "self", ".", "_check", "(", ")", "rewritten", ",", "pos", "=", "[", "]", ",", "0", "for", "range", ",", "replacement", "in", "self", ".", "ranges", ":", "rewritten", ".", "a...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
compare
An AST comparison function. Returns ``True`` if all fields in ``left`` are equal to fields in ``right``; if ``compare_locs`` is true, all locations should match as well.
third_party/pythonparser/algorithm.py
def compare(left, right, compare_locs=False): """ An AST comparison function. Returns ``True`` if all fields in ``left`` are equal to fields in ``right``; if ``compare_locs`` is true, all locations should match as well. """ if type(left) != type(right): return False if isinstance(le...
def compare(left, right, compare_locs=False): """ An AST comparison function. Returns ``True`` if all fields in ``left`` are equal to fields in ``right``; if ``compare_locs`` is true, all locations should match as well. """ if type(left) != type(right): return False if isinstance(le...
[ "An", "AST", "comparison", "function", ".", "Returns", "True", "if", "all", "fields", "in", "left", "are", "equal", "to", "fields", "in", "right", ";", "if", "compare_locs", "is", "true", "all", "locations", "should", "match", "as", "well", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/algorithm.py#L87-L117
[ "def", "compare", "(", "left", ",", "right", ",", "compare_locs", "=", "False", ")", ":", "if", "type", "(", "left", ")", "!=", "type", "(", "right", ")", ":", "return", "False", "if", "isinstance", "(", "left", ",", "ast", ".", "AST", ")", ":", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Visitor.visit
Visit a node or a list of nodes. Other values are ignored
third_party/pythonparser/algorithm.py
def visit(self, obj): """Visit a node or a list of nodes. Other values are ignored""" if isinstance(obj, list): return [self.visit(elt) for elt in obj] elif isinstance(obj, ast.AST): return self._visit_one(obj)
def visit(self, obj): """Visit a node or a list of nodes. Other values are ignored""" if isinstance(obj, list): return [self.visit(elt) for elt in obj] elif isinstance(obj, ast.AST): return self._visit_one(obj)
[ "Visit", "a", "node", "or", "a", "list", "of", "nodes", ".", "Other", "values", "are", "ignored" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/algorithm.py#L36-L41
[ "def", "visit", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "list", ")", ":", "return", "[", "self", ".", "visit", "(", "elt", ")", "for", "elt", "in", "obj", "]", "elif", "isinstance", "(", "obj", ",", "ast", ".", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Transformer.generic_visit
Called if no explicit visitor function exists for a node.
third_party/pythonparser/algorithm.py
def generic_visit(self, node): """Called if no explicit visitor function exists for a node.""" for field_name in node._fields: setattr(node, field_name, self.visit(getattr(node, field_name))) return node
def generic_visit(self, node): """Called if no explicit visitor function exists for a node.""" for field_name in node._fields: setattr(node, field_name, self.visit(getattr(node, field_name))) return node
[ "Called", "if", "no", "explicit", "visitor", "function", "exists", "for", "a", "node", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/algorithm.py#L65-L69
[ "def", "generic_visit", "(", "self", ",", "node", ")", ":", "for", "field_name", "in", "node", ".", "_fields", ":", "setattr", "(", "node", ",", "field_name", ",", "self", ".", "visit", "(", "getattr", "(", "node", ",", "field_name", ")", ")", ")", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Transformer.visit
Visit a node or a list of nodes. Other values are ignored
third_party/pythonparser/algorithm.py
def visit(self, obj): """Visit a node or a list of nodes. Other values are ignored""" if isinstance(obj, list): return list(filter(lambda x: x is not None, map(self.visit, obj))) elif isinstance(obj, ast.AST): return self._visit_one(obj) else: return o...
def visit(self, obj): """Visit a node or a list of nodes. Other values are ignored""" if isinstance(obj, list): return list(filter(lambda x: x is not None, map(self.visit, obj))) elif isinstance(obj, ast.AST): return self._visit_one(obj) else: return o...
[ "Visit", "a", "node", "or", "a", "list", "of", "nodes", ".", "Other", "values", "are", "ignored" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/algorithm.py#L78-L85
[ "def", "visit", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "list", ")", ":", "return", "list", "(", "filter", "(", "lambda", "x", ":", "x", "is", "not", "None", ",", "map", "(", "self", ".", "visit", ",", "obj", ")"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
start_new_thread
Dummy implementation of thread.start_new_thread(). Compatibility is maintained by making sure that ``args`` is a tuple and ``kwargs`` is a dictionary. If an exception is raised and it is SystemExit (which can be done by thread.exit()) it is caught and nothing is done; all other exceptions are printed ...
third_party/stdlib/dummy_thread.py
def start_new_thread(function, args, kwargs={}): """Dummy implementation of thread.start_new_thread(). Compatibility is maintained by making sure that ``args`` is a tuple and ``kwargs`` is a dictionary. If an exception is raised and it is SystemExit (which can be done by thread.exit()) it is caugh...
def start_new_thread(function, args, kwargs={}): """Dummy implementation of thread.start_new_thread(). Compatibility is maintained by making sure that ``args`` is a tuple and ``kwargs`` is a dictionary. If an exception is raised and it is SystemExit (which can be done by thread.exit()) it is caugh...
[ "Dummy", "implementation", "of", "thread", ".", "start_new_thread", "()", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/dummy_thread.py#L27-L56
[ "def", "start_new_thread", "(", "function", ",", "args", ",", "kwargs", "=", "{", "}", ")", ":", "if", "type", "(", "args", ")", "!=", "type", "(", "tuple", "(", ")", ")", ":", "raise", "TypeError", "(", "\"2nd arg must be a tuple\"", ")", "if", "type"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b