Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.32 KB | None | 0 0
  1. y.factors.Factor.Factor object>]), 'L': set([<pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>]), 'R': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>])}
  2. var.remove = undefined
  3. factor = <pgmpy.factors.Factor.Factor object>
  4. 16 working_factors[var].add(factor_reduced)
  5. 17 del working_factors[evidence_var]
  6. 18
  7. 19 def _variable_elimination(self, variables, operation, evidence=None, elimination_order=None):
  8.  
  9. KeyError: 'J'
  10. ___________________________________________________________________________
  11.  
  12. During handling of the above exception, another exception occurred:
  13.  
  14. Traceback (most recent call last):
  15. File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/tests/test_inference/test_ExactInference.py", line 86, in test_map_query_with_evidence
  16. {'J': 0, 'Q': 1, 'G': 0})
  17. File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py", line 188, in map_query
  18. elimination_order=elimination_order)
  19. File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py", line 50, in _variable_elimination
  20. Parallel(n_jobs=-1, backend="threading") (delayed(self. parallelFor)(evidence_var,working_factors,evidence)for evidence_var in evidence)
  21. File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 660, in __call__
  22. self.retrieve()
  23. File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 543, in retrieve
  24. raise exception_type(report)
  25. joblib.my_exceptions.JoblibKeyError: JoblibKeyError
  26. ___________________________________________________________________________
  27. Multiprocessing exception:
  28. ...........................................................................
  29. /usr/bin/nosetests3 in <module>()
  30. 4 import sys
  31. 5 from pkg_resources import load_entry_point
  32. 6
  33. 7 if __name__ == '__main__':
  34. 8 sys.exit(
  35. ----> 9 load_entry_point('nose==1.3.1', 'console_scripts', 'nosetests')()
  36. 10 )
  37. 11
  38. 12
  39. 13
  40.  
  41. ...........................................................................
  42. /usr/local/lib/python3.4/dist-packages/nose/core.py in __init__(self=<nose.core.TestProgram object>, module=None, defaultTest='.', argv=None, testRunner=None, testLoader=None, env=environ({'SESSION_MANAGER': 'local/gokstudio:@/t...ault.path', 'KONSOLE_DBUS_WINDOW': '/Windows/2'}), config=Config(addPaths=True, args=(), configSection='no...r=False, workingDir='/home/gokul/pgmpy_gk/pgmpy'), suite=None, exit=True, plugins=None, addplugins=None)
  43. 116 if version >= (2,7) and version != (3,0):
  44. 117 extra_args['exit'] = exit
  45. 118 unittest.TestProgram.__init__(
  46. 119 self, module=module, defaultTest=defaultTest,
  47. 120 argv=argv, testRunner=testRunner, testLoader=testLoader,
  48. --> 121 **extra_args)
  49. extra_args = {'exit': True}
  50. 122
  51. 123 def getAllConfigFiles(self, env=None):
  52. 124 env = env or {}
  53. 125 if env.get('NOSE_IGNORE_CONFIG_FILES', False):
  54.  
  55. ...........................................................................
  56. /usr/lib/python3.4/unittest/main.py in __init__(self=<nose.core.TestProgram object>, module=None, defaultTest='.', argv=['/usr/bin/nosetests3'], testRunner=None, testLoader=None, exit=True, verbosity=1, failfast=None, catchbreak=None, buffer=None, warnings=None)
  57. 88 self.defaultTest = defaultTest
  58. 89 self.testRunner = testRunner
  59. 90 self.testLoader = testLoader
  60. 91 self.progName = os.path.basename(argv[0])
  61. 92 self.parseArgs(argv)
  62. ---> 93 self.runTests()
  63. self.runTests = <bound method TestProgram.runTests of <nose.core.TestProgram object>>
  64. 94
  65. 95 def usageExit(self, msg=None):
  66. 96 if msg:
  67. 97 print(msg)
  68.  
  69. ...........................................................................
  70. /usr/local/lib/python3.4/dist-packages/nose/core.py in runTests(self=<nose.core.TestProgram object>)
  71. 202 verbosity=self.config.verbosity,
  72. 203 config=self.config)
  73. 204 plug_runner = self.config.plugins.prepareTestRunner(self.testRunner)
  74. 205 if plug_runner is not None:
  75. 206 self.testRunner = plug_runner
  76. --> 207 result = self.testRunner.run(self.test)
  77. result = undefined
  78. self.testRunner.run = <bound method TextTestRunner.run of <nose.core.TextTestRunner object>>
  79. self.test = <nose.suite.ContextSuite context=None>
  80. 208 self.success = result.wasSuccessful()
  81. 209 if self.exit:
  82. 210 sys.exit(not self.success)
  83. 211 return self.success
  84.  
  85. ...........................................................................
  86. /usr/local/lib/python3.4/dist-packages/nose/core.py in run(self=<nose.core.TextTestRunner object>, test=<nose.suite.ContextSuite context=None>)
  87. 57 self.stream = wrapped
  88. 58
  89. 59 result = self._makeResult()
  90. 60 start = time.time()
  91. 61 try:
  92. ---> 62 test(result)
  93. test = <nose.suite.ContextSuite context=None>
  94. result = <nose.result.TextTestResult run=102 errors=0 failures=0>
  95. 63 except KeyboardInterrupt:
  96. 64 pass
  97. 65 stop = time.time()
  98. 66 result.printErrors()
  99.  
  100. ...........................................................................
  101. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=None>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
  102. 173 def __hash__(self):
  103. 174 return object.__hash__(self)
  104. 175
  105. 176 # 2.3 compat -- force 2.4 call sequence
  106. 177 def __call__(self, *arg, **kw):
  107. --> 178 return self.run(*arg, **kw)
  108. self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=None>>
  109. arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
  110. kw = {}
  111. 179
  112. 180 def exc_info(self):
  113. 181 """Hook for replacing error tuple output
  114. 182 """
  115.  
  116. ...........................................................................
  117. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=None>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
  118. 220 log.debug("stopping")
  119. 221 break
  120. 222 # each nose.case.Test will create its own result proxy
  121. 223 # so the cases need the original result, to avoid proxy
  122. 224 # chains
  123. --> 225 test(orig)
  124. test = <nose.suite.LazySuite tests=generator (139974360407624)>
  125. orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
  126. 226 finally:
  127. 227 self.has_run = True
  128. 228 try:
  129. 229 self.tearDown()
  130.  
  131. ...........................................................................
  132. /usr/lib/python3.4/unittest/suite.py in __call__(self=<nose.suite.LazySuite tests=generator (139974360407624)>, *args=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kwds={})
  133. 82 if hasattr(test, 'countTestCases'):
  134. 83 self._removed_tests += test.countTestCases()
  135. 84 self._tests[index] = None
  136. 85
  137. 86 def __call__(self, *args, **kwds):
  138. ---> 87 return self.run(*args, **kwds)
  139. self.run = <bound method LazySuite.run of <nose.suite.LazySuite tests=generator (139974360407624)>>
  140. args = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
  141. kwds = {}
  142. 88
  143. 89 def debug(self):
  144. 90 """Run the tests without collecting errors in a TestResult"""
  145. 91 for test in self:
  146.  
  147. ...........................................................................
  148. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.LazySuite tests=generator (139974360407624)>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
  149. 71 # added to bypass run changes in 2.7's unittest
  150. 72 def run(self, result):
  151. 73 for test in self._tests:
  152. 74 if result.shouldStop:
  153. 75 break
  154. ---> 76 test(result)
  155. test = <nose.suite.ContextSuite context=pgmpy>
  156. result = <nose.result.TextTestResult run=102 errors=0 failures=0>
  157. 77 return result
  158. 78
  159. 79 def __bool__(self):
  160. 80 log.debug("tests in %s?", id(self))
  161.  
  162. ...........................................................................
  163. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
  164. 173 def __hash__(self):
  165. 174 return object.__hash__(self)
  166. 175
  167. 176 # 2.3 compat -- force 2.4 call sequence
  168. 177 def __call__(self, *arg, **kw):
  169. --> 178 return self.run(*arg, **kw)
  170. self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy>>
  171. arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
  172. kw = {}
  173. 179
  174. 180 def exc_info(self):
  175. 181 """Hook for replacing error tuple output
  176. 182 """
  177.  
  178. ...........................................................................
  179. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
  180. 220 log.debug("stopping")
  181. 221 break
  182. 222 # each nose.case.Test will create its own result proxy
  183. 223 # so the cases need the original result, to avoid proxy
  184. 224 # chains
  185. --> 225 test(orig)
  186. test = <nose.suite.ContextSuite context=pgmpy.tests>
  187. orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
  188. 226 finally:
  189. 227 self.has_run = True
  190. 228 try:
  191. 229 self.tearDown()
  192.  
  193. ...........................................................................
  194. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
  195. 173 def __hash__(self):
  196. 174 return object.__hash__(self)
  197. 175
  198. 176 # 2.3 compat -- force 2.4 call sequence
  199. 177 def __call__(self, *arg, **kw):
  200. --> 178 return self.run(*arg, **kw)
  201. self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy.tests>>
  202. arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
  203. kw = {}
  204. 179
  205. 180 def exc_info(self):
  206. 181 """Hook for replacing error tuple output
  207. 182 """
  208.  
  209. ...........................................................................
  210. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
  211. 220 log.debug("stopping")
  212. 221 break
  213. 222 # each nose.case.Test will create its own result proxy
  214. 223 # so the cases need the original result, to avoid proxy
  215. 224 # chains
  216. --> 225 test(orig)
  217. test = <nose.suite.ContextSuite context=pgmpy.tests.test_inference>
  218. orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
  219. 226 finally:
  220. 227 self.has_run = True
  221. 228 try:
  222. 229 self.tearDown()
  223.  
  224. ...........................................................................
  225. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
  226. 173 def __hash__(self):
  227. 174 return object.__hash__(self)
  228. 175
  229. 176 # 2.3 compat -- force 2.4 call sequence
  230. 177 def __call__(self, *arg, **kw):
  231. --> 178 return self.run(*arg, **kw)
  232. self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy.tests.test_inference>>
  233. arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
  234. kw = {}
  235. 179
  236. 180 def exc_info(self):
  237. 181 """Hook for replacing error tuple output
  238. 182 """
  239.  
  240. ...........................................................................
  241. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
  242. 220 log.debug("stopping")
  243. 221 break
  244. 222 # each nose.case.Test will create its own result proxy
  245. 223 # so the cases need the original result, to avoid proxy
  246. 224 # chains
  247. --> 225 test(orig)
  248. test = <nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>
  249. orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
  250. 226 finally:
  251. 227 self.has_run = True
  252. 228 try:
  253. 229 self.tearDown()
  254.  
  255. ...........................................................................
  256. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
  257. 173 def __hash__(self):
  258. 174 return object.__hash__(self)
  259. 175
  260. 176 # 2.3 compat -- force 2.4 call sequence
  261. 177 def __call__(self, *arg, **kw):
  262. --> 178 return self.run(*arg, **kw)
  263. self.run = <bound method ContextSuite.run of <nose.suite.Co...=pgmpy.tests.test_inference.test_ExactInference>>
  264. arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
  265. kw = {}
  266. 179
  267. 180 def exc_info(self):
  268. 181 """Hook for replacing error tuple output
  269. 182 """
  270.  
  271. ...........................................................................
  272. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
  273. 220 log.debug("stopping")
  274. 221 break
  275. 222 # each nose.case.Test will create its own result proxy
  276. 223 # so the cases need the original result, to avoid proxy
  277. 224 # chains
  278. --> 225 test(orig)
  279. test = <nose.suite.ContextSuite context=TestVariableElimination>
  280. orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
  281. 226 finally:
  282. 227 self.has_run = True
  283. 228 try:
  284. 229 self.tearDown()
  285.  
  286. ...........................................................................
  287. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=TestVariableElimination>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
  288. 173 def __hash__(self):
  289. 174 return object.__hash__(self)
  290. 175
  291. 176 # 2.3 compat -- force 2.4 call sequence
  292. 177 def __call__(self, *arg, **kw):
  293. --> 178 return self.run(*arg, **kw)
  294. self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=TestVariableElimination>>
  295. arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
  296. kw = {}
  297. 179
  298. 180 def exc_info(self):
  299. 181 """Hook for replacing error tuple output
  300. 182 """
  301.  
  302. ...........................................................................
  303. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=TestVariableElimination>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
  304. 220 log.debug("stopping")
  305. 221 break
  306. 222 # each nose.case.Test will create its own result proxy
  307. 223 # so the cases need the original result, to avoid proxy
  308. 224 # chains
  309. --> 225 test(orig)
  310. test = Test(<pgmpy.tests.test_inference.test_ExactInfer...ination testMethod=test_map_query_with_evidence>)
  311. orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
  312. 226 finally:
  313. 227 self.has_run = True
  314. 228 try:
  315. 229 self.tearDown()
  316.  
  317. ...........................................................................
  318. /usr/local/lib/python3.4/dist-packages/nose/case.py in __call__(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...ination testMethod=test_map_query_with_evidence>), *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kwarg={})
  319. 41 self.plugins = config.plugins
  320. 42 self.passed = None
  321. 43 unittest.TestCase.__init__(self)
  322. 44
  323. 45 def __call__(self, *arg, **kwarg):
  324. ---> 46 return self.run(*arg, **kwarg)
  325. self.run = <bound method Test.run of Test(<pgmpy.tests.test...nation testMethod=test_map_query_with_evidence>)>
  326. arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
  327. kwarg = {}
  328. 47
  329. 48 def __str__(self):
  330. 49 name = self.plugins.testName(self)
  331. 50 if name is not None:
  332.  
  333. ...........................................................................
  334. /usr/local/lib/python3.4/dist-packages/nose/case.py in run(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...ination testMethod=test_map_query_with_evidence>), result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
  335. 129 if self.resultProxy:
  336. 130 result = self.resultProxy(result, self)
  337. 131 try:
  338. 132 try:
  339. 133 self.beforeTest(result)
  340. --> 134 self.runTest(result)
  341. self.runTest = <bound method Test.runTest of Test(<pgmpy.tests....nation testMethod=test_map_query_with_evidence>)>
  342. result = <nose.result.TextTestResult run=102 errors=0 failures=0>
  343. 135 except KeyboardInterrupt:
  344. 136 raise
  345. 137 except:
  346. 138 err = sys.exc_info()
  347.  
  348. ...........................................................................
  349. /usr/local/lib/python3.4/dist-packages/nose/case.py in runTest(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...ination testMethod=test_map_query_with_evidence>), result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
  350. 147 """
  351. 148 test = self.test
  352. 149 plug_test = self.config.plugins.prepareTestCase(self)
  353. 150 if plug_test is not None:
  354. 151 test = plug_test
  355. --> 152 test(result)
  356. test = <pgmpy.tests.test_inference.test_ExactInference....mination testMethod=test_map_query_with_evidence>
  357. result = <nose.result.TextTestResult run=102 errors=0 failures=0>
  358. 153
  359. 154 def shortDescription(self):
  360. 155 desc = self.plugins.describeTest(self)
  361. 156 if desc is not None:
  362.  
  363. ...........................................................................
  364. /usr/lib/python3.4/unittest/case.py in __call__(self=<pgmpy.tests.test_inference.test_ExactInference....mination testMethod=test_map_query_with_evidence>, *args=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kwds={})
  365. 617 # return this for backwards compatibility
  366. 618 # even though we no longer us it internally
  367. 619 return outcome.success
  368. 620
  369. 621 def __call__(self, *args, **kwds):
  370. --> 622 return self.run(*args, **kwds)
  371. self.run = <bound method TestVariableElimination.run of <pg...ination testMethod=test_map_query_with_evidence>>
  372. args = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
  373. kwds = {}
  374. 623
  375. 624 def debug(self):
  376. 625 """Run the test without collecting errors in a TestResult"""
  377. 626 self.setUp()
  378.  
  379. ...........................................................................
  380. /usr/lib/python3.4/unittest/case.py in run(self=<pgmpy.tests.test_inference.test_ExactInference....mination testMethod=test_map_query_with_evidence>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
  381. 569 with outcome.testPartExecutor(self):
  382. 570 self.setUp()
  383. 571 if outcome.success:
  384. 572 outcome.expecting_failure = expecting_failure
  385. 573 with outcome.testPartExecutor(self, isTest=True):
  386. --> 574 testMethod()
  387. testMethod = <bound method TestVariableElimination.test_map_q...ination testMethod=test_map_query_with_evidence>>
  388. 575 outcome.expecting_failure = False
  389. 576 with outcome.testPartExecutor(self):
  390. 577 self.tearDown()
  391. 578
  392.  
  393. ...........................................................................
  394. /home/gokul/pgmpy_gk/pgmpy/pgmpy/tests/test_inference/test_ExactInference.py in test_map_query_with_evidence(self=<pgmpy.tests.test_inference.test_ExactInference....mination testMethod=test_map_query_with_evidence>)
  395. 81 self.assertDictEqual(map_query, {'A': 1, 'R': 1, 'J': 1, 'Q': 1, 'G': 0,
  396. 82 'L': 0})
  397. 83
  398. 84 def test_map_query_with_evidence(self):
  399. 85 map_query = self.bayesian_inference.map_query(['A', 'R', 'L'],
  400. ---> 86 {'J': 0, 'Q': 1, 'G': 0})
  401. 87 self.assertDictEqual(map_query, {'A': 1, 'R': 0, 'L': 0})
  402. 88
  403. 89
  404. 90 class TestBeliefPropagation(unittest.TestCase):
  405.  
  406. ...........................................................................
  407. /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in map_query(self=<pgmpy.inference.ExactInference.VariableElimination object>, variables=['A', 'R', 'L'], evidence={'G': 0, 'J': 0, 'Q': 1}, elimination_order=None)
  408. 183 >>> phi_query = inference.map_query(['A', 'B'])
  409. 184 """
  410. 185 elimination_variables = set(self.variables) - set(evidence.keys()) if evidence else set()
  411. 186 final_distribution = self._variable_elimination(elimination_variables, 'maximize',
  412. 187 evidence=evidence,
  413. --> 188 elimination_order=elimination_order)
  414. elimination_order = None
  415. 189 # To handle the case when no argument is passed then
  416. 190 # _variable_elimination returns a dict.
  417. 191 if isinstance(final_distribution, dict):
  418. 192 final_distribution = final_distribution.values()
  419.  
  420. ...........................................................................
  421. /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in _variable_elimination(self=<pgmpy.inference.ExactInference.VariableElimination object>, variables=set(['A', 'L', 'R']), operation='maximize', evidence={'G': 0, 'J': 0, 'Q': 1}, elimination_order=None)
  422. 45 for node in self.factors}
  423. 46
  424. 47 # Dealing with evidence. Reducing factors over it before VE is run.
  425. 48
  426. 49 if evidence: #Implementation of a parallel looping construct
  427. ---> 50 Parallel(n_jobs=-1, backend="threading") (delayed(self. parallelFor)(evidence_var,working_factors,evidence)for evidence_var in evidence)
  428. self.parallelFor = <bound method VariableElimination.parallelFor of...rence.ExactInference.VariableElimination object>>
  429. evidence = {'G': 0, 'J': 0, 'Q': 1}
  430. 51 # TODO: Modify it to find the optimal elimination order
  431. 52 if not elimination_order:
  432. 53 elimination_order = list(set(self.variables) -
  433. 54 set(variables) -
  434.  
  435. ...........................................................................
  436. /usr/local/lib/python3.4/dist-packages/joblib/parallel.py in __call__(self=Parallel(n_jobs=-1), iterable=<generator object <genexpr>>)
  437. 655 if pre_dispatch == "all" or n_jobs == 1:
  438. 656 # The iterable was consumed all at once by the above for loop.
  439. 657 # No need to wait for async callbacks to trigger to
  440. 658 # consumption.
  441. 659 self._iterating = False
  442. --> 660 self.retrieve()
  443. self.retrieve = <bound method Parallel.retrieve of Parallel(n_jobs=-1)>
  444. 661 # Make sure that we get a last message telling us we are done
  445. 662 elapsed_time = time.time() - self._start_time
  446. 663 self._print('Done %3i out of %3i | elapsed: %s finished',
  447. 664 (len(self._output),
  448.  
  449. ---------------------------------------------------------------------------
  450. Sub-process traceback:
  451. ---------------------------------------------------------------------------
  452. KeyError Fri Mar 6 23:06:30 2015
  453. PID: 19709 Python 3.4.0: /usr/bin/python3
  454. ...........................................................................
  455. /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in parallelFor(self=<pgmpy.inference.ExactInference.VariableElimination object>, evidence_var='G', working_factors={'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'G': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'L': set([<pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>]), 'R': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>])}, evidence={'G': 0, 'J': 0, 'Q': 1})
  456. 10 def parallelFor(self, evidence_var,working_factors,evidence):
  457. 11
  458. 12 for factor in working_factors[evidence_var]:
  459. 13 factor_reduced = factor.reduce('{evidence_var}_{state}'.format(evidence_var=evidence_var,state=evidence[evidence_var]),inplace=False)
  460. 14 for var in factor_reduced.scope():
  461. ---> 15 working_factors[var].remove(factor)
  462. working_factors = {'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'G': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'L': set([<pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>]), 'R': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>])}
  463. var.remove = undefined
  464. factor = <pgmpy.factors.Factor.Factor object>
  465. 16 working_factors[var].add(factor_reduced)
  466. 17 del working_factors[evidence_var]
  467. 18
  468. 19 def _variable_elimination(self, variables, operation, evidence=None, elimination_order=None):
  469.  
  470. KeyError: 'J'
  471. ___________________________________________________________________________
  472.  
  473. ======================================================================
  474. ERROR: test_query_multiple_variable_with_evidence (pgmpy.tests.test_inference.test_ExactInference.TestVariableElimination)
  475. ----------------------------------------------------------------------
  476. Traceback (most recent call last):
  477. File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 92, in __call__
  478. return self.func(*args, **kwargs)
  479. File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py", line 15, in parallelFor
  480. working_factors[var].remove(factor)
  481. KeyError: <pgmpy.factors.Factor.Factor object at 0x7f4e4a966400>
  482.  
  483. During handling of the above exception, another exception occurred:
  484.  
  485. Traceback (most recent call last):
  486. File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 512, in retrieve
  487. self._output.append(job.get())
  488. File "/usr/lib/python3.4/multiprocessing/pool.py", line 599, in get
  489. raise self._value
  490. File "/usr/lib/python3.4/multiprocessing/pool.py", line 119, in worker
  491. result = (True, func(*args, **kwds))
  492. File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 102, in __call__
  493. raise TransportableException(text, e_type)
  494. joblib.my_exceptions.TransportableException: TransportableException
  495. ___________________________________________________________________________
  496. KeyError Fri Mar 6 23:06:30 2015
  497. PID: 19709 Python 3.4.0: /usr/bin/python3
  498. ...........................................................................
  499. /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in parallelFor(self=<pgmpy.inference.ExactInference.VariableElimination object>, evidence_var='A', working_factors={'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'J': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>])}, evidence={'A': 0, 'G': 0, 'L': 1, 'R': 0})
  500. 10 def parallelFor(self, evidence_var,working_factors,evidence):
  501. 11
  502. 12 for factor in working_factors[evidence_var]:
  503. 13 factor_reduced = factor.reduce('{evidence_var}_{state}'.format(evidence_var=evidence_var,state=evidence[evidence_var]),inplace=False)
  504. 14 for var in factor_reduced.scope():
  505. ---> 15 working_factors[var].remove(factor)
  506. working_factors = {'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'J': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>])}
  507. var.remove = undefined
  508. factor = <pgmpy.factors.Factor.Factor object>
  509. 16 working_factors[var].add(factor_reduced)
  510. 17 del working_factors[evidence_var]
  511. 18
  512. 19 def _variable_elimination(self, variables, operation, evidence=None, elimination_order=None):
  513.  
  514. KeyError: <pgmpy.factors.Factor.Factor object at 0x7f4e4a966400>
  515. ___________________________________________________________________________
  516.  
  517. During handling of the above exception, another exception occurred:
  518.  
  519. Traceback (most recent call last):
  520. File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/tests/test_inference/test_ExactInference.py", line 59, in test_query_multiple_variable_with_evidence
  521. 'G': 0, 'L': 1})
  522. File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py", line 115, in query
  523. evidence=evidence, elimination_order=elimination_order)
  524. File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py", line 50, in _variable_elimination
  525. Parallel(n_jobs=-1, backend="threading") (delayed(self. parallelFor)(evidence_var,working_factors,evidence)for evidence_var in evidence)
  526. File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 660, in __call__
  527. self.retrieve()
  528. File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 543, in retrieve
  529. raise exception_type(report)
  530. joblib.my_exceptions.JoblibKeyError: JoblibKeyError
  531. ___________________________________________________________________________
  532. Multiprocessing exception:
  533. ...........................................................................
  534. /usr/bin/nosetests3 in <module>()
  535. 4 import sys
  536. 5 from pkg_resources import load_entry_point
  537. 6
  538. 7 if __name__ == '__main__':
  539. 8 sys.exit(
  540. ----> 9 load_entry_point('nose==1.3.1', 'console_scripts', 'nosetests')()
  541. 10 )
  542. 11
  543. 12
  544. 13
  545.  
  546. ...........................................................................
  547. /usr/local/lib/python3.4/dist-packages/nose/core.py in __init__(self=<nose.core.TestProgram object>, module=None, defaultTest='.', argv=None, testRunner=None, testLoader=None, env=environ({'SESSION_MANAGER': 'local/gokstudio:@/t...ault.path', 'KONSOLE_DBUS_WINDOW': '/Windows/2'}), config=Config(addPaths=True, args=(), configSection='no...r=False, workingDir='/home/gokul/pgmpy_gk/pgmpy'), suite=None, exit=True, plugins=None, addplugins=None)
  548. 116 if version >= (2,7) and version != (3,0):
  549. 117 extra_args['exit'] = exit
  550. 118 unittest.TestProgram.__init__(
  551. 119 self, module=module, defaultTest=defaultTest,
  552. 120 argv=argv, testRunner=testRunner, testLoader=testLoader,
  553. --> 121 **extra_args)
  554. extra_args = {'exit': True}
  555. 122
  556. 123 def getAllConfigFiles(self, env=None):
  557. 124 env = env or {}
  558. 125 if env.get('NOSE_IGNORE_CONFIG_FILES', False):
  559.  
  560. ...........................................................................
  561. /usr/lib/python3.4/unittest/main.py in __init__(self=<nose.core.TestProgram object>, module=None, defaultTest='.', argv=['/usr/bin/nosetests3'], testRunner=None, testLoader=None, exit=True, verbosity=1, failfast=None, catchbreak=None, buffer=None, warnings=None)
  562. 88 self.defaultTest = defaultTest
  563. 89 self.testRunner = testRunner
  564. 90 self.testLoader = testLoader
  565. 91 self.progName = os.path.basename(argv[0])
  566. 92 self.parseArgs(argv)
  567. ---> 93 self.runTests()
  568. self.runTests = <bound method TestProgram.runTests of <nose.core.TestProgram object>>
  569. 94
  570. 95 def usageExit(self, msg=None):
  571. 96 if msg:
  572. 97 print(msg)
  573.  
  574. ...........................................................................
  575. /usr/local/lib/python3.4/dist-packages/nose/core.py in runTests(self=<nose.core.TestProgram object>)
  576. 202 verbosity=self.config.verbosity,
  577. 203 config=self.config)
  578. 204 plug_runner = self.config.plugins.prepareTestRunner(self.testRunner)
  579. 205 if plug_runner is not None:
  580. 206 self.testRunner = plug_runner
  581. --> 207 result = self.testRunner.run(self.test)
  582. result = undefined
  583. self.testRunner.run = <bound method TextTestRunner.run of <nose.core.TextTestRunner object>>
  584. self.test = <nose.suite.ContextSuite context=None>
  585. 208 self.success = result.wasSuccessful()
  586. 209 if self.exit:
  587. 210 sys.exit(not self.success)
  588. 211 return self.success
  589.  
  590. ...........................................................................
  591. /usr/local/lib/python3.4/dist-packages/nose/core.py in run(self=<nose.core.TextTestRunner object>, test=<nose.suite.ContextSuite context=None>)
  592. 57 self.stream = wrapped
  593. 58
  594. 59 result = self._makeResult()
  595. 60 start = time.time()
  596. 61 try:
  597. ---> 62 test(result)
  598. test = <nose.suite.ContextSuite context=None>
  599. result = <nose.result.TextTestResult run=108 errors=1 failures=0>
  600. 63 except KeyboardInterrupt:
  601. 64 pass
  602. 65 stop = time.time()
  603. 66 result.printErrors()
  604.  
  605. ...........................................................................
  606. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=None>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
  607. 173 def __hash__(self):
  608. 174 return object.__hash__(self)
  609. 175
  610. 176 # 2.3 compat -- force 2.4 call sequence
  611. 177 def __call__(self, *arg, **kw):
  612. --> 178 return self.run(*arg, **kw)
  613. self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=None>>
  614. arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
  615. kw = {}
  616. 179
  617. 180 def exc_info(self):
  618. 181 """Hook for replacing error tuple output
  619. 182 """
  620.  
  621. ...........................................................................
  622. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=None>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
  623. 220 log.debug("stopping")
  624. 221 break
  625. 222 # each nose.case.Test will create its own result proxy
  626. 223 # so the cases need the original result, to avoid proxy
  627. 224 # chains
  628. --> 225 test(orig)
  629. test = <nose.suite.LazySuite tests=generator (139974360407624)>
  630. orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
  631. 226 finally:
  632. 227 self.has_run = True
  633. 228 try:
  634. 229 self.tearDown()
  635.  
  636. ...........................................................................
  637. /usr/lib/python3.4/unittest/suite.py in __call__(self=<nose.suite.LazySuite tests=generator (139974360407624)>, *args=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kwds={})
  638. 82 if hasattr(test, 'countTestCases'):
  639. 83 self._removed_tests += test.countTestCases()
  640. 84 self._tests[index] = None
  641. 85
  642. 86 def __call__(self, *args, **kwds):
  643. ---> 87 return self.run(*args, **kwds)
  644. self.run = <bound method LazySuite.run of <nose.suite.LazySuite tests=generator (139974360407624)>>
  645. args = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
  646. kwds = {}
  647. 88
  648. 89 def debug(self):
  649. 90 """Run the tests without collecting errors in a TestResult"""
  650. 91 for test in self:
  651.  
  652. ...........................................................................
  653. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.LazySuite tests=generator (139974360407624)>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
  654. 71 # added to bypass run changes in 2.7's unittest
  655. 72 def run(self, result):
  656. 73 for test in self._tests:
  657. 74 if result.shouldStop:
  658. 75 break
  659. ---> 76 test(result)
  660. test = <nose.suite.ContextSuite context=pgmpy>
  661. result = <nose.result.TextTestResult run=108 errors=1 failures=0>
  662. 77 return result
  663. 78
  664. 79 def __bool__(self):
  665. 80 log.debug("tests in %s?", id(self))
  666.  
  667. ...........................................................................
  668. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
  669. 173 def __hash__(self):
  670. 174 return object.__hash__(self)
  671. 175
  672. 176 # 2.3 compat -- force 2.4 call sequence
  673. 177 def __call__(self, *arg, **kw):
  674. --> 178 return self.run(*arg, **kw)
  675. self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy>>
  676. arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
  677. kw = {}
  678. 179
  679. 180 def exc_info(self):
  680. 181 """Hook for replacing error tuple output
  681. 182 """
  682.  
  683. ...........................................................................
  684. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
  685. 220 log.debug("stopping")
  686. 221 break
  687. 222 # each nose.case.Test will create its own result proxy
  688. 223 # so the cases need the original result, to avoid proxy
  689. 224 # chains
  690. --> 225 test(orig)
  691. test = <nose.suite.ContextSuite context=pgmpy.tests>
  692. orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
  693. 226 finally:
  694. 227 self.has_run = True
  695. 228 try:
  696. 229 self.tearDown()
  697.  
  698. ...........................................................................
  699. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
  700. 173 def __hash__(self):
  701. 174 return object.__hash__(self)
  702. 175
  703. 176 # 2.3 compat -- force 2.4 call sequence
  704. 177 def __call__(self, *arg, **kw):
  705. --> 178 return self.run(*arg, **kw)
  706. self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy.tests>>
  707. arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
  708. kw = {}
  709. 179
  710. 180 def exc_info(self):
  711. 181 """Hook for replacing error tuple output
  712. 182 """
  713.  
  714. ...........................................................................
  715. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
  716. 220 log.debug("stopping")
  717. 221 break
  718. 222 # each nose.case.Test will create its own result proxy
  719. 223 # so the cases need the original result, to avoid proxy
  720. 224 # chains
  721. --> 225 test(orig)
  722. test = <nose.suite.ContextSuite context=pgmpy.tests.test_inference>
  723. orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
  724. 226 finally:
  725. 227 self.has_run = True
  726. 228 try:
  727. 229 self.tearDown()
  728.  
  729. ...........................................................................
  730. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
  731. 173 def __hash__(self):
  732. 174 return object.__hash__(self)
  733. 175
  734. 176 # 2.3 compat -- force 2.4 call sequence
  735. 177 def __call__(self, *arg, **kw):
  736. --> 178 return self.run(*arg, **kw)
  737. self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy.tests.test_inference>>
  738. arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
  739. kw = {}
  740. 179
  741. 180 def exc_info(self):
  742. 181 """Hook for replacing error tuple output
  743. 182 """
  744.  
  745. ...........................................................................
  746. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
  747. 220 log.debug("stopping")
  748. 221 break
  749. 222 # each nose.case.Test will create its own result proxy
  750. 223 # so the cases need the original result, to avoid proxy
  751. 224 # chains
  752. --> 225 test(orig)
  753. test = <nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>
  754. orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
  755. 226 finally:
  756. 227 self.has_run = True
  757. 228 try:
  758. 229 self.tearDown()
  759.  
  760. ...........................................................................
  761. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
  762. 173 def __hash__(self):
  763. 174 return object.__hash__(self)
  764. 175
  765. 176 # 2.3 compat -- force 2.4 call sequence
  766. 177 def __call__(self, *arg, **kw):
  767. --> 178 return self.run(*arg, **kw)
  768. self.run = <bound method ContextSuite.run of <nose.suite.Co...=pgmpy.tests.test_inference.test_ExactInference>>
  769. arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
  770. kw = {}
  771. 179
  772. 180 def exc_info(self):
  773. 181 """Hook for replacing error tuple output
  774. 182 """
  775.  
  776. ...........................................................................
  777. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
  778. 220 log.debug("stopping")
  779. 221 break
  780. 222 # each nose.case.Test will create its own result proxy
  781. 223 # so the cases need the original result, to avoid proxy
  782. 224 # chains
  783. --> 225 test(orig)
  784. test = <nose.suite.ContextSuite context=TestVariableElimination>
  785. orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
  786. 226 finally:
  787. 227 self.has_run = True
  788. 228 try:
  789. 229 self.tearDown()
  790.  
  791. ...........................................................................
  792. /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=TestVariableElimination>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
  793. 173 def __hash__(self):
  794. 174 return object.__hash__(self)
  795. 175
  796. 176 # 2.3 compat -- force 2.4 call sequence
  797. 177 def __call__(self, *arg, **kw):
  798. --> 178 return self.run(*arg, **kw)
  799. self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=TestVariableElimination>>
  800. arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
  801. kw = {}
  802. 179
  803. 180 def exc_info(self):
  804. 181 """Hook for replacing error tuple output
  805. 182 """
  806.  
  807. ...........................................................................
  808. /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=TestVariableElimination>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
  809. 220 log.debug("stopping")
  810. 221 break
  811. 222 # each nose.case.Test will create its own result proxy
  812. 223 # so the cases need the original result, to avoid proxy
  813. 224 # chains
  814. --> 225 test(orig)
  815. test = Test(<pgmpy.tests.test_inference.test_ExactInfer...thod=test_query_multiple_variable_with_evidence>)
  816. orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
  817. 226 finally:
  818. 227 self.has_run = True
  819. 228 try:
  820. 229 self.tearDown()
  821.  
  822. ...........................................................................
  823. /usr/local/lib/python3.4/dist-packages/nose/case.py in __call__(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...thod=test_query_multiple_variable_with_evidence>), *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kwarg={})
  824. 41 self.plugins = config.plugins
  825. 42 self.passed = None
  826. 43 unittest.TestCase.__init__(self)
  827. 44
  828. 45 def __call__(self, *arg, **kwarg):
  829. ---> 46 return self.run(*arg, **kwarg)
  830. self.run = <bound method Test.run of Test(<pgmpy.tests.test...hod=test_query_multiple_variable_with_evidence>)>
  831. arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
  832. kwarg = {}
  833. 47
  834. 48 def __str__(self):
  835. 49 name = self.plugins.testName(self)
  836. 50 if name is not None:
  837.  
  838. ...........................................................................
  839. /usr/local/lib/python3.4/dist-packages/nose/case.py in run(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...thod=test_query_multiple_variable_with_evidence>), result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
  840. 129 if self.resultProxy:
  841. 130 result = self.resultProxy(result, self)
  842. 131 try:
  843. 132 try:
  844. 133 self.beforeTest(result)
  845. --> 134 self.runTest(result)
  846. self.runTest = <bound method Test.runTest of Test(<pgmpy.tests....hod=test_query_multiple_variable_with_evidence>)>
  847. result = <nose.result.TextTestResult run=108 errors=1 failures=0>
  848. 135 except KeyboardInterrupt:
  849. 136 raise
  850. 137 except:
  851. 138 err = sys.exc_info()
  852.  
  853. ...........................................................................
  854. /usr/local/lib/python3.4/dist-packages/nose/case.py in runTest(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...thod=test_query_multiple_variable_with_evidence>), result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
  855. 147 """
  856. 148 test = self.test
  857. 149 plug_test = self.config.plugins.prepareTestCase(self)
  858. 150 if plug_test is not None:
  859. 151 test = plug_test
  860. --> 152 test(result)
  861. test = <pgmpy.tests.test_inference.test_ExactInference....ethod=test_query_multiple_variable_with_evidence>
  862. result = <nose.result.TextTestResult run=108 errors=1 failures=0>
  863. 153
  864. 154 def shortDescription(self):
  865. 155 desc = self.plugins.describeTest(self)
  866. 156 if desc is not None:
  867.  
  868. ...........................................................................
  869. /usr/lib/python3.4/unittest/case.py in __call__(self=<pgmpy.tests.test_inference.test_ExactInference....ethod=test_query_multiple_variable_with_evidence>, *args=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kwds={})
  870. 617 # return this for backwards compatibility
  871. 618 # even though we no longer us it internally
  872. 619 return outcome.success
  873. 620
  874. 621 def __call__(self, *args, **kwds):
  875. --> 622 return self.run(*args, **kwds)
  876. self.run = <bound method TestVariableElimination.run of <pg...thod=test_query_multiple_variable_with_evidence>>
  877. args = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
  878. kwds = {}
  879. 623
  880. 624 def debug(self):
  881. 625 """Run the test without collecting errors in a TestResult"""
  882. 626 self.setUp()
  883.  
  884. ...........................................................................
  885. /usr/lib/python3.4/unittest/case.py in run(self=<pgmpy.tests.test_inference.test_ExactInference....ethod=test_query_multiple_variable_with_evidence>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
  886. 569 with outcome.testPartExecutor(self):
  887. 570 self.setUp()
  888. 571 if outcome.success:
  889. 572 outcome.expecting_failure = expecting_failure
  890. 573 with outcome.testPartExecutor(self, isTest=True):
  891. --> 574 testMethod()
  892. testMethod = <bound method TestVariableElimination.test_query...thod=test_query_multiple_variable_with_evidence>>
  893. 575 outcome.expecting_failure = False
  894. 576 with outcome.testPartExecutor(self):
  895. 577 self.tearDown()
  896. 578
  897.  
  898. ...........................................................................
  899. /home/gokul/pgmpy_gk/pgmpy/pgmpy/tests/test_inference/test_ExactInference.py in test_query_multiple_variable_with_evidence(self=<pgmpy.tests.test_inference.test_ExactInference....ethod=test_query_multiple_variable_with_evidence>)
  900. 54 np.array([0.60, 0.40]))
  901. 55
  902. 56 def test_query_multiple_variable_with_evidence(self):
  903. 57 query_result = self.bayesian_inference.query(variables=['J', 'Q'],
  904. 58 evidence={'A': 0, 'R': 0,
  905. ---> 59 'G': 0, 'L': 1})
  906. 60 np_test.assert_array_almost_equal(query_result['J'].values,
  907. 61 np.array([0.818182, 0.181818]))
  908. 62 np_test.assert_array_almost_equal(query_result['Q'].values,
  909. 63 np.array([0.772727, 0.227273]))
  910.  
  911. ...........................................................................
  912. /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in query(self=<pgmpy.inference.ExactInference.VariableElimination object>, variables=['J', 'Q'], evidence={'A': 0, 'G': 0, 'L': 1, 'R': 0}, elimination_order=None)
  913. 110 >>> model.fit(values)
  914. 111 >>> inference = VariableElimination(model)
  915. 112 >>> phi_query = inference.query(['A', 'B'])
  916. 113 """
  917. 114 return self._variable_elimination(variables, 'marginalize',
  918. --> 115 evidence=evidence, elimination_order=elimination_order)
  919. evidence = {'A': 0, 'G': 0, 'L': 1, 'R': 0}
  920. elimination_order = None
  921. 116
  922. 117 def max_marginal(self, variables=None, evidence=None, elimination_order=None):
  923. 118 """
  924. 119 Computes the max-marginal over the variables given the evidence.
  925.  
  926. ...........................................................................
  927. /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in _variable_elimination(self=<pgmpy.inference.ExactInference.VariableElimination object>, variables=['J', 'Q'], operation='marginalize', evidence={'A': 0, 'G': 0, 'L': 1, 'R': 0}, elimination_order=None)
  928. 45 for node in self.factors}
  929. 46
  930. 47 # Dealing with evidence. Reducing factors over it before VE is run.
  931. 48
  932. 49 if evidence: #Implementation of a parallel looping construct
  933. ---> 50 Parallel(n_jobs=-1, backend="threading") (delayed(self. parallelFor)(evidence_var,working_factors,evidence)for evidence_var in evidence)
  934. self.parallelFor = <bound method VariableElimination.parallelFor of...rence.ExactInference.VariableElimination object>>
  935. evidence = {'A': 0, 'G': 0, 'L': 1, 'R': 0}
  936. 51 # TODO: Modify it to find the optimal elimination order
  937. 52 if not elimination_order:
  938. 53 elimination_order = list(set(self.variables) -
  939. 54 set(variables) -
  940.  
  941. ...........................................................................
  942. /usr/local/lib/python3.4/dist-packages/joblib/parallel.py in __call__(self=Parallel(n_jobs=-1), iterable=<generator object <genexpr>>)
  943. 655 if pre_dispatch == "all" or n_jobs == 1:
  944. 656 # The iterable was consumed all at once by the above for loop.
  945. 657 # No need to wait for async callbacks to trigger to
  946. 658 # consumption.
  947. 659 self._iterating = False
  948. --> 660 self.retrieve()
  949. self.retrieve = <bound method Parallel.retrieve of Parallel(n_jobs=-1)>
  950. 661 # Make sure that we get a last message telling us we are done
  951. 662 elapsed_time = time.time() - self._start_time
  952. 663 self._print('Done %3i out of %3i | elapsed: %s finished',
  953. 664 (len(self._output),
  954.  
  955. ---------------------------------------------------------------------------
  956. Sub-process traceback:
  957. ---------------------------------------------------------------------------
  958. KeyError Fri Mar 6 23:06:30 2015
  959. PID: 19709 Python 3.4.0: /usr/bin/python3
  960. ...........................................................................
  961. /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in parallelFor(self=<pgmpy.inference.ExactInference.VariableElimination object>, evidence_var='A', working_factors={'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'J': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>])}, evidence={'A': 0, 'G': 0, 'L': 1, 'R': 0})
  962. 10 def parallelFor(self, evidence_var,working_factors,evidence):
  963. 11
  964. 12 for factor in working_factors[evidence_var]:
  965. 13 factor_reduced = factor.reduce('{evidence_var}_{state}'.format(evidence_var=evidence_var,state=evidence[evidence_var]),inplace=False)
  966. 14 for var in factor_reduced.scope():
  967. ---> 15 working_factors[var].remove(factor)
  968. working_factors = {'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'J': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>])}
  969. var.remove = undefined
  970. factor = <pgmpy.factors.Factor.Factor object>
  971. 16 working_factors[var].add(factor_reduced)
  972. 17 del working_factors[evidence_var]
  973. 18
  974. 19 def _variable_elimination(self, variables, operation, evidence=None, elimination_order=None):
  975.  
  976. KeyError: <pgmpy.factors.Factor.Factor object at 0x7f4e4a966400>
  977. ___________________________________________________________________________
  978.  
  979. ----------------------------------------------------------------------
  980. Ran 253 tests in 1.379s
  981.  
  982. FAILED (SKIP=3, errors=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement