Skip to content

Instantly share code, notes, and snippets.

@paulscode
Created September 8, 2018 23:54
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 paulscode/38e5c7c3fd08bbea48a51903cf9ac9c4 to your computer and use it in GitHub Desktop.
Save paulscode/38e5c7c3fd08bbea48a51903cf9ac9c4 to your computer and use it in GitHub Desktop.
nupic tests, Raspbian Stretch, attempt #2
============================= test session starts ==============================
platform linux2 -- Python 2.7.13, pytest-3.0.7, py-1.6.0, pluggy-0.4.0
rootdir: /home/pi/nupic, inifile:
plugins: xdist-1.16.0, cov-2.5.0
collected 738 items
tests/unit/nupic/serializable_test.py ...
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/backtracking_tm_constant_test.py *** Synapse consistency checking turned on for Cells4 ***
.*** Synapse consistency checking turned on for Cells4 ***
.*** Synapse consistency checking turned on for Cells4 ***
.
tests/unit/nupic/algorithms/backtracking_tm_cpp2_test.py *** Synapse consistency checking turned on for Cells4 ***
*** Python segment match turned on for Cells4
.
tests/unit/nupic/algorithms/backtracking_tm_cpp_test.py ....FFF
tests/unit/nupic/algorithms/backtracking_tm_test.py ....FFF
tests/unit/nupic/algorithms/connections_test.py .........
tests/unit/nupic/algorithms/inhibition_object_test.py s
tests/unit/nupic/algorithms/knn_classifier_test.py .........s...
tests/unit/nupic/algorithms/sdr_classifier_test.py ............................
tests/unit/nupic/algorithms/sp_learn_inference_test.py s
tests/unit/nupic/algorithms/sp_overlap_test.py .s.s
tests/unit/nupic/algorithms/spatial_pooler_boost_test.py ..
tests/unit/nupic/algorithms/spatial_pooler_compatability_test.py ...ss....
tests/unit/nupic/algorithms/spatial_pooler_compute_test.py ..
tests/unit/nupic/algorithms/spatial_pooler_cpp_api_test.py ............................
tests/unit/nupic/algorithms/spatial_pooler_cpp_unit_test.py .....
tests/unit/nupic/algorithms/spatial_pooler_py_api_test.py ............................
tests/unit/nupic/algorithms/spatial_pooler_unit_test.py s..............................F....
tests/unit/nupic/algorithms/temporal_memory_test.py ...............................s.....s.
tests/unit/nupic/algorithms/monitor_mixin/metric_test.py ..
tests/unit/nupic/algorithms/monitor_mixin/trace_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/docs/examples_test.py .xx.xxxxxx
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 ......F..FF
tests/unit/nupic/engine/syntactic_sugar_test.py .F...
tests/unit/nupic/engine/unified_py_parameter_test.py ..
tests/unit/nupic/frameworks/opf/htmpredictionmodel_classifier_helper_test.py ......................
tests/unit/nupic/frameworks/opf/htmpredictionmodel_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/lgamma_test.py .
tests/unit/nupic/math/topology_test.py ....................
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/knn_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/regions/sdr_classifier_region_test.py ..
tests/unit/nupic/regions/tm_region_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 ......
tests/unit/nupic/support/object_json_test.py ...............
tests/unit/nupic/support/consoleprinter_test/consoleprinter_test.py .
=================================== FAILURES ===================================
_________________ BacktrackingTMTest.testSerializationLearned __________________
self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationLearned>
@unittest.skipUnless(capnp, "pycapnp not installed")
def testSerializationLearned(self):
# Create a model and give it some inputs to learn.
tm1 = BacktrackingTM(numberOfCols=100, cellsPerColumn=12,
verbosity=VERBOSITY)
sequences = [self.generateSequence() for _ in xrange(5)]
train = list(itertools.chain.from_iterable(sequences[:3]))
for bottomUpInput in train:
if bottomUpInput is None:
tm1.reset()
else:
tm1.compute(bottomUpInput, True, True)
# Serialize and deserialized the TM.
tmProto = BacktrackingTM.getSchema().new_message()
tm1.write(tmProto)
checkpointPath = os.path.join(self._tmpDir, 'a')
with open(checkpointPath, "wb") as f:
tmProto.write(f)
with open(checkpointPath, "rb") as f:
tmProto = BacktrackingTM.getSchema().read(f)
tm2 = BacktrackingTM.read(tmProto)
# Check that the TMs are the same.
> self.assertTMsEqual(tm1, tm2)
tests/unit/nupic/algorithms/backtracking_tm_test.py:89:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
self.assertEqual(tm1, tm2, tm1.diff(tm2))
E AssertionError: <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x734c5330> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x734c51f0> : [(('maxSynapsesPerSegment',), -1, -1L), (('maxSegmentsPerCell',), -1, -1L), (('seed',), 42, 42L)]
----------------------------- Captured stdout call -----------------------------
<nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73f372a8> >
_____________ BacktrackingTMTest.testSerializationMiddleOfSequence _____________
self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationMiddleOfSequence>
@unittest.skipUnless(capnp, "pycapnp not installed")
def testSerializationMiddleOfSequence(self):
# Create a model and give it some inputs to learn.
tm1 = BacktrackingTM(numberOfCols=100, cellsPerColumn=12,
verbosity=VERBOSITY)
sequences = [self.generateSequence() for _ in xrange(5)]
train = list(itertools.chain.from_iterable(sequences[:3] +
[sequences[3][:5]]))
for bottomUpInput in train:
if bottomUpInput is None:
tm1.reset()
else:
tm1.compute(bottomUpInput, True, True)
# Serialize and deserialized the TM.
tmProto = BacktrackingTM.getSchema().new_message()
tm1.write(tmProto)
checkpointPath = os.path.join(self._tmpDir, 'a')
with open(checkpointPath, "wb") as f:
tmProto.write(f)
with open(checkpointPath, "rb") as f:
tmProto = BacktrackingTM.getSchema().read(f)
tm2 = BacktrackingTM.read(tmProto)
# Check that the TMs are the same.
> self.assertTMsEqual(tm1, tm2)
tests/unit/nupic/algorithms/backtracking_tm_test.py:130:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
self.assertEqual(tm1, tm2, tm1.diff(tm2))
E AssertionError: <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x73ee0750> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x73ee07b0> : [(('maxSynapsesPerSegment',), -1, -1L), (('maxSegmentsPerCell',), -1, -1L), (('seed',), 42, 42L)]
----------------------------- Captured stdout call -----------------------------
<nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73eef668> >
____________ BacktrackingTMTest.testSerializationMiddleOfSequence2 _____________
self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationMiddleOfSequence2>
@unittest.skipUnless(capnp, "pycapnp not installed")
def testSerializationMiddleOfSequence2(self):
"""More complex test of checkpointing in the middle of a sequence."""
tm1 = BacktrackingTM(2048, 32, 0.21, 0.5, 11, 20, 0.1, 0.1, 1.0, 0.0, 14,
False, 5, 2, False, 1960, 0, False, 3, 10, 5, 0, 32,
128, 32, 'normal')
tm2 = BacktrackingTM(2048, 32, 0.21, 0.5, 11, 20, 0.1, 0.1, 1.0, 0.0, 14,
False, 5, 2, False, 1960, 0, False, 3, 10, 5, 0, 32,
128, 32, 'normal')
with open(resource_filename(__name__, 'data/tm_input.csv'), 'r') as fin:
reader = csv.reader(fin)
records = []
for bottomUpInStr in fin:
bottomUpIn = numpy.array(eval('[' + bottomUpInStr.strip() + ']'),
dtype='int32')
records.append(bottomUpIn)
i = 1
for r in records[:250]:
print i
i += 1
output1 = tm1.compute(r, True, True)
output2 = tm2.compute(r, True, True)
self.assertTrue(numpy.array_equal(output1, output2))
print 'Serializing and deserializing models.'
savePath1 = os.path.join(self._tmpDir, 'tm1.bin')
tmProto1 = BacktrackingTM.getSchema().new_message()
tm1.write(tmProto1)
with open(savePath1, "wb") as f:
tmProto1.write(f)
with open(savePath1, "rb") as f:
tmProto3 = BacktrackingTM.getSchema().read(f)
tm3 = BacktrackingTM.read(tmProto3)
savePath2 = os.path.join(self._tmpDir, 'tm2.bin')
tmProto2 = BacktrackingTM.getSchema().new_message()
tm2.write(tmProto2)
with open(savePath2, "wb") as f:
tmProto2.write(f)
with open(savePath2, "rb") as f:
tmProto4 = BacktrackingTM.getSchema().read(f)
tm4 = BacktrackingTM.read(tmProto4)
> self.assertTMsEqual(tm1, tm3)
tests/unit/nupic/algorithms/backtracking_tm_test.py:193:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
self.assertEqual(tm1, tm2, tm1.diff(tm2))
E AssertionError: <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x738eff70> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x73ee07b0> : [(('maxSynapsesPerSegment',), 32, 32L), (('maxSegmentsPerCell',), 128, 128L), (('seed',), 1960, 1960L)]
----------------------------- Captured stdout call -----------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
Serializing and deserializing models.
<nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73e9e5d8> >
<nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73e9e710> >
_________________ BacktrackingTMTest.testSerializationLearned __________________
self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationLearned>
@unittest.skipUnless(capnp, "pycapnp not installed")
def testSerializationLearned(self):
# Create a model and give it some inputs to learn.
tm1 = BacktrackingTM(numberOfCols=100, cellsPerColumn=12,
verbosity=VERBOSITY)
sequences = [self.generateSequence() for _ in xrange(5)]
train = list(itertools.chain.from_iterable(sequences[:3]))
for bottomUpInput in train:
if bottomUpInput is None:
tm1.reset()
else:
tm1.compute(bottomUpInput, True, True)
# Serialize and deserialized the TM.
tmProto = BacktrackingTM.getSchema().new_message()
tm1.write(tmProto)
checkpointPath = os.path.join(self._tmpDir, 'a')
with open(checkpointPath, "wb") as f:
tmProto.write(f)
with open(checkpointPath, "rb") as f:
tmProto = BacktrackingTM.getSchema().read(f)
tm2 = BacktrackingTM.read(tmProto)
# Check that the TMs are the same.
> self.assertTMsEqual(tm1, tm2)
tests/unit/nupic/algorithms/backtracking_tm_test.py:89:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
self.assertEqual(tm1, tm2, tm1.diff(tm2))
E AssertionError: <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x73ee0190> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x73ee0170> : [(('maxSynapsesPerSegment',), -1, -1L), (('maxSegmentsPerCell',), -1, -1L), (('seed',), 42, 42L)]
----------------------------- Captured stdout call -----------------------------
<nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73eef530> >
_____________ BacktrackingTMTest.testSerializationMiddleOfSequence _____________
self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationMiddleOfSequence>
@unittest.skipUnless(capnp, "pycapnp not installed")
def testSerializationMiddleOfSequence(self):
# Create a model and give it some inputs to learn.
tm1 = BacktrackingTM(numberOfCols=100, cellsPerColumn=12,
verbosity=VERBOSITY)
sequences = [self.generateSequence() for _ in xrange(5)]
train = list(itertools.chain.from_iterable(sequences[:3] +
[sequences[3][:5]]))
for bottomUpInput in train:
if bottomUpInput is None:
tm1.reset()
else:
tm1.compute(bottomUpInput, True, True)
# Serialize and deserialized the TM.
tmProto = BacktrackingTM.getSchema().new_message()
tm1.write(tmProto)
checkpointPath = os.path.join(self._tmpDir, 'a')
with open(checkpointPath, "wb") as f:
tmProto.write(f)
with open(checkpointPath, "rb") as f:
tmProto = BacktrackingTM.getSchema().read(f)
tm2 = BacktrackingTM.read(tmProto)
# Check that the TMs are the same.
> self.assertTMsEqual(tm1, tm2)
tests/unit/nupic/algorithms/backtracking_tm_test.py:130:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
self.assertEqual(tm1, tm2, tm1.diff(tm2))
E AssertionError: <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x739c7f70> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x5f9a7210> : [(('maxSynapsesPerSegment',), -1, -1L), (('maxSegmentsPerCell',), -1, -1L), (('seed',), 42, 42L)]
----------------------------- Captured stdout call -----------------------------
<nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73eefc50> >
____________ BacktrackingTMTest.testSerializationMiddleOfSequence2 _____________
self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationMiddleOfSequence2>
@unittest.skipUnless(capnp, "pycapnp not installed")
def testSerializationMiddleOfSequence2(self):
"""More complex test of checkpointing in the middle of a sequence."""
tm1 = BacktrackingTM(2048, 32, 0.21, 0.5, 11, 20, 0.1, 0.1, 1.0, 0.0, 14,
False, 5, 2, False, 1960, 0, False, 3, 10, 5, 0, 32,
128, 32, 'normal')
tm2 = BacktrackingTM(2048, 32, 0.21, 0.5, 11, 20, 0.1, 0.1, 1.0, 0.0, 14,
False, 5, 2, False, 1960, 0, False, 3, 10, 5, 0, 32,
128, 32, 'normal')
with open(resource_filename(__name__, 'data/tm_input.csv'), 'r') as fin:
reader = csv.reader(fin)
records = []
for bottomUpInStr in fin:
bottomUpIn = numpy.array(eval('[' + bottomUpInStr.strip() + ']'),
dtype='int32')
records.append(bottomUpIn)
i = 1
for r in records[:250]:
print i
i += 1
output1 = tm1.compute(r, True, True)
output2 = tm2.compute(r, True, True)
self.assertTrue(numpy.array_equal(output1, output2))
print 'Serializing and deserializing models.'
savePath1 = os.path.join(self._tmpDir, 'tm1.bin')
tmProto1 = BacktrackingTM.getSchema().new_message()
tm1.write(tmProto1)
with open(savePath1, "wb") as f:
tmProto1.write(f)
with open(savePath1, "rb") as f:
tmProto3 = BacktrackingTM.getSchema().read(f)
tm3 = BacktrackingTM.read(tmProto3)
savePath2 = os.path.join(self._tmpDir, 'tm2.bin')
tmProto2 = BacktrackingTM.getSchema().new_message()
tm2.write(tmProto2)
with open(savePath2, "wb") as f:
tmProto2.write(f)
with open(savePath2, "rb") as f:
tmProto4 = BacktrackingTM.getSchema().read(f)
tm4 = BacktrackingTM.read(tmProto4)
> self.assertTMsEqual(tm1, tm3)
tests/unit/nupic/algorithms/backtracking_tm_test.py:193:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
self.assertEqual(tm1, tm2, tm1.diff(tm2))
E AssertionError: <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x7355dcd0> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x73ee02f0> : [(('maxSynapsesPerSegment',), 32, 32L), (('maxSegmentsPerCell',), 128, 128L), (('seed',), 1960, 1960L)]
----------------------------- Captured stdout call -----------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
Serializing and deserializing models.
<nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73eef2f0> >
<nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73eef050> >
_______________________ SpatialPoolerTest.testWriteRead ________________________
self = <tests.unit.nupic.algorithms.spatial_pooler_unit_test.SpatialPoolerTest testMethod=testWriteRead>
@unittest.skipUnless(
capnp, "pycapnp is not installed, skipping serialization test.")
def testWriteRead(self):
sp1 = SpatialPooler(
inputDimensions=[9],
columnDimensions=[5],
potentialRadius=3,
potentialPct=0.5,
globalInhibition=False,
localAreaDensity=-1.0,
numActiveColumnsPerInhArea=3,
stimulusThreshold=1,
synPermInactiveDec=0.01,
synPermActiveInc=0.1,
synPermConnected=0.10,
minPctOverlapDutyCycle=0.1,
dutyCyclePeriod=10,
boostStrength=10.0,
seed=42,
spVerbosity=0)
# Run a record through before serializing
inputVector = numpy.array([1, 0, 1, 0, 1, 0, 0, 1, 1])
activeArray1 = numpy.zeros(5)
sp1.compute(inputVector, True, activeArray1)
proto1 = SpatialPoolerProto_capnp.SpatialPoolerProto.new_message()
sp1.write(proto1)
# Write the proto to a temp file and read it back into a new proto
with tempfile.TemporaryFile() as f:
proto1.write(f)
f.seek(0)
proto2 = SpatialPoolerProto_capnp.SpatialPoolerProto.read(f)
# Load the deserialized proto
sp2 = SpatialPooler.read(proto2)
ephemeral = set(["_boostedOverlaps", "_overlaps"])
# Check that the two spatial poolers have the same attributes
self.assertSetEqual(set(sp1.__dict__.keys()), set(sp2.__dict__.keys()))
for k, v1 in sp1.__dict__.iteritems():
v2 = getattr(sp2, k)
if k in ephemeral:
continue
if isinstance(v1, numpy.ndarray):
self.assertEqual(v1.dtype, v2.dtype,
"Key %s has differing dtypes: %s vs %s" % (
> k, v1.dtype, v2.dtype))
E AssertionError: Key _inputDimensions has differing dtypes: int32 vs int64
tests/unit/nupic/algorithms/spatial_pooler_unit_test.py:1503: AssertionError
----------------------------- Captured stdout call -----------------------------
New seed generated as: 1163 called by run line 320 -> setUp
_______________________ NetworkTest.testOneRegionNetwork _______________________
self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testOneRegionNetwork>
def testOneRegionNetwork(self):
n = engine.Network()
print "Number of regions in new network: %d" % len(n.regions)
self.assertEqual(len(n.regions), 0)
print "Adding level1SP"
level1SP = n.addRegion("level1SP", "TestNode", "")
> print "Current dimensions are: %s" % level1SP.dimensions
tests/unit/nupic/engine/network_test.py:103:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.engine.Region object at 0x73d56ab0>
def _getDimensions(self):
"""Dimensions of the region"""
> return Dimensions(tuple(self._region.getDimensions()))
E TypeError: 'Dimensions' object is not iterable
/usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:475: TypeError
----------------------------- Captured stdout call -----------------------------
Number of regions in new network: 0
Adding level1SP
_______________________ NetworkTest.testTwoRegionNetwork _______________________
self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testTwoRegionNetwork>
def testTwoRegionNetwork(self):
n = engine.Network()
region1 = n.addRegion("region1", "TestNode", "")
region2 = n.addRegion("region2", "TestNode", "")
names = [region[0] for region in n.regions]
self.assertEqual(names, ['region1', 'region2'])
print n.getPhases('region1')
self.assertEqual(n.getPhases('region1'), (0,))
self.assertEqual(n.getPhases('region2'), (1,))
n.link("region1", "region2", "TestFanIn2", "")
print "Initialize should fail..."
with self.assertRaises(Exception):
n.initialize()
print "Setting region1 dims"
r1dims = engine.Dimensions([6, 4])
region1.setDimensions(r1dims)
print "Initialize should now succeed"
n.initialize()
> r2dims = region2.dimensions
tests/unit/nupic/engine/network_test.py:307:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.engine.Region object at 0x739c7b10>
def _getDimensions(self):
"""Dimensions of the region"""
> return Dimensions(tuple(self._region.getDimensions()))
E TypeError: 'Dimensions' object is not iterable
/usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:475: TypeError
----------------------------- Captured stdout call -----------------------------
(0,)
Initialize should fail...
Setting region1 dims
Initialize should now succeed
----------------------------- Captured stderr call -----------------------------
ERR: Network::initialize() -- unable to evaluate all links
The following links could not be evaluated:
[region1.bottomUpOut (region dims: [unspecified]) to region2.bottomUpIn (region dims: [unspecified]) type: TestFanIn2]
[/home/pi/nupic.core/src/nupic/engine/Network.cpp line 488]
____________________ NetworkTest.testTwoRegionPyNodeNetwork ____________________
self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testTwoRegionPyNodeNetwork>
@unittest.skipIf(sys.platform.lower().startswith("win"),
"Not supported on Windows, yet!")
def testTwoRegionPyNodeNetwork(self):
n = engine.Network()
region1 = n.addRegion("region1", "py.TestNode", "")
region2 = n.addRegion("region2", "py.TestNode", "")
n.link("region1", "region2", "TestFanIn2", "")
print "Initialize should fail..."
with self.assertRaises(Exception):
n.initialize()
print "Setting region1 dims"
r1dims = engine.Dimensions([6, 4])
region1.setDimensions(r1dims)
print "Initialize should now succeed"
n.initialize()
> r2dims = region2.dimensions
tests/unit/nupic/engine/network_test.py:448:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.engine.Region object at 0x60973230>
def _getDimensions(self):
"""Dimensions of the region"""
> return Dimensions(tuple(self._region.getDimensions()))
E TypeError: 'Dimensions' object is not iterable
/usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:475: TypeError
----------------------------- Captured stdout call -----------------------------
Initialize should fail...
Setting region1 dims
Initialize should now succeed
TestNode.initialize() here.
TestNode.initialize() here.
----------------------------- Captured stderr call -----------------------------
ERR: Network::initialize() -- unable to evaluate all links
The following links could not be evaluated:
[region1.bottomUpOut (region dims: [unspecified]) to region2.bottomUpIn (region dims: [unspecified]) type: TestFanIn2]
[/home/pi/nupic.core/src/nupic/engine/Network.cpp line 488]
_________________________ NetworkSugarTest.testRegion __________________________
self = <tests.unit.nupic.engine.syntactic_sugar_test.NetworkSugarTest testMethod=testRegion>
@unittest.skipIf(sys.platform.lower().startswith("win"),
"Not supported on Windows, yet!")
def testRegion(self):
r = net.Network().addRegion('r', 'py.TestNode', '')
print r.spec
self.assertEqual(r.type, 'py.TestNode')
self.assertEqual(r.name, 'r')
> self.assertTrue(r.dimensions.isUnspecified())
tests/unit/nupic/engine/syntactic_sugar_test.py:122:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.engine.Region object at 0x73babf50>
def _getDimensions(self):
"""Dimensions of the region"""
> return Dimensions(tuple(self._region.getDimensions()))
E TypeError: 'Dimensions' object is not iterable
/usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:475: TypeError
----------------------------- Captured stdout call -----------------------------
Spec:
Description:
The node spec of the NuPIC 2 Python TestNode
Parameters:
failInCompute
description: For testing failure in compute()
type: Int32
count: 1
stringParam
description: String parameter
type: Byte
count: 0
real32Param
description: Real32 scalar parameter
type: Real32
count: 1
failInInit
description: For testing failure in __init__()
type: Int32
count: 1
boolArrayParam
description: bool array parameter
type: Bool
count: 0
uint32Param
description: UInt32 scalar parameter
type: UInt32
count: 1
boolParam
description: bool parameter
type: Bool
count: 1
int32Param
description: Int32 scalar parameter
type: Int32
count: 1
uint64Param
description: UInt64 scalar parameter
type: UInt64
count: 1
int64arrayParam
description: Int64 array parameter
type: Int64
count: 0
int64Param
description: Int64 scalar parameter
type: Int64
count: 1
real64Param
description: Real64 scalar parameter
type: Real64
count: 1
real32arrayParam
description: Real32 array parameter
type: Real32
count: 0
self
description: The PyObject * of the region's Python classd
type: Handle
count: 1
Inputs:
bottomUpIn
Outputs:
bottomUpOut
Commands:
============================ pytest-warning summary ============================
WC1 /home/pi/nupic/tests/unit/nupic/engine/network_test.py cannot collect test class 'TestNode' because it has a __init__ constructor
WC1 /home/pi/nupic/tests/unit/nupic/frameworks/opf/htmpredictionmodel_classifier_helper_test.py cannot collect test class 'TestOptionParser' because it has a __init__ constructor
WC1 /home/pi/nupic/tests/unit/nupic/regions/knn_anomaly_classifier_region_test.py cannot collect test class 'TestOptionParser' because it has a __init__ constructor
WC1 /home/pi/nupic/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestParentException' because it has a __init__ constructor
WC1 /home/pi/nupic/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestChildException' because it has a __init__ constructor
11 failed, 702 passed, 17 skipped, 8 xfailed, 5 pytest-warnings in 1209.20 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment