Guest User

Untitled

a guest
Dec 11th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.42 KB | None | 0 0
  1. ============================= test session starts ==============================
  2. platform linux2 -- Python 2.7.13, pytest-3.0.7, py-1.5.2, pluggy-0.4.0
  3. rootdir: /home/pi/nupic, inifile:
  4. plugins: xdist-1.16.0, cov-2.5.0
  5. collected 734 items
  6.  
  7. tests/unit/nupic/serializable_test.py ..
  8. tests/unit/nupic/utils_test.py ......
  9. tests/unit/nupic/algorithms/anomaly_likelihood_jeff_test.py ...ss..
  10. tests/unit/nupic/algorithms/anomaly_likelihood_test.py .....................
  11. tests/unit/nupic/algorithms/anomaly_test.py ..............
  12. tests/unit/nupic/algorithms/backtracking_tm_constant_test.py *** Synapse consistency checking turned on for Cells4 ***
  13. .*** Synapse consistency checking turned on for Cells4 ***
  14. .*** Synapse consistency checking turned on for Cells4 ***
  15. .
  16. tests/unit/nupic/algorithms/backtracking_tm_cpp2_test.py *** Synapse consistency checking turned on for Cells4 ***
  17. *** Python segment match turned on for Cells4
  18. .
  19. tests/unit/nupic/algorithms/backtracking_tm_cpp_test.py ....FFF
  20. tests/unit/nupic/algorithms/backtracking_tm_test.py ....FFF
  21. tests/unit/nupic/algorithms/connections_test.py .........
  22. tests/unit/nupic/algorithms/inhibition_object_test.py s
  23. tests/unit/nupic/algorithms/knn_classifier_test.py .........s...
  24. tests/unit/nupic/algorithms/sdr_classifier_test.py ...........................
  25. tests/unit/nupic/algorithms/sp_learn_inference_test.py s
  26. tests/unit/nupic/algorithms/sp_overlap_test.py .s.s
  27. tests/unit/nupic/algorithms/spatial_pooler_boost_test.py ..
  28. tests/unit/nupic/algorithms/spatial_pooler_compatability_test.py ...ss....
  29. tests/unit/nupic/algorithms/spatial_pooler_compute_test.py ..
  30. tests/unit/nupic/algorithms/spatial_pooler_cpp_api_test.py ............................
  31. tests/unit/nupic/algorithms/spatial_pooler_cpp_unit_test.py ....
  32. tests/unit/nupic/algorithms/spatial_pooler_py_api_test.py ............................
  33. tests/unit/nupic/algorithms/spatial_pooler_unit_test.py s..............................F....
  34. tests/unit/nupic/algorithms/temporal_memory_test.py ...............................s.....s.
  35. tests/unit/nupic/algorithms/monitor_mixin/metric_test.py ..
  36. tests/unit/nupic/algorithms/monitor_mixin/trace_test.py ..
  37. tests/unit/nupic/data/aggregator_test.py .
  38. tests/unit/nupic/data/dictutils_test.py ......
  39. tests/unit/nupic/data/fieldmeta_test.py .....
  40. tests/unit/nupic/data/file_record_stream_test.py ......
  41. tests/unit/nupic/data/filters_test.py s
  42. tests/unit/nupic/data/functionsource_test.py ......
  43. tests/unit/nupic/data/inference_shifter_test.py ........
  44. tests/unit/nupic/data/record_stream_test.py .......
  45. tests/unit/nupic/data/utils_test.py .......
  46. tests/unit/nupic/data/generators/anomalyzer_test.py ...........
  47. tests/unit/nupic/data/generators/pattern_machine_test.py .........
  48. tests/unit/nupic/data/generators/sequence_machine_test.py .....
  49. tests/unit/nupic/docs/examples_test.py .xx.xxxxxx
  50. tests/unit/nupic/encoders/adaptivescalar_test.py .......
  51. tests/unit/nupic/encoders/category_test.py ..
  52. tests/unit/nupic/encoders/coordinate_test.py .................
  53. tests/unit/nupic/encoders/date_test.py ........
  54. tests/unit/nupic/encoders/delta_test.py .....
  55. tests/unit/nupic/encoders/geospatial_coordinate_test.py ...........
  56. tests/unit/nupic/encoders/logenc_test.py ......
  57. tests/unit/nupic/encoders/multi_test.py ..
  58. tests/unit/nupic/encoders/pass_through_encoder_test.py ....
  59. tests/unit/nupic/encoders/random_distributed_scalar_test.py ...............
  60. tests/unit/nupic/encoders/scalar_test.py .............
  61. tests/unit/nupic/encoders/scalarspace_test.py .
  62. tests/unit/nupic/encoders/sdrcategory_test.py ...
  63. tests/unit/nupic/encoders/sparse_pass_through_encoder_test.py .....
  64. tests/unit/nupic/engine/network_test.py FF..F.FFFFF
  65. tests/unit/nupic/engine/syntactic_sugar_test.py .F...
  66. tests/unit/nupic/engine/unified_py_parameter_test.py ..
  67. tests/unit/nupic/frameworks/opf/htmpredictionmodel_classifier_helper_test.py ......................
  68. tests/unit/nupic/frameworks/opf/htmpredictionmodel_test.py ......
  69. tests/unit/nupic/frameworks/opf/opf_metrics_test.py ...............................
  70. tests/unit/nupic/frameworks/opf/previous_value_model_test.py .......
  71. tests/unit/nupic/frameworks/opf/safe_interpreter_test.py ........
  72. tests/unit/nupic/frameworks/opf/two_gram_model_test.py ......
  73. tests/unit/nupic/frameworks/opf/common_models/cluster_params_test.py .
  74. tests/unit/nupic/math/lgamma_test.py .
  75. tests/unit/nupic/math/topology_test.py ....................
  76. tests/unit/nupic/regions/anomaly_likelihood_region_test.py ...
  77. tests/unit/nupic/regions/anomaly_region_test.py F
  78. tests/unit/nupic/regions/knn_anomaly_classifier_region_test.py .....................
  79. tests/unit/nupic/regions/knn_classifier_region_test.py .
  80. tests/unit/nupic/regions/record_sensor_region_test.py ...
  81. tests/unit/nupic/regions/regions_spec_test.py s...s......
  82. tests/unit/nupic/regions/sdr_classifier_region_test.py ..
  83. tests/unit/nupic/regions/tm_region_test.py ....
  84. tests/unit/nupic/support/configuration_test.py ............s....................
  85. tests/unit/nupic/support/custom_configuration_test.py ...................s.........................
  86. tests/unit/nupic/support/decorators_test.py ............
  87. tests/unit/nupic/support/group_by_test.py ......
  88. tests/unit/nupic/support/object_json_test.py ...............
  89. tests/unit/nupic/support/consoleprinter_test/consoleprinter_test.py .
  90.  
  91. =================================== FAILURES ===================================
  92. _________________ BacktrackingTMTest.testSerializationLearned __________________
  93.  
  94. self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationLearned>
  95.  
  96. @unittest.skipUnless(capnp, "pycapnp not installed")
  97. def testSerializationLearned(self):
  98. # Create a model and give it some inputs to learn.
  99. tm1 = BacktrackingTM(numberOfCols=100, cellsPerColumn=12,
  100. verbosity=VERBOSITY)
  101. sequences = [self.generateSequence() for _ in xrange(5)]
  102. train = list(itertools.chain.from_iterable(sequences[:3]))
  103. for bottomUpInput in train:
  104. if bottomUpInput is None:
  105. tm1.reset()
  106. else:
  107. tm1.compute(bottomUpInput, True, True)
  108.  
  109. # Serialize and deserialized the TM.
  110. tmProto = BacktrackingTM.getSchema().new_message()
  111. tm1.write(tmProto)
  112. checkpointPath = os.path.join(self._tmpDir, 'a')
  113. with open(checkpointPath, "wb") as f:
  114. tmProto.write(f)
  115. with open(checkpointPath, "rb") as f:
  116. tmProto = BacktrackingTM.getSchema().read(f)
  117. tm2 = BacktrackingTM.read(tmProto)
  118.  
  119. # Check that the TMs are the same.
  120. > self.assertTMsEqual(tm1, tm2)
  121.  
  122. tests/unit/nupic/algorithms/backtracking_tm_test.py:89:
  123. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  124. tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
  125. self.assertEqual(tm1, tm2, tm1.diff(tm2))
  126. 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)]
  127. ----------------------------- Captured stdout call -----------------------------
  128. <nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73ed6f38> >
  129. _____________ BacktrackingTMTest.testSerializationMiddleOfSequence _____________
  130.  
  131. self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationMiddleOfSequence>
  132.  
  133. @unittest.skipUnless(capnp, "pycapnp not installed")
  134. def testSerializationMiddleOfSequence(self):
  135. # Create a model and give it some inputs to learn.
  136. tm1 = BacktrackingTM(numberOfCols=100, cellsPerColumn=12,
  137. verbosity=VERBOSITY)
  138. sequences = [self.generateSequence() for _ in xrange(5)]
  139. train = list(itertools.chain.from_iterable(sequences[:3] +
  140. [sequences[3][:5]]))
  141. for bottomUpInput in train:
  142. if bottomUpInput is None:
  143. tm1.reset()
  144. else:
  145. tm1.compute(bottomUpInput, True, True)
  146.  
  147. # Serialize and deserialized the TM.
  148. tmProto = BacktrackingTM.getSchema().new_message()
  149. tm1.write(tmProto)
  150. checkpointPath = os.path.join(self._tmpDir, 'a')
  151. with open(checkpointPath, "wb") as f:
  152. tmProto.write(f)
  153. with open(checkpointPath, "rb") as f:
  154. tmProto = BacktrackingTM.getSchema().read(f)
  155. tm2 = BacktrackingTM.read(tmProto)
  156.  
  157. # Check that the TMs are the same.
  158. > self.assertTMsEqual(tm1, tm2)
  159.  
  160. tests/unit/nupic/algorithms/backtracking_tm_test.py:130:
  161. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  162. tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
  163. self.assertEqual(tm1, tm2, tm1.diff(tm2))
  164. 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)]
  165. ----------------------------- Captured stdout call -----------------------------
  166. <nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73ed6b48> >
  167. ____________ BacktrackingTMTest.testSerializationMiddleOfSequence2 _____________
  168.  
  169. self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationMiddleOfSequence2>
  170.  
  171. @unittest.skipUnless(capnp, "pycapnp not installed")
  172. def testSerializationMiddleOfSequence2(self):
  173. """More complex test of checkpointing in the middle of a sequence."""
  174. tm1 = BacktrackingTM(2048, 32, 0.21, 0.5, 11, 20, 0.1, 0.1, 1.0, 0.0, 14,
  175. False, 5, 2, False, 1960, 0, False, 3, 10, 5, 0, 32,
  176. 128, 32, 'normal')
  177. tm2 = BacktrackingTM(2048, 32, 0.21, 0.5, 11, 20, 0.1, 0.1, 1.0, 0.0, 14,
  178. False, 5, 2, False, 1960, 0, False, 3, 10, 5, 0, 32,
  179. 128, 32, 'normal')
  180.  
  181. with open(resource_filename(__name__, 'data/tm_input.csv'), 'r') as fin:
  182. reader = csv.reader(fin)
  183. records = []
  184. for bottomUpInStr in fin:
  185. bottomUpIn = numpy.array(eval('[' + bottomUpInStr.strip() + ']'),
  186. dtype='int32')
  187. records.append(bottomUpIn)
  188.  
  189. i = 1
  190. for r in records[:250]:
  191. print i
  192. i += 1
  193. output1 = tm1.compute(r, True, True)
  194. output2 = tm2.compute(r, True, True)
  195. self.assertTrue(numpy.array_equal(output1, output2))
  196.  
  197. print 'Serializing and deserializing models.'
  198.  
  199. savePath1 = os.path.join(self._tmpDir, 'tm1.bin')
  200. tmProto1 = BacktrackingTM.getSchema().new_message()
  201. tm1.write(tmProto1)
  202. with open(savePath1, "wb") as f:
  203. tmProto1.write(f)
  204. with open(savePath1, "rb") as f:
  205. tmProto3 = BacktrackingTM.getSchema().read(f)
  206. tm3 = BacktrackingTM.read(tmProto3)
  207.  
  208. savePath2 = os.path.join(self._tmpDir, 'tm2.bin')
  209. tmProto2 = BacktrackingTM.getSchema().new_message()
  210. tm2.write(tmProto2)
  211. with open(savePath2, "wb") as f:
  212. tmProto2.write(f)
  213. with open(savePath2, "rb") as f:
  214. tmProto4 = BacktrackingTM.getSchema().read(f)
  215. tm4 = BacktrackingTM.read(tmProto4)
  216.  
  217. > self.assertTMsEqual(tm1, tm3)
  218.  
  219. tests/unit/nupic/algorithms/backtracking_tm_test.py:193:
  220. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  221. tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
  222. self.assertEqual(tm1, tm2, tm1.diff(tm2))
  223. 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)]
  224. ----------------------------- Captured stdout call -----------------------------
  225. 1
  226. 2
  227. 3
  228. 4
  229. 5
  230. 6
  231. 7
  232. 8
  233. 9
  234. 10
  235. 11
  236. 12
  237. 13
  238. 14
  239. 15
  240. 16
  241. 17
  242. 18
  243. 19
  244. 20
  245. 21
  246. 22
  247. 23
  248. 24
  249. 25
  250. 26
  251. 27
  252. 28
  253. 29
  254. 30
  255. 31
  256. 32
  257. 33
  258. 34
  259. 35
  260. 36
  261. 37
  262. 38
  263. 39
  264. 40
  265. 41
  266. 42
  267. 43
  268. 44
  269. 45
  270. 46
  271. 47
  272. 48
  273. 49
  274. 50
  275. 51
  276. 52
  277. 53
  278. 54
  279. 55
  280. 56
  281. 57
  282. 58
  283. 59
  284. 60
  285. 61
  286. 62
  287. 63
  288. 64
  289. 65
  290. 66
  291. 67
  292. 68
  293. 69
  294. 70
  295. 71
  296. 72
  297. 73
  298. 74
  299. 75
  300. 76
  301. 77
  302. 78
  303. 79
  304. 80
  305. 81
  306. 82
  307. 83
  308. 84
  309. 85
  310. 86
  311. 87
  312. 88
  313. 89
  314. 90
  315. 91
  316. 92
  317. 93
  318. 94
  319. 95
  320. 96
  321. 97
  322. 98
  323. 99
  324. 100
  325. 101
  326. 102
  327. 103
  328. 104
  329. 105
  330. 106
  331. 107
  332. 108
  333. 109
  334. 110
  335. 111
  336. 112
  337. 113
  338. 114
  339. 115
  340. 116
  341. 117
  342. 118
  343. 119
  344. 120
  345. 121
  346. 122
  347. 123
  348. 124
  349. 125
  350. 126
  351. 127
  352. 128
  353. 129
  354. 130
  355. 131
  356. 132
  357. 133
  358. 134
  359. 135
  360. 136
  361. 137
  362. 138
  363. 139
  364. 140
  365. 141
  366. 142
  367. 143
  368. 144
  369. 145
  370. 146
  371. 147
  372. 148
  373. 149
  374. 150
  375. 151
  376. 152
  377. 153
  378. 154
  379. 155
  380. 156
  381. 157
  382. 158
  383. 159
  384. 160
  385. 161
  386. 162
  387. 163
  388. 164
  389. 165
  390. 166
  391. 167
  392. 168
  393. 169
  394. 170
  395. 171
  396. 172
  397. 173
  398. 174
  399. 175
  400. 176
  401. 177
  402. 178
  403. 179
  404. 180
  405. 181
  406. 182
  407. 183
  408. 184
  409. 185
  410. 186
  411. 187
  412. 188
  413. 189
  414. 190
  415. 191
  416. 192
  417. 193
  418. 194
  419. 195
  420. 196
  421. 197
  422. 198
  423. 199
  424. 200
  425. 201
  426. 202
  427. 203
  428. 204
  429. 205
  430. 206
  431. 207
  432. 208
  433. 209
  434. 210
  435. 211
  436. 212
  437. 213
  438. 214
  439. 215
  440. 216
  441. 217
  442. 218
  443. 219
  444. 220
  445. 221
  446. 222
  447. 223
  448. 224
  449. 225
  450. 226
  451. 227
  452. 228
  453. 229
  454. 230
  455. 231
  456. 232
  457. 233
  458. 234
  459. 235
  460. 236
  461. 237
  462. 238
  463. 239
  464. 240
  465. 241
  466. 242
  467. 243
  468. 244
  469. 245
  470. 246
  471. 247
  472. 248
  473. 249
  474. 250
  475. Serializing and deserializing models.
  476. <nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73ed6f20> >
  477. <nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73ed6da0> >
  478. _________________ BacktrackingTMTest.testSerializationLearned __________________
  479.  
  480. self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationLearned>
  481.  
  482. @unittest.skipUnless(capnp, "pycapnp not installed")
  483. def testSerializationLearned(self):
  484. # Create a model and give it some inputs to learn.
  485. tm1 = BacktrackingTM(numberOfCols=100, cellsPerColumn=12,
  486. verbosity=VERBOSITY)
  487. sequences = [self.generateSequence() for _ in xrange(5)]
  488. train = list(itertools.chain.from_iterable(sequences[:3]))
  489. for bottomUpInput in train:
  490. if bottomUpInput is None:
  491. tm1.reset()
  492. else:
  493. tm1.compute(bottomUpInput, True, True)
  494.  
  495. # Serialize and deserialized the TM.
  496. tmProto = BacktrackingTM.getSchema().new_message()
  497. tm1.write(tmProto)
  498. checkpointPath = os.path.join(self._tmpDir, 'a')
  499. with open(checkpointPath, "wb") as f:
  500. tmProto.write(f)
  501. with open(checkpointPath, "rb") as f:
  502. tmProto = BacktrackingTM.getSchema().read(f)
  503. tm2 = BacktrackingTM.read(tmProto)
  504.  
  505. # Check that the TMs are the same.
  506. > self.assertTMsEqual(tm1, tm2)
  507.  
  508. tests/unit/nupic/algorithms/backtracking_tm_test.py:89:
  509. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  510. tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
  511. self.assertEqual(tm1, tm2, tm1.diff(tm2))
  512. 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)]
  513. ----------------------------- Captured stdout call -----------------------------
  514. <nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73ed6fe0> >
  515. _____________ BacktrackingTMTest.testSerializationMiddleOfSequence _____________
  516.  
  517. self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationMiddleOfSequence>
  518.  
  519. @unittest.skipUnless(capnp, "pycapnp not installed")
  520. def testSerializationMiddleOfSequence(self):
  521. # Create a model and give it some inputs to learn.
  522. tm1 = BacktrackingTM(numberOfCols=100, cellsPerColumn=12,
  523. verbosity=VERBOSITY)
  524. sequences = [self.generateSequence() for _ in xrange(5)]
  525. train = list(itertools.chain.from_iterable(sequences[:3] +
  526. [sequences[3][:5]]))
  527. for bottomUpInput in train:
  528. if bottomUpInput is None:
  529. tm1.reset()
  530. else:
  531. tm1.compute(bottomUpInput, True, True)
  532.  
  533. # Serialize and deserialized the TM.
  534. tmProto = BacktrackingTM.getSchema().new_message()
  535. tm1.write(tmProto)
  536. checkpointPath = os.path.join(self._tmpDir, 'a')
  537. with open(checkpointPath, "wb") as f:
  538. tmProto.write(f)
  539. with open(checkpointPath, "rb") as f:
  540. tmProto = BacktrackingTM.getSchema().read(f)
  541. tm2 = BacktrackingTM.read(tmProto)
  542.  
  543. # Check that the TMs are the same.
  544. > self.assertTMsEqual(tm1, tm2)
  545.  
  546. tests/unit/nupic/algorithms/backtracking_tm_test.py:130:
  547. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  548. tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
  549. self.assertEqual(tm1, tm2, tm1.diff(tm2))
  550. 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)]
  551. ----------------------------- Captured stdout call -----------------------------
  552. <nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73ed6e90> >
  553. ____________ BacktrackingTMTest.testSerializationMiddleOfSequence2 _____________
  554.  
  555. self = <tests.unit.nupic.algorithms.backtracking_tm_test.BacktrackingTMTest testMethod=testSerializationMiddleOfSequence2>
  556.  
  557. @unittest.skipUnless(capnp, "pycapnp not installed")
  558. def testSerializationMiddleOfSequence2(self):
  559. """More complex test of checkpointing in the middle of a sequence."""
  560. tm1 = BacktrackingTM(2048, 32, 0.21, 0.5, 11, 20, 0.1, 0.1, 1.0, 0.0, 14,
  561. False, 5, 2, False, 1960, 0, False, 3, 10, 5, 0, 32,
  562. 128, 32, 'normal')
  563. tm2 = BacktrackingTM(2048, 32, 0.21, 0.5, 11, 20, 0.1, 0.1, 1.0, 0.0, 14,
  564. False, 5, 2, False, 1960, 0, False, 3, 10, 5, 0, 32,
  565. 128, 32, 'normal')
  566.  
  567. with open(resource_filename(__name__, 'data/tm_input.csv'), 'r') as fin:
  568. reader = csv.reader(fin)
  569. records = []
  570. for bottomUpInStr in fin:
  571. bottomUpIn = numpy.array(eval('[' + bottomUpInStr.strip() + ']'),
  572. dtype='int32')
  573. records.append(bottomUpIn)
  574.  
  575. i = 1
  576. for r in records[:250]:
  577. print i
  578. i += 1
  579. output1 = tm1.compute(r, True, True)
  580. output2 = tm2.compute(r, True, True)
  581. self.assertTrue(numpy.array_equal(output1, output2))
  582.  
  583. print 'Serializing and deserializing models.'
  584.  
  585. savePath1 = os.path.join(self._tmpDir, 'tm1.bin')
  586. tmProto1 = BacktrackingTM.getSchema().new_message()
  587. tm1.write(tmProto1)
  588. with open(savePath1, "wb") as f:
  589. tmProto1.write(f)
  590. with open(savePath1, "rb") as f:
  591. tmProto3 = BacktrackingTM.getSchema().read(f)
  592. tm3 = BacktrackingTM.read(tmProto3)
  593.  
  594. savePath2 = os.path.join(self._tmpDir, 'tm2.bin')
  595. tmProto2 = BacktrackingTM.getSchema().new_message()
  596. tm2.write(tmProto2)
  597. with open(savePath2, "wb") as f:
  598. tmProto2.write(f)
  599. with open(savePath2, "rb") as f:
  600. tmProto4 = BacktrackingTM.getSchema().read(f)
  601. tm4 = BacktrackingTM.read(tmProto4)
  602.  
  603. > self.assertTMsEqual(tm1, tm3)
  604.  
  605. tests/unit/nupic/algorithms/backtracking_tm_test.py:193:
  606. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  607. tests/unit/nupic/algorithms/backtracking_tm_test.py:348: in assertTMsEqual
  608. self.assertEqual(tm1, tm2, tm1.diff(tm2))
  609. 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)]
  610. ----------------------------- Captured stdout call -----------------------------
  611. 1
  612. 2
  613. 3
  614. 4
  615. 5
  616. 6
  617. 7
  618. 8
  619. 9
  620. 10
  621. 11
  622. 12
  623. 13
  624. 14
  625. 15
  626. 16
  627. 17
  628. 18
  629. 19
  630. 20
  631. 21
  632. 22
  633. 23
  634. 24
  635. 25
  636. 26
  637. 27
  638. 28
  639. 29
  640. 30
  641. 31
  642. 32
  643. 33
  644. 34
  645. 35
  646. 36
  647. 37
  648. 38
  649. 39
  650. 40
  651. 41
  652. 42
  653. 43
  654. 44
  655. 45
  656. 46
  657. 47
  658. 48
  659. 49
  660. 50
  661. 51
  662. 52
  663. 53
  664. 54
  665. 55
  666. 56
  667. 57
  668. 58
  669. 59
  670. 60
  671. 61
  672. 62
  673. 63
  674. 64
  675. 65
  676. 66
  677. 67
  678. 68
  679. 69
  680. 70
  681. 71
  682. 72
  683. 73
  684. 74
  685. 75
  686. 76
  687. 77
  688. 78
  689. 79
  690. 80
  691. 81
  692. 82
  693. 83
  694. 84
  695. 85
  696. 86
  697. 87
  698. 88
  699. 89
  700. 90
  701. 91
  702. 92
  703. 93
  704. 94
  705. 95
  706. 96
  707. 97
  708. 98
  709. 99
  710. 100
  711. 101
  712. 102
  713. 103
  714. 104
  715. 105
  716. 106
  717. 107
  718. 108
  719. 109
  720. 110
  721. 111
  722. 112
  723. 113
  724. 114
  725. 115
  726. 116
  727. 117
  728. 118
  729. 119
  730. 120
  731. 121
  732. 122
  733. 123
  734. 124
  735. 125
  736. 126
  737. 127
  738. 128
  739. 129
  740. 130
  741. 131
  742. 132
  743. 133
  744. 134
  745. 135
  746. 136
  747. 137
  748. 138
  749. 139
  750. 140
  751. 141
  752. 142
  753. 143
  754. 144
  755. 145
  756. 146
  757. 147
  758. 148
  759. 149
  760. 150
  761. 151
  762. 152
  763. 153
  764. 154
  765. 155
  766. 156
  767. 157
  768. 158
  769. 159
  770. 160
  771. 161
  772. 162
  773. 163
  774. 164
  775. 165
  776. 166
  777. 167
  778. 168
  779. 169
  780. 170
  781. 171
  782. 172
  783. 173
  784. 174
  785. 175
  786. 176
  787. 177
  788. 178
  789. 179
  790. 180
  791. 181
  792. 182
  793. 183
  794. 184
  795. 185
  796. 186
  797. 187
  798. 188
  799. 189
  800. 190
  801. 191
  802. 192
  803. 193
  804. 194
  805. 195
  806. 196
  807. 197
  808. 198
  809. 199
  810. 200
  811. 201
  812. 202
  813. 203
  814. 204
  815. 205
  816. 206
  817. 207
  818. 208
  819. 209
  820. 210
  821. 211
  822. 212
  823. 213
  824. 214
  825. 215
  826. 216
  827. 217
  828. 218
  829. 219
  830. 220
  831. 221
  832. 222
  833. 223
  834. 224
  835. 225
  836. 226
  837. 227
  838. 228
  839. 229
  840. 230
  841. 231
  842. 232
  843. 233
  844. 234
  845. 235
  846. 236
  847. 237
  848. 238
  849. 239
  850. 240
  851. 241
  852. 242
  853. 243
  854. 244
  855. 245
  856. 246
  857. 247
  858. 248
  859. 249
  860. 250
  861. Serializing and deserializing models.
  862. <nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73ed6d70> >
  863. <nupic.bindings.algorithms.Cells4; proxy of <Swig Object of type 'nupic::algorithms::Cells4::Cells4 *' at 0x73ed6c68> >
  864. _______________________ SpatialPoolerTest.testWriteRead ________________________
  865.  
  866. self = <tests.unit.nupic.algorithms.spatial_pooler_unit_test.SpatialPoolerTest testMethod=testWriteRead>
  867.  
  868. @unittest.skipUnless(
  869. capnp, "pycapnp is not installed, skipping serialization test.")
  870. def testWriteRead(self):
  871. sp1 = SpatialPooler(
  872. inputDimensions=[9],
  873. columnDimensions=[5],
  874. potentialRadius=3,
  875. potentialPct=0.5,
  876. globalInhibition=False,
  877. localAreaDensity=-1.0,
  878. numActiveColumnsPerInhArea=3,
  879. stimulusThreshold=1,
  880. synPermInactiveDec=0.01,
  881. synPermActiveInc=0.1,
  882. synPermConnected=0.10,
  883. minPctOverlapDutyCycle=0.1,
  884. dutyCyclePeriod=10,
  885. boostStrength=10.0,
  886. seed=42,
  887. spVerbosity=0)
  888.  
  889. # Run a record through before serializing
  890. inputVector = numpy.array([1, 0, 1, 0, 1, 0, 0, 1, 1])
  891. activeArray1 = numpy.zeros(5)
  892. sp1.compute(inputVector, True, activeArray1)
  893.  
  894. proto1 = SpatialPoolerProto_capnp.SpatialPoolerProto.new_message()
  895. sp1.write(proto1)
  896.  
  897. # Write the proto to a temp file and read it back into a new proto
  898. with tempfile.TemporaryFile() as f:
  899. proto1.write(f)
  900. f.seek(0)
  901. proto2 = SpatialPoolerProto_capnp.SpatialPoolerProto.read(f)
  902.  
  903. # Load the deserialized proto
  904. sp2 = SpatialPooler.read(proto2)
  905.  
  906. ephemeral = set(["_boostedOverlaps", "_overlaps"])
  907.  
  908. # Check that the two spatial poolers have the same attributes
  909. self.assertSetEqual(set(sp1.__dict__.keys()), set(sp2.__dict__.keys()))
  910. for k, v1 in sp1.__dict__.iteritems():
  911. v2 = getattr(sp2, k)
  912. if k in ephemeral:
  913. continue
  914. if isinstance(v1, numpy.ndarray):
  915. self.assertEqual(v1.dtype, v2.dtype,
  916. "Key %s has differing dtypes: %s vs %s" % (
  917. > k, v1.dtype, v2.dtype))
  918. E AssertionError: Key _inputDimensions has differing dtypes: int32 vs int64
  919.  
  920. tests/unit/nupic/algorithms/spatial_pooler_unit_test.py:1503: AssertionError
  921. ----------------------------- Captured stdout call -----------------------------
  922. New seed generated as: 95868 called by run line 320 -> setUp
  923. _________________________ NetworkTest.testDelayedLink __________________________
  924.  
  925. self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testDelayedLink>
  926.  
  927. def testDelayedLink(self):
  928. n = engine.Network()
  929.  
  930. region1 = n.addRegion("region1", "TestNode", "")
  931. region2 = n.addRegion("region2", "TestNode", "")
  932.  
  933. names = []
  934.  
  935. propagationDelay = 2
  936. n.link("region1", "region2", "TestFanIn2", "",
  937. propagationDelay=propagationDelay)
  938.  
  939. > r1dims = engine.Dimensions([6, 4])
  940.  
  941. tests/unit/nupic/engine/network_test.py:329:
  942. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  943. /usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
  944. engine_internal.Dimensions.__init__(self, *args)
  945. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  946.  
  947. self = <nupic.engine.Dimensions; >, args = ([6, 4],)
  948.  
  949. def __init__(self, *args):
  950. """
  951. __init__(self) -> Dimensions
  952. __init__(self, v) -> Dimensions
  953. __init__(self, x) -> Dimensions
  954. __init__(self, x, y) -> Dimensions
  955. __init__(self, x, y, z) -> Dimensions
  956. """
  957. > this = _engine_internal.new_Dimensions(*args)
  958. E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
  959. E Possible C/C++ prototypes are:
  960. E nupic::Dimensions::Dimensions()
  961. E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
  962. E nupic::Dimensions::Dimensions(size_t)
  963. E nupic::Dimensions::Dimensions(size_t,size_t)
  964. E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
  965.  
  966. ../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
  967. ________________________ NetworkTest.testErrorHandling _________________________
  968.  
  969. self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testErrorHandling>
  970.  
  971. @unittest.skipIf(sys.platform.lower().startswith("win"),
  972. "Not supported on Windows, yet!")
  973. def testErrorHandling(self):
  974. n = engine.Network()
  975.  
  976. # Test trying to add non-existent node
  977. with self.assertRaises(Exception) as cm:
  978. n.addRegion('r', 'py.NonExistingNode', '')
  979.  
  980. self.assertEqual(cm.exception.message, "Matching Python module for NonExistingNode not found.")
  981.  
  982. orig_import = __import__
  983. def import_mock(name, *args):
  984. if name == "nupic.regions.unimportable_node":
  985. raise SyntaxError("invalid syntax (unimportable_node.py, line 5)")
  986.  
  987. return orig_import(name, *args)
  988.  
  989. with patch('__builtin__.__import__', side_effect=import_mock):
  990. # Test failure during import
  991. with self.assertRaises(Exception) as cm:
  992. n.addRegion('r', 'py.UnimportableNode', '')
  993.  
  994. self.assertEqual(cm.exception.message, "invalid syntax (unimportable_node.py, line 5)")
  995.  
  996. # Test failure in the __init__() method
  997. with self.assertRaises(Exception) as cm:
  998. n.addRegion('r', 'py.TestNode', '{ failInInit: 1 }')
  999.  
  1000. self.assertEqual(cm.exception.message, "TestNode.__init__() Failing on purpose as requested")
  1001.  
  1002. # Test failure inside the compute() method
  1003. with self.assertRaises(Exception) as cm:
  1004. r = n.addRegion('r', 'py.TestNode', '{ failInCompute: 1 }')
  1005. r.dimensions = engine.Dimensions([4, 4])
  1006. n.initialize()
  1007. n.run(1)
  1008.  
  1009. self.assertEqual(str(cm.exception),
  1010. > 'TestNode.compute() Failing on purpose as requested')
  1011. 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'
  1012.  
  1013. tests/unit/nupic/engine/network_test.py:74: AssertionError
  1014. ----------------------------- Captured stdout call -----------------------------
  1015. {'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'}}}
  1016. ----------------------------- Captured stderr call -----------------------------
  1017. ERR: Matching Python module for NonExistingNode not found. [/home/pi/nupic.core/src/nupic/engine/RegionImplFactory.cpp line 444]
  1018. WARN: PyRegion::createSpec failed: 0x7ea7e0dc
  1019. ERR: Unable to create region r of type TestNode [/home/pi/nupic.core/src/nupic/engine/RegionImplFactory.cpp line 272]
  1020. _______________________ NetworkTest.testInputsAndOutputs _______________________
  1021.  
  1022. self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testInputsAndOutputs>
  1023.  
  1024. def testInputsAndOutputs(self):
  1025. n = engine.Network()
  1026.  
  1027. region1 = n.addRegion("region1", "TestNode", "")
  1028. region2 = n.addRegion("region2", "TestNode", "")
  1029. > region1.setDimensions(engine.Dimensions([6, 4]))
  1030.  
  1031. tests/unit/nupic/engine/network_test.py:358:
  1032. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1033. /usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
  1034. engine_internal.Dimensions.__init__(self, *args)
  1035. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1036.  
  1037. self = <nupic.engine.Dimensions; >, args = ([6, 4],)
  1038.  
  1039. def __init__(self, *args):
  1040. """
  1041. __init__(self) -> Dimensions
  1042. __init__(self, v) -> Dimensions
  1043. __init__(self, x) -> Dimensions
  1044. __init__(self, x, y) -> Dimensions
  1045. __init__(self, x, y, z) -> Dimensions
  1046. """
  1047. > this = _engine_internal.new_Dimensions(*args)
  1048. E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
  1049. E Possible C/C++ prototypes are:
  1050. E nupic::Dimensions::Dimensions()
  1051. E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
  1052. E nupic::Dimensions::Dimensions(size_t)
  1053. E nupic::Dimensions::Dimensions(size_t,size_t)
  1054. E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
  1055.  
  1056. ../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
  1057. _______________________ NetworkTest.testOneRegionNetwork _______________________
  1058.  
  1059. self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testOneRegionNetwork>
  1060.  
  1061. def testOneRegionNetwork(self):
  1062. n = engine.Network()
  1063.  
  1064. print "Number of regions in new network: %d" % len(n.regions)
  1065. self.assertEqual(len(n.regions), 0)
  1066.  
  1067. print "Adding level1SP"
  1068. level1SP = n.addRegion("level1SP", "TestNode", "")
  1069. > print "Current dimensions are: %s" % level1SP.dimensions
  1070.  
  1071. tests/unit/nupic/engine/network_test.py:103:
  1072. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1073.  
  1074. self = <nupic.engine.Region object at 0x737f2170>
  1075.  
  1076. def _getDimensions(self):
  1077. """Dimensions of the region"""
  1078. > return Dimensions(tuple(self._region.getDimensions()))
  1079. E TypeError: 'Dimensions' object is not iterable
  1080.  
  1081. /usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:473: TypeError
  1082. ----------------------------- Captured stdout call -----------------------------
  1083. Number of regions in new network: 0
  1084. Adding level1SP
  1085. ______________________ NetworkTest.testPyNodeGetNodeSpec _______________________
  1086.  
  1087. self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testPyNodeGetNodeSpec>
  1088.  
  1089. @unittest.skipIf(sys.platform.lower().startswith("win"),
  1090. "Not supported on Windows, yet!")
  1091. def testPyNodeGetNodeSpec(self):
  1092. n = engine.Network()
  1093.  
  1094. r = n.addRegion("region", "py.TestNode", "")
  1095.  
  1096. print "Setting region1 dims"
  1097. > r.setDimensions(engine.Dimensions([6, 4]))
  1098.  
  1099. tests/unit/nupic/engine/network_test.py:411:
  1100. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1101. /usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
  1102. engine_internal.Dimensions.__init__(self, *args)
  1103. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1104.  
  1105. self = <nupic.engine.Dimensions; >, args = ([6, 4],)
  1106.  
  1107. def __init__(self, *args):
  1108. """
  1109. __init__(self) -> Dimensions
  1110. __init__(self, v) -> Dimensions
  1111. __init__(self, x) -> Dimensions
  1112. __init__(self, x, y) -> Dimensions
  1113. __init__(self, x, y, z) -> Dimensions
  1114. """
  1115. > this = _engine_internal.new_Dimensions(*args)
  1116. E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
  1117. E Possible C/C++ prototypes are:
  1118. E nupic::Dimensions::Dimensions()
  1119. E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
  1120. E nupic::Dimensions::Dimensions(size_t)
  1121. E nupic::Dimensions::Dimensions(size_t,size_t)
  1122. E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
  1123.  
  1124. ../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
  1125. ----------------------------- Captured stdout call -----------------------------
  1126. Setting region1 dims
  1127. ____________________ NetworkTest.testPyNodeGetSetParameter _____________________
  1128.  
  1129. self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testPyNodeGetSetParameter>
  1130.  
  1131. @unittest.skipIf(sys.platform.lower().startswith("win"),
  1132. "Not supported on Windows, yet!")
  1133. def testPyNodeGetSetParameter(self):
  1134. n = engine.Network()
  1135.  
  1136. r = n.addRegion("region", "py.TestNode", "")
  1137.  
  1138. print "Setting region1 dims"
  1139. > r.dimensions = engine.Dimensions([6, 4])
  1140.  
  1141. tests/unit/nupic/engine/network_test.py:389:
  1142. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1143. /usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
  1144. engine_internal.Dimensions.__init__(self, *args)
  1145. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1146.  
  1147. self = <nupic.engine.Dimensions; >, args = ([6, 4],)
  1148.  
  1149. def __init__(self, *args):
  1150. """
  1151. __init__(self) -> Dimensions
  1152. __init__(self, v) -> Dimensions
  1153. __init__(self, x) -> Dimensions
  1154. __init__(self, x, y) -> Dimensions
  1155. __init__(self, x, y, z) -> Dimensions
  1156. """
  1157. > this = _engine_internal.new_Dimensions(*args)
  1158. E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
  1159. E Possible C/C++ prototypes are:
  1160. E nupic::Dimensions::Dimensions()
  1161. E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
  1162. E nupic::Dimensions::Dimensions(size_t)
  1163. E nupic::Dimensions::Dimensions(size_t,size_t)
  1164. E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
  1165.  
  1166. ../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
  1167. ----------------------------- Captured stdout call -----------------------------
  1168. Setting region1 dims
  1169. _______________________ NetworkTest.testTwoRegionNetwork _______________________
  1170.  
  1171. self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testTwoRegionNetwork>
  1172.  
  1173. def testTwoRegionNetwork(self):
  1174. n = engine.Network()
  1175.  
  1176. region1 = n.addRegion("region1", "TestNode", "")
  1177. region2 = n.addRegion("region2", "TestNode", "")
  1178.  
  1179. names = [region[0] for region in n.regions]
  1180. self.assertEqual(names, ['region1', 'region2'])
  1181. print n.getPhases('region1')
  1182. self.assertEqual(n.getPhases('region1'), (0,))
  1183. self.assertEqual(n.getPhases('region2'), (1,))
  1184.  
  1185. n.link("region1", "region2", "TestFanIn2", "")
  1186.  
  1187. print "Initialize should fail..."
  1188. with self.assertRaises(Exception):
  1189. n.initialize()
  1190.  
  1191. print "Setting region1 dims"
  1192. > r1dims = engine.Dimensions([6, 4])
  1193.  
  1194. tests/unit/nupic/engine/network_test.py:301:
  1195. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1196. /usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
  1197. engine_internal.Dimensions.__init__(self, *args)
  1198. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1199.  
  1200. self = <nupic.engine.Dimensions; >, args = ([6, 4],)
  1201.  
  1202. def __init__(self, *args):
  1203. """
  1204. __init__(self) -> Dimensions
  1205. __init__(self, v) -> Dimensions
  1206. __init__(self, x) -> Dimensions
  1207. __init__(self, x, y) -> Dimensions
  1208. __init__(self, x, y, z) -> Dimensions
  1209. """
  1210. > this = _engine_internal.new_Dimensions(*args)
  1211. E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
  1212. E Possible C/C++ prototypes are:
  1213. E nupic::Dimensions::Dimensions()
  1214. E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
  1215. E nupic::Dimensions::Dimensions(size_t)
  1216. E nupic::Dimensions::Dimensions(size_t,size_t)
  1217. E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
  1218.  
  1219. ../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
  1220. ----------------------------- Captured stdout call -----------------------------
  1221. (0,)
  1222. Initialize should fail...
  1223. Setting region1 dims
  1224. ----------------------------- Captured stderr call -----------------------------
  1225. ERR: Network::initialize() -- unable to evaluate all links
  1226. The following links could not be evaluated:
  1227. [region1.bottomUpOut (region dims: [unspecified]) to region2.bottomUpIn (region dims: [unspecified]) type: TestFanIn2]
  1228.  
  1229. [/home/pi/nupic.core/src/nupic/engine/Network.cpp line 528]
  1230. ____________________ NetworkTest.testTwoRegionPyNodeNetwork ____________________
  1231.  
  1232. self = <tests.unit.nupic.engine.network_test.NetworkTest testMethod=testTwoRegionPyNodeNetwork>
  1233.  
  1234. @unittest.skipIf(sys.platform.lower().startswith("win"),
  1235. "Not supported on Windows, yet!")
  1236. def testTwoRegionPyNodeNetwork(self):
  1237. n = engine.Network()
  1238.  
  1239. region1 = n.addRegion("region1", "py.TestNode", "")
  1240. region2 = n.addRegion("region2", "py.TestNode", "")
  1241.  
  1242. n.link("region1", "region2", "TestFanIn2", "")
  1243.  
  1244. print "Initialize should fail..."
  1245. with self.assertRaises(Exception):
  1246. n.initialize()
  1247.  
  1248. print "Setting region1 dims"
  1249. > r1dims = engine.Dimensions([6, 4])
  1250.  
  1251. tests/unit/nupic/engine/network_test.py:442:
  1252. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1253. /usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:172: in __init__
  1254. engine_internal.Dimensions.__init__(self, *args)
  1255. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1256.  
  1257. self = <nupic.engine.Dimensions; >, args = ([6, 4],)
  1258.  
  1259. def __init__(self, *args):
  1260. """
  1261. __init__(self) -> Dimensions
  1262. __init__(self, v) -> Dimensions
  1263. __init__(self, x) -> Dimensions
  1264. __init__(self, x, y) -> Dimensions
  1265. __init__(self, x, y, z) -> Dimensions
  1266. """
  1267. > this = _engine_internal.new_Dimensions(*args)
  1268. E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Dimensions'.
  1269. E Possible C/C++ prototypes are:
  1270. E nupic::Dimensions::Dimensions()
  1271. E nupic::Dimensions::Dimensions(std::vector< size_t,std::allocator< size_t > >)
  1272. E nupic::Dimensions::Dimensions(size_t)
  1273. E nupic::Dimensions::Dimensions(size_t,size_t)
  1274. E nupic::Dimensions::Dimensions(size_t,size_t,size_t)
  1275.  
  1276. ../nupic.core/bindings/py/src/nupic/bindings/engine_internal.py:613: NotImplementedError
  1277. ----------------------------- Captured stdout call -----------------------------
  1278. Initialize should fail...
  1279. Setting region1 dims
  1280. ----------------------------- Captured stderr call -----------------------------
  1281. ERR: Network::initialize() -- unable to evaluate all links
  1282. The following links could not be evaluated:
  1283. [region1.bottomUpOut (region dims: [unspecified]) to region2.bottomUpIn (region dims: [unspecified]) type: TestFanIn2]
  1284.  
  1285. [/home/pi/nupic.core/src/nupic/engine/Network.cpp line 528]
  1286. _________________________ NetworkSugarTest.testRegion __________________________
  1287.  
  1288. self = <tests.unit.nupic.engine.syntactic_sugar_test.NetworkSugarTest testMethod=testRegion>
  1289.  
  1290. @unittest.skipIf(sys.platform.lower().startswith("win"),
  1291. "Not supported on Windows, yet!")
  1292. def testRegion(self):
  1293. r = net.Network().addRegion('r', 'py.TestNode', '')
  1294.  
  1295. print r.spec
  1296. self.assertEqual(r.type, 'py.TestNode')
  1297. self.assertEqual(r.name, 'r')
  1298. > self.assertTrue(r.dimensions.isUnspecified())
  1299.  
  1300. tests/unit/nupic/engine/syntactic_sugar_test.py:122:
  1301. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  1302.  
  1303. self = <nupic.engine.Region object at 0x5f2caab0>
  1304.  
  1305. def _getDimensions(self):
  1306. """Dimensions of the region"""
  1307. > return Dimensions(tuple(self._region.getDimensions()))
  1308. E TypeError: 'Dimensions' object is not iterable
  1309.  
  1310. /usr/local/lib/python2.7/dist-packages/nupic/engine/__init__.py:473: TypeError
  1311. ----------------------------- Captured stdout call -----------------------------
  1312. Spec:
  1313. Description:
  1314. The node spec of the NuPIC 2 Python TestNode
  1315.  
  1316. Parameters:
  1317. failInCompute
  1318. description: For testing failure in compute()
  1319. type: Int32
  1320. count: 1
  1321. stringParam
  1322. description: String parameter
  1323. type: Byte
  1324. count: 0
  1325. real32Param
  1326. description: Real32 scalar parameter
  1327. type: Real32
  1328. count: 1
  1329. failInInit
  1330. description: For testing failure in __init__()
  1331. type: Int32
  1332. count: 1
  1333. boolArrayParam
  1334. description: bool array parameter
  1335. type: Bool
  1336. count: 0
  1337. uint32Param
  1338. description: UInt32 scalar parameter
  1339. type: UInt32
  1340. count: 1
  1341. boolParam
  1342. description: bool parameter
  1343. type: Bool
  1344. count: 1
  1345. int32Param
  1346. description: Int32 scalar parameter
  1347. type: Int32
  1348. count: 1
  1349. uint64Param
  1350. description: UInt64 scalar parameter
  1351. type: UInt64
  1352. count: 1
  1353. int64arrayParam
  1354. description: Int64 array parameter
  1355. type: Int64
  1356. count: 0
  1357. int64Param
  1358. description: Int64 scalar parameter
  1359. type: Int64
  1360. count: 1
  1361. real64Param
  1362. description: Real64 scalar parameter
  1363. type: Real64
  1364. count: 1
  1365. real32arrayParam
  1366. description: Real32 array parameter
  1367. type: Real32
  1368. count: 0
  1369. self
  1370. description: The PyObject * of the region's Python classd
  1371. type: Handle
  1372. count: 1
  1373. Inputs:
  1374. bottomUpIn
  1375. Outputs:
  1376. bottomUpOut
  1377. Commands:
  1378.  
  1379. _______________________ AnomalyRegionTest.testWriteRead ________________________
  1380.  
  1381. self = <tests.unit.nupic.regions.anomaly_region_test.AnomalyRegionTest testMethod=testWriteRead>
  1382.  
  1383. @unittest.skipUnless(
  1384. capnp, "pycapnp is not installed, skipping serialization test.")
  1385. def testWriteRead(self):
  1386. predictedColumns = [[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1387. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1388. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1389. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1390. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1391. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1392. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1393. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1394. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1395. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]]
  1396. activeColumns = [[0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1397. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
  1398. [0, 1 ,0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0],
  1399. [0, 0 ,0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0],
  1400. [1, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
  1401. [0, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
  1402. [0, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
  1403. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  1404. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
  1405. [0, 1 ,1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0]]
  1406. anomalyExpected = (1.0, 0.25, 1.0/3.0, 2.0/3.0, 1.0, 2.0/3.0, 1.0,
  1407. 0.0, 0.25, 0.25)
  1408.  
  1409. anomalyRegion1 = AnomalyRegion()
  1410. inputs = AnomalyRegion.getSpec()['inputs']
  1411. outputs = AnomalyRegion.getSpec()['outputs']
  1412. for i in xrange(0, 6):
  1413. inputs['predictedColumns'] = numpy.array(predictedColumns[i])
  1414. inputs['activeColumns'] = numpy.array(activeColumns[i])
  1415. anomalyRegion1.compute(inputs, outputs)
  1416.  
  1417. proto1 = AnomalyRegionProto.new_message()
  1418. anomalyRegion1.write(proto1)
  1419.  
  1420. # Write the proto to a temp file and read it back into a new proto
  1421. with tempfile.TemporaryFile() as f:
  1422. proto1.write(f)
  1423. f.seek(0)
  1424. proto2 = AnomalyRegionProto.read(f)
  1425.  
  1426. # Load the deserialized proto
  1427. anomalyRegion2 = AnomalyRegion.read(proto2)
  1428.  
  1429. > self.assertEqual(anomalyRegion1, anomalyRegion2)
  1430. E AssertionError: <nupic.regions.anomaly_region.AnomalyRegion object at 0x737f7250> != <nupic.regions.anomaly_region.AnomalyRegion object at 0x737f7eb0>
  1431.  
  1432. tests/unit/nupic/regions/anomaly_region_test.py:88: AssertionError
  1433. ============================ pytest-warning summary ============================
  1434. WC1 /home/pi/nupic/tests/unit/nupic/engine/network_test.py cannot collect test class 'TestNode' because it has a __init__ constructor
  1435. 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
  1436. 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
  1437. WC1 /home/pi/nupic/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestParentException' because it has a __init__ constructor
  1438. WC1 /home/pi/nupic/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestChildException' because it has a __init__ constructor
  1439. 17 failed, 692 passed, 17 skipped, 8 xfailed, 5 pytest-warnings in 885.90 seconds
Add Comment
Please, Sign In to add comment