Skip to content

Instantly share code, notes, and snippets.

@paulscode
Created December 9, 2017 00:40
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/7db29d052755812c0ce85391ecf8b249 to your computer and use it in GitHub Desktop.
Save paulscode/7db29d052755812c0ce85391ecf8b249 to your computer and use it in GitHub Desktop.
nupic tests, Raspbian Stretch, attempt #1
============================= test session starts ==============================
platform linux2 -- Python 2.7.13, pytest-3.0.7, py-1.5.2, pluggy-0.4.0
rootdir: /home/pi/nupic, inifile:
plugins: xdist-1.16.0, cov-2.5.0
collected 734 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 FF..F.FFFFF
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 F
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 0x73df3b10> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x73df3f90> : [(('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 0x73ed6f38> >
_____________ 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 0x5ed520d0> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x55cdb8d0> : [(('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 0x73ed6b48> >
____________ 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 0x55cf0030> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x73db3cb0> : [(('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 0x73ed6f20> >
<nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73ed6da0> >
_________________ 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 0x73db3270> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x744afb30> : [(('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 0x73ed6fe0> >
_____________ 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 0x5ea87170> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x55cf0110> : [(('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 0x73ed6e90> >
____________ 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 0x55cdb690> != <nupic.algorithms.backtracking_tm_cpp.BacktrackingTMCPP object at 0x744afb30> : [(('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 0x73ed6d70> >
<nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73ed6c68> >
_______________________ 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: 95868 called by run line 320 -> setUp
_________________________ NetworkTest.testDelayedLink __________________________
self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testDelayedLink>
def testDelayedLink(self):
n = engine.Network()
region1 = n.addRegion("region1", "TestNode", "")
region2 = n.addRegion("region2", "TestNode", "")
names = []
propagationDelay = 2
n.link("region1", "region2", "TestFanIn2", "",
propagationDelay=propagationDelay)
> r1dims = engine.Dimensions([6, 4])
tests/unit/nupic/engine/network_test.py:329:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
engine_internal.Dimensions.__init__(self, *args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.engine.Dimensions; >, args = ([6, 4],)
def __init__(self, *args):
"""
__init__(self) -> Dimensions
__init__(self, v) -> Dimensions
__init__(self, x) -> Dimensions
__init__(self, x, y) -> Dimensions
__init__(self, x, y, z) -> Dimensions
"""
> this = _engine_internal.new_Dimensions(*args)
E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
E Possible C/C++ prototypes are:
E nupic::Dimensions::Dimensions()
E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
E nupic::Dimensions::Dimensions(size_t)
E nupic::Dimensions::Dimensions(size_t,size_t)
E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
________________________ NetworkTest.testErrorHandling _________________________
self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testErrorHandling>
@unittest.skipIf(sys.platform.lower().startswith("win"),
"Not supported on Windows, yet!")
def testErrorHandling(self):
n = engine.Network()
# Test trying to add non-existent node
with self.assertRaises(Exception) as cm:
n.addRegion('r', 'py.NonExistingNode', '')
self.assertEqual(cm.exception.message, "Matching Python module for NonExistingNode not found.")
orig_import = __import__
def import_mock(name, *args):
if name == "nupic.regions.unimportable_node":
raise SyntaxError("invalid syntax (unimportable_node.py, line 5)")
return orig_import(name, *args)
with patch('__builtin__.__import__', side_effect=import_mock):
# Test failure during import
with self.assertRaises(Exception) as cm:
n.addRegion('r', 'py.UnimportableNode', '')
self.assertEqual(cm.exception.message, "invalid syntax (unimportable_node.py, line 5)")
# Test failure in the __init__() method
with self.assertRaises(Exception) as cm:
n.addRegion('r', 'py.TestNode', '{ failInInit: 1 }')
self.assertEqual(cm.exception.message, "TestNode.__init__() Failing on purpose as requested")
# Test failure inside the compute() method
with self.assertRaises(Exception) as cm:
r = n.addRegion('r', 'py.TestNode', '{ failInCompute: 1 }')
r.dimensions = engine.Dimensions([4, 4])
n.initialize()
n.run(1)
self.assertEqual(str(cm.exception),
> 'TestNode.compute() Failing on purpose as requested')
E AssertionError: "Wrong number or type of arguments for overloaded function 'new_Dimensions'.\n Possible C/C++ prototypes are:\n nupic::Dimensions::Dimensions()\n nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)\n nupic::Dimensions::Dimensions(size_t)\n nupic::Dimensions::Dimensions(size_t,size_t)\n nupic::Dimensions::Dimensions(size_t,size_t,size_t)\n" != 'TestNode.compute() Failing on purpose as requested'
tests/unit/nupic/engine/network_test.py:74: AssertionError
----------------------------- Captured stdout call -----------------------------
{'singleNodeOnly': False, 'inputs': {'bottomUpIn': {'count': 0, 'requireSplitterMap': False, 'description': 'Primary input for the node', 'isDefaultInput': True, 'dataType': 'Real64', 'required': True, 'regionLevel': False}}, 'commands': {}, 'description': 'The node spec of the NuPIC 2 Python TestNode', 'parameters': {'failInCompute': {'count': 1, 'description': 'For testing failure in compute()', 'dataType': 'Int32', 'accessMode': 'ReadWrite', 'defaultValue': '0', 'constraints': ''}, 'stringParam': {'count': 0, 'description': 'String parameter', 'dataType': 'Byte', 'accessMode': 'ReadWrite', 'defaultValue': 'nodespec value', 'constraints': ''}, 'real32Param': {'count': 1, 'description': 'Real32 scalar parameter', 'dataType': 'Real32', 'accessMode': 'ReadWrite', 'defaultValue': '32.1', 'constraints': ''}, 'failInInit': {'count': 1, 'description': 'For testing failure in __init__()', 'dataType': 'Int32', 'accessMode': 'ReadWrite', 'defaultValue': '0', 'constraints': ''}, 'boolArrayParam': {'count': 0, 'description': 'bool array parameter', 'dataType': 'Bool', 'accessMode': 'ReadWrite', 'defaultValue': '', 'constraints': ''}, 'uint32Param': {'count': 1, 'description': 'UInt32 scalar parameter', 'dataType': 'UInt32', 'accessMode': 'ReadWrite', 'defaultValue': '33', 'constraints': ''}, 'boolParam': {'count': 1, 'description': 'bool parameter', 'dataType': 'Bool', 'accessMode': 'ReadWrite', 'defaultValue': 'false', 'constraints': ''}, 'int32Param': {'count': 1, 'description': 'Int32 scalar parameter', 'dataType': 'Int32', 'accessMode': 'ReadWrite', 'defaultValue': '32', 'constraints': ''}, 'uint64Param': {'count': 1, 'description': 'UInt64 scalar parameter', 'dataType': 'UInt64', 'accessMode': 'ReadWrite', 'defaultValue': '65', 'constraints': ''}, 'int64arrayParam': {'count': 0, 'description': 'Int64 array parameter', 'dataType': 'Int64', 'accessMode': 'ReadWrite', 'defaultValue': '', 'constraints': ''}, 'int64Param': {'count': 1, 'description': 'Int64 scalar parameter', 'dataType': 'Int64', 'accessMode': 'ReadWrite', 'defaultValue': '64', 'constraints': ''}, 'real64Param': {'count': 1, 'description': 'Real64 scalar parameter', 'dataType': 'Real64', 'accessMode': 'ReadWrite', 'defaultValue': '64.1', 'constraints': ''}, 'real32arrayParam': {'count': 0, 'description': 'Real32 array parameter', 'dataType': 'Real32', 'accessMode': 'ReadWrite', 'defaultValue': '', 'constraints': ''}}, 'outputs': {'bottomUpOut': {'count': 0, 'dataType': 'Real64', 'isDefaultOutput': True, 'regionLevel': False, 'description': 'Primary output for the node'}}}
----------------------------- Captured stderr call -----------------------------
ERR: Matching Python module for NonExistingNode not found. [/home/pi/nupic.core/src/nupic/engine/RegionImplFactory.cpp line 444]
WARN: PyRegion::createSpec failed: 0x7ea7e0dc
ERR: Unable to create region r of type TestNode [/home/pi/nupic.core/src/nupic/engine/RegionImplFactory.cpp line 272]
_______________________ NetworkTest.testInputsAndOutputs _______________________
self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testInputsAndOutputs>
def testInputsAndOutputs(self):
n = engine.Network()
region1 = n.addRegion("region1", "TestNode", "")
region2 = n.addRegion("region2", "TestNode", "")
> region1.setDimensions(engine.Dimensions([6, 4]))
tests/unit/nupic/engine/network_test.py:358:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
engine_internal.Dimensions.__init__(self, *args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.engine.Dimensions; >, args = ([6, 4],)
def __init__(self, *args):
"""
__init__(self) -> Dimensions
__init__(self, v) -> Dimensions
__init__(self, x) -> Dimensions
__init__(self, x, y) -> Dimensions
__init__(self, x, y, z) -> Dimensions
"""
> this = _engine_internal.new_Dimensions(*args)
E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
E Possible C/C++ prototypes are:
E nupic::Dimensions::Dimensions()
E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
E nupic::Dimensions::Dimensions(size_t)
E nupic::Dimensions::Dimensions(size_t,size_t)
E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
_______________________ 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 0x737f2170>
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:473: TypeError
----------------------------- Captured stdout call -----------------------------
Number of regions in new network: 0
Adding level1SP
______________________ NetworkTest.testPyNodeGetNodeSpec _______________________
self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testPyNodeGetNodeSpec>
@unittest.skipIf(sys.platform.lower().startswith("win"),
"Not supported on Windows, yet!")
def testPyNodeGetNodeSpec(self):
n = engine.Network()
r = n.addRegion("region", "py.TestNode", "")
print "Setting region1 dims"
> r.setDimensions(engine.Dimensions([6, 4]))
tests/unit/nupic/engine/network_test.py:411:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
engine_internal.Dimensions.__init__(self, *args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.engine.Dimensions; >, args = ([6, 4],)
def __init__(self, *args):
"""
__init__(self) -> Dimensions
__init__(self, v) -> Dimensions
__init__(self, x) -> Dimensions
__init__(self, x, y) -> Dimensions
__init__(self, x, y, z) -> Dimensions
"""
> this = _engine_internal.new_Dimensions(*args)
E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
E Possible C/C++ prototypes are:
E nupic::Dimensions::Dimensions()
E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
E nupic::Dimensions::Dimensions(size_t)
E nupic::Dimensions::Dimensions(size_t,size_t)
E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
----------------------------- Captured stdout call -----------------------------
Setting region1 dims
____________________ NetworkTest.testPyNodeGetSetParameter _____________________
self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testPyNodeGetSetParameter>
@unittest.skipIf(sys.platform.lower().startswith("win"),
"Not supported on Windows, yet!")
def testPyNodeGetSetParameter(self):
n = engine.Network()
r = n.addRegion("region", "py.TestNode", "")
print "Setting region1 dims"
> r.dimensions = engine.Dimensions([6, 4])
tests/unit/nupic/engine/network_test.py:389:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
engine_internal.Dimensions.__init__(self, *args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.engine.Dimensions; >, args = ([6, 4],)
def __init__(self, *args):
"""
__init__(self) -> Dimensions
__init__(self, v) -> Dimensions
__init__(self, x) -> Dimensions
__init__(self, x, y) -> Dimensions
__init__(self, x, y, z) -> Dimensions
"""
> this = _engine_internal.new_Dimensions(*args)
E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
E Possible C/C++ prototypes are:
E nupic::Dimensions::Dimensions()
E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
E nupic::Dimensions::Dimensions(size_t)
E nupic::Dimensions::Dimensions(size_t,size_t)
E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
----------------------------- Captured stdout call -----------------------------
Setting region1 dims
_______________________ 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])
tests/unit/nupic/engine/network_test.py:301:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
engine_internal.Dimensions.__init__(self, *args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.engine.Dimensions; >, args = ([6, 4],)
def __init__(self, *args):
"""
__init__(self) -> Dimensions
__init__(self, v) -> Dimensions
__init__(self, x) -> Dimensions
__init__(self, x, y) -> Dimensions
__init__(self, x, y, z) -> Dimensions
"""
> this = _engine_internal.new_Dimensions(*args)
E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
E Possible C/C++ prototypes are:
E nupic::Dimensions::Dimensions()
E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
E nupic::Dimensions::Dimensions(size_t)
E nupic::Dimensions::Dimensions(size_t,size_t)
E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
----------------------------- Captured stdout call -----------------------------
(0,)
Initialize should fail...
Setting region1 dims
----------------------------- 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 528]
____________________ 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])
tests/unit/nupic/engine/network_test.py:442:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
engine_internal.Dimensions.__init__(self, *args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <nupic.engine.Dimensions; >, args = ([6, 4],)
def __init__(self, *args):
"""
__init__(self) -> Dimensions
__init__(self, v) -> Dimensions
__init__(self, x) -> Dimensions
__init__(self, x, y) -> Dimensions
__init__(self, x, y, z) -> Dimensions
"""
> this = _engine_internal.new_Dimensions(*args)
E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
E Possible C/C++ prototypes are:
E nupic::Dimensions::Dimensions()
E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
E nupic::Dimensions::Dimensions(size_t)
E nupic::Dimensions::Dimensions(size_t,size_t)
E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
----------------------------- Captured stdout call -----------------------------
Initialize should fail...
Setting region1 dims
----------------------------- 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 528]
_________________________ 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 0x5f2caab0>
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:473: 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:
_______________________ AnomalyRegionTest.testWriteRead ________________________
self = <tests.unit.nupic.regions.anomaly_region_test.AnomalyRegionTest testMethod=testWriteRead>
@unittest.skipUnless(
capnp, "pycapnp is not installed, skipping serialization test.")
def testWriteRead(self):
predictedColumns = [[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]]
activeColumns = [[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
[0, 1 ,0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0 ,0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0],
[1, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
[0, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
[0, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0]]
anomalyExpected = (1.0, 0.25, 1.0/3.0, 2.0/3.0, 1.0, 2.0/3.0, 1.0,
0.0, 0.25, 0.25)
anomalyRegion1 = AnomalyRegion()
inputs = AnomalyRegion.getSpec()['inputs']
outputs = AnomalyRegion.getSpec()['outputs']
for i in xrange(0, 6):
inputs['predictedColumns'] = numpy.array(predictedColumns[i])
inputs['activeColumns'] = numpy.array(activeColumns[i])
anomalyRegion1.compute(inputs, outputs)
proto1 = AnomalyRegionProto.new_message()
anomalyRegion1.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 = AnomalyRegionProto.read(f)
# Load the deserialized proto
anomalyRegion2 = AnomalyRegion.read(proto2)
> self.assertEqual(anomalyRegion1, anomalyRegion2)
E AssertionError: <nupic.regions.anomaly_region.AnomalyRegion object at 0x737f7250> != <nupic.regions.anomaly_region.AnomalyRegion object at 0x737f7eb0>
tests/unit/nupic/regions/anomaly_region_test.py:88: AssertionError
============================ 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
17 failed, 692 passed, 17 skipped, 8 xfailed, 5 pytest-warnings in 885.90 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment