Skip to content

Instantly share code, notes, and snippets.

@souravsingh
Created November 14, 2016 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save souravsingh/cb31ca09663912872dae281d19de6df7 to your computer and use it in GitHub Desktop.
Save souravsingh/cb31ca09663912872dae281d19de6df7 to your computer and use it in GitHub Desktop.
sourav@ubuntu:~/nupic$ py.test tests/unit
============================= test session starts ==============================
platform linux2 -- Python 2.7.12 -- pytest-2.5.1
plugins: xdist, cov
collected 906 items / 1 errors / 5 skipped
tests/unit/nupic/utils_test.py ......
tests/unit/nupic/algorithms/anomaly_likelihood_jeff_test.py ...ss..
tests/unit/nupic/algorithms/anomaly_likelihood_test.py ....................
tests/unit/nupic/algorithms/anomaly_test.py ..............
tests/unit/nupic/algorithms/cells4_test.py .
tests/unit/nupic/algorithms/cla_classifier_diff_test.py ...................
tests/unit/nupic/algorithms/cla_classifier_test.py ...................
tests/unit/nupic/algorithms/fast_cla_classifier_test.py ...................
tests/unit/nupic/algorithms/knn_classifier_test.py .........s..
tests/unit/nupic/algorithms/sdr_classifier_test.py .........................
tests/unit/nupic/algorithms/sp_overlap_test.py .s.s
tests/unit/nupic/algorithms/svm_test.py ..s
tests/unit/nupic/algorithms/tp10x2_test.py .
tests/unit/nupic/data/aggregator_test.py .
tests/unit/nupic/data/dictutils_test.py ......
tests/unit/nupic/data/fieldmeta_test.py .....
tests/unit/nupic/data/file_record_stream_test.py ......
tests/unit/nupic/data/filters_test.py s
tests/unit/nupic/data/functionsource_test.py ......
tests/unit/nupic/data/inference_shifter_test.py ........
tests/unit/nupic/data/record_stream_test.py .......
tests/unit/nupic/data/utils_test.py .......
tests/unit/nupic/data/generators/anomalyzer_test.py ...........
tests/unit/nupic/data/generators/pattern_machine_test.py .........
tests/unit/nupic/data/generators/sequence_machine_test.py .....
tests/unit/nupic/encoders/adaptivescalar_test.py .......
tests/unit/nupic/encoders/category_test.py ..
tests/unit/nupic/encoders/coordinate_test.py .................
tests/unit/nupic/encoders/date_test.py ........
tests/unit/nupic/encoders/delta_test.py .....
tests/unit/nupic/encoders/geospatial_coordinate_test.py ...........
tests/unit/nupic/encoders/logenc_test.py ......
tests/unit/nupic/encoders/multi_test.py ..
tests/unit/nupic/encoders/pass_through_encoder_test.py ....
tests/unit/nupic/encoders/random_distributed_scalar_test.py ...............
tests/unit/nupic/encoders/scalar_test.py .............
tests/unit/nupic/encoders/scalarspace_test.py .
tests/unit/nupic/encoders/sdrcategory_test.py ...
tests/unit/nupic/encoders/sparse_pass_through_encoder_test.py ....
tests/unit/nupic/engine/network_test.py ..........
tests/unit/nupic/engine/syntactic_sugar_test.py .....
tests/unit/nupic/engine/unified_py_parameter_test.py ..
tests/unit/nupic/frameworks/opf/clamodel_classifier_helper_test.py ......................
tests/unit/nupic/frameworks/opf/clamodel_test.py ......
tests/unit/nupic/frameworks/opf/opf_metrics_test.py ...............................
tests/unit/nupic/frameworks/opf/previous_value_model_test.py ......
tests/unit/nupic/frameworks/opf/safe_interpreter_test.py ........
tests/unit/nupic/frameworks/opf/two_gram_model_test.py .....
tests/unit/nupic/frameworks/opf/common_models/cluster_params_test.py .
tests/unit/nupic/math/array_algorithms_test.py ...
tests/unit/nupic/math/cast_mode_test.py s
tests/unit/nupic/math/lgamma_test.py .
tests/unit/nupic/math/nupic_random_test.py .............
tests/unit/nupic/math/sparse_binary_matrix_test.py .....................................s............
tests/unit/nupic/math/sparse_matrix_test.py ...s.........................................................................................
tests/unit/nupic/regions/anomaly_likelihood_region_test.py ...
tests/unit/nupic/regions/anomaly_region_test.py .
tests/unit/nupic/regions/knn_anomaly_classifier_region_test.py ....................
tests/unit/nupic/regions/record_sensor_region_test.py .
tests/unit/nupic/regions/regions_spec_test.py s...s......
tests/unit/nupic/research/connections_test.py F.FF..F.F..F..
tests/unit/nupic/research/inhibition_object_test.py s
tests/unit/nupic/research/sp_learn_inference_test.py s
tests/unit/nupic/research/spatial_pooler_boost_test.py ..
tests/unit/nupic/research/spatial_pooler_compatability_test.py ....ss...
tests/unit/nupic/research/spatial_pooler_compute_test.py ..
tests/unit/nupic/research/spatial_pooler_cpp_api_test.py ..............................
tests/unit/nupic/research/spatial_pooler_cpp_unit_test.py ....
tests/unit/nupic/research/spatial_pooler_py_api_test.py ..............................
tests/unit/nupic/research/spatial_pooler_unit_test.py s............F.....FF.......F....FFF
tests/unit/nupic/research/temporal_memory_test.py .F................FF.........sFF..Fs.
tests/unit/nupic/research/tp10x2_test.py ....
tests/unit/nupic/research/tp_constant_test.py ...
tests/unit/nupic/research/tp_test.py ....
tests/unit/nupic/research/monitor_mixin/metric_test.py ..
tests/unit/nupic/research/monitor_mixin/trace_test.py ..
tests/unit/nupic/support/configuration_test.py ............s....................
tests/unit/nupic/support/custom_configuration_test.py ...................s.........................
tests/unit/nupic/support/decorators_test.py ............
tests/unit/nupic/support/group_by_test.py ..F...
tests/unit/nupic/support/object_json_test.py ...............
tests/unit/nupic/support/consoleprinter_test/consoleprinter_test.py .
==================================== ERRORS ====================================
___________ ERROR collecting tests/unit/nupic/math/topology_test.py ____________
tests/unit/nupic/math/topology_test.py:27: in <module>
from nupic.math.topology import (coordinatesFromIndex,
E ImportError: No module named topology
=================================== FAILURES ===================================
_____________________ ConnectionsTest.testComputeActivity ______________________
self = <tests.unit.nupic.research.connections_test.ConnectionsTest testMethod=testComputeActivity>
def testComputeActivity(self):
""" Creates a sample set of connections, and makes sure that computing the
activity for a collection of cells with no activity returns the right
activity data.
"""
connections = Connections(1024)
# Cell with 1 segment.
# Segment with:
# - 1 connected synapse: active
# - 2 matching synapses
segment1a = connections.createSegment(10)
connections.createSynapse(segment1a, 150, .85)
connections.createSynapse(segment1a, 151, .15)
# Cell with 1 segment.
# Segment with:
# - 2 connected synapse: 2 active
# - 3 matching synapses: 3 active
segment2a = connections.createSegment(20)
connections.createSynapse(segment2a, 80, .85)
connections.createSynapse(segment2a, 81, .85)
synapse = connections.createSynapse(segment2a, 82, .85)
connections.updateSynapsePermanence(synapse, .15)
inputVec = [50, 52, 53, 80, 81, 82, 150, 151]
(numActiveConnected,
> numActivePotential) = connections.computeActivity(inputVec, .5)
E TypeError: computeActivity() takes at least 6 arguments (3 given)
tests/unit/nupic/research/connections_test.py:364: TypeError
____________________ ConnectionsTest.testCreateSegmentReuse ____________________
self = <tests.unit.nupic.research.connections_test.ConnectionsTest testMethod=testCreateSegmentReuse>
def testCreateSegmentReuse(self):
connections = Connections(1024, 2)
segment1 = connections.createSegment(42)
connections.createSynapse(segment1, 1, .5)
connections.createSynapse(segment1, 2, .5)
# Let some time pass.
> connections.startNewIteration();
E AttributeError: 'Connections' object has no attribute 'startNewIteration'
tests/unit/nupic/research/connections_test.py:58: AttributeError
______________________ ConnectionsTest.testDestroySegment ______________________
self = <tests.unit.nupic.research.connections_test.ConnectionsTest testMethod=testDestroySegment>
def testDestroySegment(self):
""" Creates a segment, destroys it, and makes sure it got destroyed along
with all of its synapses.
"""
connections = Connections(1024)
connections.createSegment(10)
segment2 = connections.createSegment(20)
connections.createSegment(30)
connections.createSegment(40)
connections.createSynapse(segment2, 80, 0.85)
connections.createSynapse(segment2, 81, 0.85)
connections.createSynapse(segment2, 82, 0.15)
self.assertEqual(4, connections.numSegments())
self.assertEqual(3, connections.numSynapses())
connections.destroySegment(segment2)
self.assertEqual(3, connections.numSegments())
self.assertEqual(0, connections.numSynapses())
(numActiveConnected,
> numActivePotential) = connections.computeActivity([80, 81, 82], 0.5)
E TypeError: computeActivity() takes at least 6 arguments (3 given)
tests/unit/nupic/research/connections_test.py:145: TypeError
______________________ ConnectionsTest.testDestroySynapse ______________________
self = <tests.unit.nupic.research.connections_test.ConnectionsTest testMethod=testDestroySynapse>
def testDestroySynapse(self):
""" Creates a segment, creates a number of synapses on it, destroys a
synapse, and makes sure it got destroyed.
"""
connections = Connections(1024)
segment = connections.createSegment(20)
synapse1 = connections.createSynapse(segment, 80, .85)
synapse2 = connections.createSynapse(segment, 81, .85)
synapse3 = connections.createSynapse(segment, 82, .15)
self.assertEqual(3, connections.numSynapses())
connections.destroySynapse(synapse2)
self.assertEqual(2, connections.numSynapses())
self.assertEqual(set([synapse1, synapse3]),
> connections.synapsesForSegment(segment))
E AssertionError: set([<nupic.research.connections.Synapse object at 0x7f6285c09fc8>, <nupic.research.connections.Synapse object at 0x7f6285c09dd0>]) != [<nupic.research.connections.Synapse object at 0x7f6285c09dd0>, <nupic.research.connections.Synapse object at 0x7f6285c09fc8>]
tests/unit/nupic/research/connections_test.py:168: AssertionError
____________ ConnectionsTest.testPathsNotInvalidatedByOtherDestroys ____________
self = <tests.unit.nupic.research.connections_test.ConnectionsTest testMethod=testPathsNotInvalidatedByOtherDestroys>
def testPathsNotInvalidatedByOtherDestroys(self):
""" Creates segments and synapses, then destroys segments and synapses on
either side of them and verifies that existing Segment and Synapse
instances still point to the same segment / synapse as before.
"""
connections = Connections(1024)
segment1 = connections.createSegment(11)
connections.createSegment(12)
segment3 = connections.createSegment(13)
connections.createSegment(14)
segment5 = connections.createSegment(15)
synapse1 = connections.createSynapse(segment3, 201, .85)
synapse2 = connections.createSynapse(segment3, 202, .85)
synapse3 = connections.createSynapse(segment3, 203, .85)
synapse4 = connections.createSynapse(segment3, 204, .85)
synapse5 = connections.createSynapse(segment3, 205, .85)
> self.assertEqual(203, synapse3.presynapticCell)
E AttributeError: 'Synapse' object has no attribute 'presynapticCell'
tests/unit/nupic/research/connections_test.py:194: AttributeError
_______________________ ConnectionsTest.testSynapseReuse _______________________
self = <tests.unit.nupic.research.connections_test.ConnectionsTest testMethod=testSynapseReuse>
def testSynapseReuse(self):
""" Creates a synapse over the synapses per segment limit, and verifies
that the lowest permanence synapse is removed to make room for the new
synapse.
"""
connections = Connections(1024, 1024, 2)
segment = connections.createSegment(10)
synapse1 = connections.createSynapse(segment, 50, .34)
synapse2 = connections.createSynapse(segment, 51, .48)
synapses = connections.synapsesForSegment(segment)
> self.assertEqual(set([synapse1, synapse2]), synapses)
E AssertionError: set([<nupic.research.connections.Synapse object at 0x7f6285bc4998>, <nupic.research.connections.Synapse object at 0x7f6285bc4ab8>]) != [<nupic.research.connections.Synapse object at 0x7f6285bc4998>, <nupic.research.connections.Synapse object at 0x7f6285bc4ab8>]
tests/unit/nupic/research/connections_test.py:108: AssertionError
__________________ SpatialPoolerTest.testInhibitColumnsLocal ___________________
self = <tests.unit.nupic.research.spatial_pooler_unit_test.SpatialPoolerTest testMethod=testInhibitColumnsLocal>
def testInhibitColumnsLocal(self):
sp = self._sp
density = 0.5
sp._numColumns = 10
sp._columnDimensions = numpy.array([sp._numColumns])
sp._inhibitionRadius = 2
overlaps = numpy.array([1, 2, 7, 0, 3, 4, 16, 1, 1.5, 1.7], dtype=realDType)
# L W W L L W W L W W (wrapAround=True)
# L W W L L W W L L W (wrapAround=False)
sp._wrapAround = True
trueActive = [1, 2, 5, 6, 8, 9]
active = list(sp._inhibitColumnsLocal(overlaps, density))
> self.assertListEqual(trueActive, sorted(active))
E AssertionError: Lists differ: [1, 2, 5, 6, 8, 9] != [1, 2, 5, 6, 9]
E
E First differing element 4:
E 8
E 9
E
E First list contains 1 additional elements.
E First extra element 5:
E 9
E
E - [1, 2, 5, 6, 8, 9]
E ? ---
E
E + [1, 2, 5, 6, 9]
tests/unit/nupic/research/spatial_pooler_unit_test.py:1435: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 87290 called by run line 320 -> setUp
_____________________ SpatialPoolerTest.testMapPotential1D _____________________
self = <tests.unit.nupic.research.spatial_pooler_unit_test.SpatialPoolerTest testMethod=testMapPotential1D>
def testMapPotential1D(self):
params = self._params.copy()
params.update({
"inputDimensions": [12],
"columnDimensions": [4],
"potentialRadius": 2,
"wrapAround": False
})
# Test without wrapAround and potentialPct = 1
params["potentialPct"] = 1
sp = SpatialPooler(**params)
expectedMask = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
mask = sp._mapPotential(0)
self.assertListEqual(mask.tolist(), expectedMask)
expectedMask = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0]
mask = sp._mapPotential(2)
self.assertListEqual(mask.tolist(), expectedMask)
# Test with wrapAround and potentialPct = 1
params["potentialPct"] = 1
params["wrapAround"] = True
sp = SpatialPooler(**params)
expectedMask = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1]
mask = sp._mapPotential(0)
> self.assertListEqual(mask.tolist(), expectedMask)
E AssertionError: Lists differ: [1L, 1L, 1L, 1L, 0L, 0L, 0L, 0... != [1, 1, 1, 1, 0, 0, 0, 0, 0, 0,...
E
E First differing element 11:
E 0L
E 1
E
E - [1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]
E ? - - - - - - - - - - - ^^
E
E + [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1]
E ? ^
tests/unit/nupic/research/spatial_pooler_unit_test.py:454: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 87292 called by run line 320 -> setUp
_____________________ SpatialPoolerTest.testMapPotential2D _____________________
self = <tests.unit.nupic.research.spatial_pooler_unit_test.SpatialPoolerTest testMethod=testMapPotential2D>
def testMapPotential2D(self):
params = self._params.copy()
params.update({
"columnDimensions": [2, 4],
"inputDimensions": [6, 12],
"potentialRadius": 1,
"potentialPct": 1,
"wrapAround": False,
})
# Test without wrapAround
sp = SpatialPooler(**params)
trueIndicies = [0, 12, 24,
1, 13, 25,
2, 14, 26]
mask = sp._mapPotential(0)
self.assertSetEqual(set(numpy.flatnonzero(mask).tolist()), set(trueIndicies))
trueIndicies = [6, 18, 30,
7, 19, 31,
8, 20, 32]
mask = sp._mapPotential(2)
self.assertSetEqual(set(numpy.flatnonzero(mask).tolist()), set(trueIndicies))
# Test with wrapAround
params.update({
"potentialRadius": 2,
"wrapAround": True,
})
sp = SpatialPooler(**params)
trueIndicies = [71, 11, 23, 35, 47,
60, 0, 12, 24, 36,
61, 1, 13, 25, 37,
62, 2, 14, 26, 38,
63, 3, 15, 27, 39]
mask = sp._mapPotential(0)
> self.assertSetEqual(set(numpy.flatnonzero(mask).tolist()), set(trueIndicies))
E AssertionError: Items in the second set but not the first:
E 35
E 71
E 11
E 47
E 23
E 60
E 61
E 62
E 63
tests/unit/nupic/research/spatial_pooler_unit_test.py:509: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 87293 called by run line 320 -> setUp
________________ SpatialPoolerTest.testUpdateMinDutyCycleLocal _________________
self = <tests.unit.nupic.research.spatial_pooler_unit_test.SpatialPoolerTest testMethod=testUpdateMinDutyCycleLocal>
def testUpdateMinDutyCycleLocal(self):
# wrapAround=False
sp = SpatialPooler(inputDimensions=(5,),
columnDimensions=(8,),
globalInhibition=False,
wrapAround=False)
sp.setInhibitionRadius(1)
sp.setOverlapDutyCycles([0.7, 0.1, 0.5, 0.01, 0.78, 0.55, 0.1, 0.001])
sp.setActiveDutyCycles([0.9, 0.3, 0.5, 0.7, 0.1, 0.01, 0.08, 0.12])
sp.setMinPctActiveDutyCycles(0.1);
sp.setMinPctOverlapDutyCycles(0.2);
sp._updateMinDutyCyclesLocal()
resultMinActiveDutyCycles = numpy.zeros(sp.getNumColumns())
sp.getMinActiveDutyCycles(resultMinActiveDutyCycles)
for actual, expected in zip(resultMinActiveDutyCycles,
[0.09, 0.09, 0.07, 0.07, 0.07, 0.01, 0.012, 0.012]):
self.assertAlmostEqual(actual, expected)
resultMinOverlapDutyCycles = numpy.zeros(sp.getNumColumns())
sp.getMinOverlapDutyCycles(resultMinOverlapDutyCycles)
for actual, expected in zip(resultMinOverlapDutyCycles,
[0.14, 0.14, 0.1, 0.156, 0.156, 0.156, 0.11, 0.02]):
self.assertAlmostEqual(actual, expected)
# wrapAround=True
sp = SpatialPooler(inputDimensions=(5,),
columnDimensions=(8,),
globalInhibition=False,
wrapAround=True)
sp.setInhibitionRadius(1)
sp.setOverlapDutyCycles([0.7, 0.1, 0.5, 0.01, 0.78, 0.55, 0.1, 0.001])
sp.setActiveDutyCycles([0.9, 0.3, 0.5, 0.7, 0.1, 0.01, 0.08, 0.12])
sp.setMinPctActiveDutyCycles(0.1);
sp.setMinPctOverlapDutyCycles(0.2);
sp._updateMinDutyCyclesLocal()
resultMinActiveDutyCycles = numpy.zeros(sp.getNumColumns())
sp.getMinActiveDutyCycles(resultMinActiveDutyCycles)
for actual, expected in zip(resultMinActiveDutyCycles,
[0.09, 0.09, 0.07, 0.07, 0.07, 0.01, 0.012, 0.09]):
> self.assertAlmostEqual(actual, expected)
E AssertionError: 0.012000000104308128 != 0.09 within 7 places
tests/unit/nupic/research/spatial_pooler_unit_test.py:981: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 87295 called by run line 320 -> setUp
____ SpatialPoolerTest.testZeroOverlap_NoStimulusThreshold_LocalInhibition _____
self = <tests.unit.nupic.research.spatial_pooler_unit_test.SpatialPoolerTest testMethod=testZeroOverlap_NoStimulusThreshold_LocalInhibition>
def testZeroOverlap_NoStimulusThreshold_LocalInhibition(self):
"""When stimulusThreshold is 0, allow columns without any overlap to become
active. This test focuses on the local inhibition code path."""
inputSize = 10
nColumns = 20
sp = SpatialPooler(inputDimensions=[inputSize],
columnDimensions=[nColumns],
potentialRadius=5,
globalInhibition=False,
numActiveColumnsPerInhArea=1,
stimulusThreshold=0,
seed=getSeed())
# This exact number of active columns is determined by the inhibition
# radius, which changes based on the random synapses (i.e. weird math).
# Force it to a known number.
sp.setInhibitionRadius(2);
inputVector = numpy.zeros(inputSize)
activeArray = numpy.zeros(nColumns)
sp.compute(inputVector, True, activeArray)
> self.assertEqual(len(activeArray.nonzero()[0]), 6)
E AssertionError: 20 != 6
tests/unit/nupic/research/spatial_pooler_unit_test.py:217: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 87708 called by run line 320 -> setUp
New seed generated as: 87708 called by run line 329 -> testZeroOverlap_NoStimulusThreshold_LocalInhibition
_____ SpatialPoolerTest.testZeroOverlap_StimulusThreshold_GlobalInhibition _____
self = <tests.unit.nupic.research.spatial_pooler_unit_test.SpatialPoolerTest testMethod=testZeroOverlap_StimulusThreshold_GlobalInhibition>
def testZeroOverlap_StimulusThreshold_GlobalInhibition(self):
"""When stimulusThreshold is > 0, don't allow columns without any overlap to
become active. This test focuses on the global inhibition code path."""
inputSize = 10
nColumns = 20
sp = SpatialPooler(inputDimensions=[inputSize],
columnDimensions=[nColumns],
potentialRadius=10,
globalInhibition=True,
numActiveColumnsPerInhArea=3,
stimulusThreshold=1,
seed=getSeed())
inputVector = numpy.zeros(inputSize)
activeArray = numpy.zeros(nColumns)
sp.compute(inputVector, True, activeArray)
> self.assertEqual(0, len(activeArray.nonzero()[0]))
E AssertionError: 0 != 3
tests/unit/nupic/research/spatial_pooler_unit_test.py:192: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 87709 called by run line 320 -> setUp
New seed generated as: 87709 called by run line 329 -> testZeroOverlap_StimulusThreshold_GlobalInhibition
_____ SpatialPoolerTest.testZeroOverlap_StimulusThreshold_LocalInhibition ______
self = <tests.unit.nupic.research.spatial_pooler_unit_test.SpatialPoolerTest testMethod=testZeroOverlap_StimulusThreshold_LocalInhibition>
def testZeroOverlap_StimulusThreshold_LocalInhibition(self):
"""When stimulusThreshold is > 0, don't allow columns without any overlap to
become active. This test focuses on the local inhibition code path."""
inputSize = 10
nColumns = 20
sp = SpatialPooler(inputDimensions=[inputSize],
columnDimensions=[nColumns],
potentialRadius=10,
globalInhibition=False,
numActiveColumnsPerInhArea=3,
stimulusThreshold=1,
seed=getSeed())
inputVector = numpy.zeros(inputSize)
activeArray = numpy.zeros(nColumns)
sp.compute(inputVector, True, activeArray)
> self.assertEqual(0, len(activeArray.nonzero()[0]))
E AssertionError: 0 != 20
tests/unit/nupic/research/spatial_pooler_unit_test.py:237: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 87710 called by run line 320 -> setUp
New seed generated as: 87710 called by run line 329 -> testZeroOverlap_StimulusThreshold_LocalInhibition
_ TemporalMemoryTest.testActiveSegmentGrowSynapsesAccordingToPotentialOverlap __
self = <tests.unit.nupic.research.temporal_memory_test.TemporalMemoryTest testMethod=testActiveSegmentGrowSynapsesAccordingToPotentialOverlap>
def testActiveSegmentGrowSynapsesAccordingToPotentialOverlap(self):
"""
When a segment becomes active, grow synapses to previous winner cells.
The number of grown synapses is calculated from the "matching segment"
overlap, not the "active segment" overlap.
"""
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=1,
activationThreshold=2,
initialPermanence=.21,
connectedPermanence=.50,
minThreshold=1,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.0,
seed=42)
# Use 1 cell per column so that we have easy control over the winner cells.
previousActiveColumns = [0, 1, 2, 3, 4]
prevWinnerCells = [0, 1, 2, 3, 4]
activeColumns = [5]
activeSegment = tm.connections.createSegment(5)
tm.connections.createSynapse(activeSegment, 0, .5)
tm.connections.createSynapse(activeSegment, 1, .5)
tm.connections.createSynapse(activeSegment, 2, .2)
tm.compute(previousActiveColumns, True)
self.assertEqual(prevWinnerCells, tm.getWinnerCells())
tm.compute(activeColumns, True)
presynapticCells = set(synapse.presynapticCell for synapse in
> tm.connections.synapsesForSegment(activeSegment))
tests/unit/nupic/research/temporal_memory_test.py:559:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <listiterator object at 0x7f6285b545d0>
> presynapticCells = set(synapse.presynapticCell for synapse in
tm.connections.synapsesForSegment(activeSegment))
E AttributeError: 'Synapse' object has no attribute 'presynapticCell'
tests/unit/nupic/research/temporal_memory_test.py:558: AttributeError
_______________ TemporalMemoryTest.testMaxSegmentsPerCellGetter ________________
self = <tests.unit.nupic.research.temporal_memory_test.TemporalMemoryTest testMethod=testMaxSegmentsPerCellGetter>
def testMaxSegmentsPerCellGetter(self):
tm = TemporalMemory(
columnDimensions=[64,64],
cellsPerColumn=32,
maxSegmentsPerCell=200
)
> self.assertEqual(tm.getMaxSegmentsPerCell(), 200)
E AttributeError: 'TemporalMemory' object has no attribute 'getMaxSegmentsPerCell'
tests/unit/nupic/research/temporal_memory_test.py:1008: AttributeError
______________ TemporalMemoryTest.testMaxSynapsesPerSegmentGetter ______________
self = <tests.unit.nupic.research.temporal_memory_test.TemporalMemoryTest testMethod=testMaxSynapsesPerSegmentGetter>
def testMaxSynapsesPerSegmentGetter(self):
tm = TemporalMemory(
columnDimensions=[32,32],
cellsPerColumn=16,
maxSynapsesPerSegment=150
)
> self.assertEqual(tm.getMaxSynapsesPerSegment(), 150)
E AttributeError: 'TemporalMemory' object has no attribute 'getMaxSynapsesPerSegment'
tests/unit/nupic/research/temporal_memory_test.py:1017: AttributeError
TemporalMemoryTest.testRecycleLeastRecentlyActiveSegmentToMakeRoomForNewSegment
self = <tests.unit.nupic.research.temporal_memory_test.TemporalMemoryTest testMethod=testRecycleLeastRecentlyActiveSegmentToMakeRoomForNewSegment>
def testRecycleLeastRecentlyActiveSegmentToMakeRoomForNewSegment(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=1,
activationThreshold=3,
initialPermanence=.50,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=3,
permanenceIncrement=.02,
permanenceDecrement=.02,
predictedSegmentDecrement=0.0,
seed=42,
maxSegmentsPerCell=2)
prevActiveColumns1 = [0, 1, 2]
prevActiveColumns2 = [3, 4, 5]
prevActiveColumns3 = [6, 7, 8]
activeColumns = [9]
tm.compute(prevActiveColumns1)
tm.compute(activeColumns)
self.assertEqual(1, tm.connections.numSegments(9))
oldestSegment = list(tm.connections.segmentsForCell(9))[0]
tm.reset()
tm.compute(prevActiveColumns2)
tm.compute(activeColumns)
self.assertEqual(2, tm.connections.numSegments(9))
oldPresynaptic = \
set(synapse.presynapticCell
> for synapse in tm.connections.synapsesForSegment(oldestSegment))
tests/unit/nupic/research/temporal_memory_test.py:697:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <listiterator object at 0x7f6285b4f650>
set(synapse.presynapticCell
> for synapse in tm.connections.synapsesForSegment(oldestSegment))
E AttributeError: 'Synapse' object has no attribute 'presynapticCell'
tests/unit/nupic/research/temporal_memory_test.py:697: AttributeError
_____ TemporalMemoryTest.testRecycleWeakestSynapseToMakeRoomForNewSynapse ______
self = <tests.unit.nupic.research.temporal_memory_test.TemporalMemoryTest testMethod=testRecycleWeakestSynapseToMakeRoomForNewSynapse>
def testRecycleWeakestSynapseToMakeRoomForNewSynapse(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=1,
activationThreshold=3,
initialPermanence=.21,
connectedPermanence=.50,
minThreshold=1,
maxNewSynapseCount=3,
permanenceIncrement=.02,
permanenceDecrement=.02,
predictedSegmentDecrement=0.0,
seed=42,
maxSynapsesPerSegment=3)
prevActiveColumns = [0, 1, 2]
prevWinnerCells = [0, 1, 2]
activeColumns = [4]
matchingSegment = tm.connections.createSegment(4)
tm.connections.createSynapse(matchingSegment, 81, .6)
weakestSynapse = tm.connections.createSynapse(matchingSegment, 0, .11)
tm.compute(prevActiveColumns)
self.assertEqual(prevWinnerCells, tm.getWinnerCells())
tm.compute(activeColumns)
synapses = tm.connections.synapsesForSegment(matchingSegment)
self.assertEqual(3, len(synapses))
> presynapticCells = set(synapse.presynapticCell for synapse in synapses)
tests/unit/nupic/research/temporal_memory_test.py:660:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <listiterator object at 0x7f6285b54e50>
> presynapticCells = set(synapse.presynapticCell for synapse in synapses)
E AttributeError: 'Synapse' object has no attribute 'presynapticCell'
tests/unit/nupic/research/temporal_memory_test.py:660: AttributeError
_______________________ TemporalMemoryTest.testWriteRead _______________________
self = <tests.unit.nupic.research.temporal_memory_test.TemporalMemoryTest testMethod=testWriteRead>
@unittest.skipUnless(
capnp, "pycapnp is not installed, skipping serialization test.")
def testWriteRead(self):
tm1 = TemporalMemory(
columnDimensions=(32,),
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=0.21,
connectedPermanence=0.50,
minThreshold=2,
maxNewSynapseCount=3,
permanenceIncrement=0.1,
permanenceDecrement=0.1,
predictedSegmentDecrement=0.0,
seed=42
)
> self.serializationTestPrepare(tm1)
tests/unit/nupic/research/temporal_memory_test.py:1128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.unit.nupic.research.temporal_memory_test.TemporalMemoryTest testMethod=testWriteRead>
tm = <nupic.research.temporal_memory.TemporalMemory object at 0x7f6285ae2750>
def serializationTestPrepare(self, tm):
# Create an active segment and two matching segments.
# Destroy a few to exercise the code.
destroyMe1 = tm.connections.createSegment(4)
tm.connections.destroySegment(destroyMe1)
activeSegment = tm.connections.createSegment(4)
tm.connections.createSynapse(activeSegment, 0, 0.5)
tm.connections.createSynapse(activeSegment, 1, 0.5)
destroyMe2 = tm.connections.createSynapse(activeSegment, 42, 0.5)
tm.connections.destroySynapse(destroyMe2)
tm.connections.createSynapse(activeSegment, 2, 0.5)
tm.connections.createSynapse(activeSegment, 3, 0.5)
matchingSegment1 = tm.connections.createSegment(8)
tm.connections.createSynapse(matchingSegment1, 0, 0.4)
tm.connections.createSynapse(matchingSegment1, 1, 0.4)
tm.connections.createSynapse(matchingSegment1, 2, 0.4)
matchingSegment2 = tm.connections.createSegment(9)
tm.connections.createSynapse(matchingSegment2, 0, 0.4)
tm.connections.createSynapse(matchingSegment2, 1, 0.4)
tm.connections.createSynapse(matchingSegment2, 2, 0.4)
tm.connections.createSynapse(matchingSegment2, 3, 0.4)
tm.compute([0])
> self.assertEqual(len(tm.getActiveSegments()), 1)
E AttributeError: 'TemporalMemory' object has no attribute 'getActiveSegments'
tests/unit/nupic/research/temporal_memory_test.py:1047: AttributeError
_____________________________ GroupByTest.testNone _____________________________
self = <tests.unit.nupic.support.group_by_test.GroupByTest testMethod=testNone>
def testNone(self):
sequence0 = None
sequence1 = [3, 4, 5]
sequence2 = None
sequence3 = [3, 3, 4, 5]
sequence4 = None
identity = lambda x: int(x)
times3 = lambda x: int(3 * x)
times4 = lambda x: int(4 * x)
times5 = lambda x: int(5 * x)
times6 = lambda x: int(6 * x)
expectedValues = [(9, None, [3], None, None, None),
(12, None, [4], None, None, None),
(15, None, [5], None, [3, 3], None),
(20, None, None, None, [4], None),
(25, None, None, None, [5], None)]
i = 0
for data in groupby2(sequence0, identity,
sequence1, times3,
sequence2, times4,
sequence3, times5,
> sequence4, times6):
tests/unit/nupic/support/group_by_test.py:187:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (None, <function <lambda> at 0x7f6285992c08>, [3, 4, 5], <function <lambda> at 0x7f627fbb4398>, None, <function <lambda> at 0x7f627fbb4488>, ...)
generatorList = [], i = 0, listn = None
def groupby2(*args):
""" An extension to groupby in itertools. Allows to walk across n sorted lists
with respect to their key functions and yields a tuple of n lists of the
members of the next *smallest* group.
@param args (list) a list of arguments alternating between sorted lists and
their respective key functions. The lists should be
sorted with respect to their key function.
@return (tuple) a n + 1 dimensional tuple, where the first element is the
key of the group and the other n entries are lists of
objects that are a member of the current group that is being
iterated over in the nth list passed in. Note that this
is a generator and a n+1 dimensional tuple is yielded for
every group. If a list has no members in the current
group, None is returned in place of a generator.
Notes: Read up on groupby here:
https://docs.python.org/dev/library/itertools.html#itertools.groupby
"""
generatorList = [] # list of each list's (k, group) tuples
if len(args) % 2 == 1:
raise ValueError("Must have a key function for every list.")
# populate above lists
for i in xrange(0, len(args), 2):
listn = args[i]
fn = args[i + 1]
> generatorList.append(groupby(listn, fn))
E TypeError: 'NoneType' object is not iterable
../miniconda2/lib/python2.7/site-packages/nupic/support/group_by.py:55: TypeError
========= 20 failed, 865 passed, 26 skipped, 1 error in 163.39 seconds =========
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment