Skip to content

Instantly share code, notes, and snippets.

@rhyolight
Created September 19, 2016 17:20
Show Gist options
  • Save rhyolight/dfb3fb67a412088bbb9d7d6691a68b97 to your computer and use it in GitHub Desktop.
Save rhyolight/dfb3fb67a412088bbb9d7d6691a68b97 to your computer and use it in GitHub Desktop.
fursty@ubuntu:~/nupic$ ./scripts/run_nupic_tests.py
============================= test session starts ==============================
platform linux2 -- Python 2.7.10 -- pytest-2.5.1 -- /usr/bin/python
plugins: cov, xdist
collected 904 items / 1 errors / 5 skipped
==================================== 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:346: 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:60: 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())
args = [segment2]
self.assertRaises(ValueError, connections.synapsesForSegment, *args)
(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:125: 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([synapse1, synapse3],
list(connections.synapsesForSegment(segment)))
(numActiveConnected,
> numActivePotential) = connections.computeActivity([80, 81, 82], .5)
E TypeError: computeActivity() takes at least 6 arguments (3 given)
tests/unit/nupic/research/connections_test.py:150: TypeError
____________ 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:174: AttributeError
_____________________ 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 0
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:452: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 66729 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:507: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 66730 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())
inputVector = numpy.zeros(inputSize)
activeArray = numpy.zeros(nColumns)
sp.compute(inputVector, True, activeArray)
# This exact number of active columns is determined by the inhibition
# radius, which changes based on the random synapses (i.e. weird math).
self.assertGreater(len(activeArray.nonzero()[0]), 2)
> self.assertLess(len(activeArray.nonzero()[0]), 10)
E AssertionError: 20 not less than 10
tests/unit/nupic/research/spatial_pooler_unit_test.py:215: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 67206 called by run line 320 -> setUp
New seed generated as: 67206 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: 67208 called by run line 320 -> setUp
New seed generated as: 67208 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:235: AssertionError
------------------------------- Captured stdout --------------------------------
New seed generated as: 67209 called by run line 320 -> setUp
New seed generated as: 67209 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)
synapses = list(tm.connections.synapsesForSegment(activeSegment))
> self.assertEqual(4, len(synapses))
E AssertionError: 4 != 3
tests/unit/nupic/research/temporal_memory_test.py:557: AssertionError
_____ TemporalMemoryTest.testDestroySegmentsWithTooFewSynapsesToBeMatching _____
self = <tests.unit.nupic.research.temporal_memory_test.TemporalMemoryTest testMethod=testDestroySegmentsWithTooFewSynapsesToBeMatching>
def testDestroySegmentsWithTooFewSynapsesToBeMatching(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.2,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.02,
seed=42)
prevActiveColumns = [0]
prevActiveCells = [0, 1, 2, 3]
activeColumns = [2]
expectedActiveCell = 5
matchingSegment = tm.connections.createSegment(expectedActiveCell)
tm.connections.createSynapse(matchingSegment, prevActiveCells[0], .015)
tm.connections.createSynapse(matchingSegment, prevActiveCells[1], .015)
tm.connections.createSynapse(matchingSegment, prevActiveCells[2], .015)
tm.connections.createSynapse(matchingSegment, prevActiveCells[3], .015)
tm.compute(prevActiveColumns, True)
tm.compute(activeColumns, True)
> self.assertTrue(matchingSegment._destroyed)
E AttributeError: 'Segment' object has no attribute '_destroyed'
tests/unit/nupic/research/temporal_memory_test.py:744: AttributeError
__________ TemporalMemoryTest.testDestroyWeakSynapseOnActiveReinforce __________
self = <tests.unit.nupic.research.temporal_memory_test.TemporalMemoryTest testMethod=testDestroyWeakSynapseOnActiveReinforce>
def testDestroyWeakSynapseOnActiveReinforce(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.2,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.02,
seed=42)
previousActiveColumns = [0]
previousActiveCells = [0, 1, 2, 3]
activeColumns = [2]
activeCell = 5
activeSegment = tm.connections.createSegment(activeCell)
tm.connections.createSynapse(activeSegment, previousActiveCells[0], .5)
tm.connections.createSynapse(activeSegment, previousActiveCells[1], .5)
tm.connections.createSynapse(activeSegment, previousActiveCells[2], .5)
weakInactSynapse = tm.connections.createSynapse(activeSegment,
previousActiveCells[3],
.009)
tm.compute(previousActiveColumns, True)
tm.compute(activeColumns, True)
> self.assertTrue(weakInactSynapse._destroyed)
E AttributeError: 'Synapse' object has no attribute '_destroyed'
tests/unit/nupic/research/temporal_memory_test.py:629: AttributeError
__________ TemporalMemoryTest.testDestroyWeakSynapseOnWrongPrediction __________
self = <tests.unit.nupic.research.temporal_memory_test.TemporalMemoryTest testMethod=testDestroyWeakSynapseOnWrongPrediction>
def testDestroyWeakSynapseOnWrongPrediction(self):
tm = TemporalMemory(
columnDimensions=[32],
cellsPerColumn=4,
activationThreshold=3,
initialPermanence=.2,
connectedPermanence=.50,
minThreshold=2,
maxNewSynapseCount=4,
permanenceIncrement=.10,
permanenceDecrement=.10,
predictedSegmentDecrement=0.02,
seed=42)
previousActiveColumns = [0]
previousActiveCells = [0, 1, 2, 3]
activeColumns = [2]
expectedActiveCells = [5]
activeSegment = tm.connections.createSegment(expectedActiveCells[0])
tm.connections.createSynapse(activeSegment, previousActiveCells[0], .5)
tm.connections.createSynapse(activeSegment, previousActiveCells[1], .5)
tm.connections.createSynapse(activeSegment, previousActiveCells[2], .5)
weakActiveSynapse = tm.connections.createSynapse(activeSegment,
previousActiveCells[3],
.015)
tm.compute(previousActiveColumns, True)
tm.compute(activeColumns, True)
> self.assertTrue(weakActiveSynapse._destroyed)
E AttributeError: 'Synapse' object has no attribute '_destroyed'
tests/unit/nupic/research/temporal_memory_test.py:596: 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))
tm.reset()
tm.compute(prevActiveColumns3)
tm.compute(activeColumns)
self.assertEqual(2, tm.connections.numSegments(9))
self.assertEqual(3, tm.connections.numSynapses(oldestSegment))
presynapticCells = \
set(synapse.presynapticCell
> for synapse in tm.connections.synapsesForSegment(oldestSegment))
tests/unit/nupic/research/temporal_memory_test.py:709:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <listiterator object at 0x7fb471ea0e90>
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:709: 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)
synapseData = tm.connections.dataForSynapse(weakestSynapse)
self.assertNotEqual(0, synapseData.presynapticCell)
> self.assertFalse(synapseData._destroyed)
E AttributeError: 'SynapseData' object has no attribute '_destroyed'
tests/unit/nupic/research/temporal_memory_test.py:663: 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=(100,),
cellsPerColumn=4,
activationThreshold=7,
initialPermanence=0.37,
connectedPermanence=0.58,
minThreshold=4,
maxNewSynapseCount=18,
permanenceIncrement=0.23,
permanenceDecrement=0.08,
seed=91
)
# Run some data through before serializing
patternMachine = PatternMachine(100, 4)
sequenceMachine = SequenceMachine(patternMachine)
sequence = sequenceMachine.generateFromNumbers(range(5))
for _ in range(3):
for pattern in sequence:
tm1.compute(pattern)
proto1 = TemporalMemoryProto_capnp.TemporalMemoryProto.new_message()
> tm1.write(proto1)
tests/unit/nupic/research/temporal_memory_test.py:1030:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.research.temporal_memory.TemporalMemory object at 0x7fb471ea0990>
proto = <nupic.proto.TemporalMemoryProto_capnp:TemporalMemoryProto builder (cellsPerCo...rmanenceIncrement = 0, permanenceDecrement = 0, predictedSegmentDecrement = 0)>
def write(self, proto):
""" Writes serialized data to proto object
@param proto (DynamicStructBuilder) Proto object
"""
> proto.columnDimensions = self.columnDimensions
../.local/lib/python2.7/site-packages/nupic/research/temporal_memory.py:722:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> ???
capnp/lib/capnp.pyx:1240:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> ???
E AttributeError: 'NoneType' object has no attribute 'type'
capnp/lib/capnp.pyx:242: 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 0x7fb471e897d0>, [3, 4, 5], <function <lambda> at 0x7fb471e89848>, None, <function <lambda> at 0x7fb471e898c0>, ...)
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
../.local/lib/python2.7/site-packages/nupic/support/group_by.py:55: TypeError
========= 18 failed, 867 passed, 24 skipped, 1 error in 159.80 seconds =========
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment