compiled-knowledge 4.0.0a24__tar.gz → 4.0.0a25__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of compiled-knowledge might be problematic. Click here for more details.

Files changed (185) hide show
  1. {compiled_knowledge-4.0.0a24/src/compiled_knowledge.egg-info → compiled_knowledge-4.0.0a25}/PKG-INFO +1 -1
  2. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/pyproject.toml +2 -1
  3. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit/tmp_const.py +5 -4
  4. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/support/llvm_ir_function.py +4 -4
  5. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/diamond_square.py +3 -1
  6. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/triangle_square.py +3 -1
  7. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/truss.py +3 -1
  8. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/in_out/parse_net.py +21 -19
  9. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/in_out/parser_utils.py +7 -3
  10. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm.py +67 -58
  11. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_circuit/mpe_program.py +3 -4
  12. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_circuit/pgm_circuit.py +27 -18
  13. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_circuit/program_with_slotmap.py +4 -1
  14. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/probability/probability_space.py +10 -11
  15. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/program/raw_program.py +23 -16
  16. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/sampling/sampler_support.py +5 -6
  17. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/utils/iter_extras.py +3 -2
  18. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/utils/local_config.py +16 -8
  19. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25/src/compiled_knowledge.egg-info}/PKG-INFO +1 -1
  20. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/LICENSE.txt +0 -0
  21. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/MANIFEST.in +0 -0
  22. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/README.md +0 -0
  23. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/setup.cfg +0 -0
  24. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/setup.py +0 -0
  25. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/__init__.py +0 -0
  26. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit/__init__.py +0 -0
  27. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit/_circuit_cy.c +0 -0
  28. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit/_circuit_cy.pxd +0 -0
  29. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit/_circuit_cy.pyx +0 -0
  30. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit/_circuit_py.py +0 -0
  31. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/__init__.py +0 -0
  32. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/circuit_compiler.py +0 -0
  33. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/cython_vm_compiler/__init__.py +0 -0
  34. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/cython_vm_compiler/_compiler.c +0 -0
  35. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/cython_vm_compiler/_compiler.pyx +0 -0
  36. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/cython_vm_compiler/cython_vm_compiler.py +0 -0
  37. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/interpret_compiler.py +0 -0
  38. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/llvm_compiler.py +0 -0
  39. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/llvm_vm_compiler.py +0 -0
  40. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/named_circuit_compilers.py +0 -0
  41. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/support/__init__.py +0 -0
  42. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/support/circuit_analyser/__init__.py +0 -0
  43. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/support/circuit_analyser/_circuit_analyser_cy.c +0 -0
  44. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/support/circuit_analyser/_circuit_analyser_cy.pyx +0 -0
  45. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/support/circuit_analyser/_circuit_analyser_py.py +0 -0
  46. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/circuit_compiler/support/input_vars.py +0 -0
  47. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/__init__.py +0 -0
  48. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/alarm.py +0 -0
  49. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/asia.py +0 -0
  50. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/binary_clique.py +0 -0
  51. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/bow_tie.py +0 -0
  52. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/cancer.py +0 -0
  53. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/chain.py +0 -0
  54. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/child.py +0 -0
  55. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/clique.py +0 -0
  56. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/cnf_pgm.py +0 -0
  57. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/earthquake.py +0 -0
  58. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/empty.py +0 -0
  59. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/hailfinder.py +0 -0
  60. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/hepar2.py +0 -0
  61. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/insurance.py +0 -0
  62. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/loop.py +0 -0
  63. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/mildew.py +0 -0
  64. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/munin.py +0 -0
  65. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/pathfinder.py +0 -0
  66. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/rain.py +0 -0
  67. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/rectangle.py +0 -0
  68. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/run.py +0 -0
  69. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/sachs.py +0 -0
  70. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/sprinkler.py +0 -0
  71. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/star.py +0 -0
  72. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/stress.py +0 -0
  73. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/student.py +0 -0
  74. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/example/survey.py +0 -0
  75. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/in_out/__init__.py +0 -0
  76. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/in_out/parse_ace_lmap.py +0 -0
  77. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/in_out/parse_ace_nnf.py +0 -0
  78. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/in_out/pgm_pickle.py +0 -0
  79. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/in_out/pgm_python.py +0 -0
  80. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/in_out/render_bugs.py +0 -0
  81. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/in_out/render_net.py +0 -0
  82. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/in_out/render_pomegranate.py +0 -0
  83. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_circuit/__init__.py +0 -0
  84. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_circuit/marginals_program.py +0 -0
  85. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_circuit/slot_map.py +0 -0
  86. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_circuit/support/__init__.py +0 -0
  87. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_circuit/support/compile_circuit.py +0 -0
  88. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_circuit/target_marginals_program.py +0 -0
  89. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_circuit/wmc_program.py +0 -0
  90. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/__init__.py +0 -0
  91. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/ace/__init__.py +0 -0
  92. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/ace/ace.py +0 -0
  93. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/factor_elimination.py +0 -0
  94. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/named_pgm_compilers.py +0 -0
  95. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/pgm_compiler.py +0 -0
  96. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/recursive_conditioning.py +0 -0
  97. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/support/__init__.py +0 -0
  98. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/support/circuit_table/__init__.py +0 -0
  99. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/support/circuit_table/_circuit_table_cy.c +0 -0
  100. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/support/circuit_table/_circuit_table_cy.pyx +0 -0
  101. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/support/circuit_table/_circuit_table_py.py +0 -0
  102. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/support/clusters.py +0 -0
  103. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/support/factor_tables.py +0 -0
  104. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/support/join_tree.py +0 -0
  105. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/support/named_compiler_maker.py +0 -0
  106. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/pgm_compiler/variable_elimination.py +0 -0
  107. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/probability/__init__.py +0 -0
  108. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/probability/empirical_probability_space.py +0 -0
  109. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/probability/pgm_probability_space.py +0 -0
  110. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/program/__init__.py +0 -0
  111. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/program/program.py +0 -0
  112. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/program/program_buffer.py +0 -0
  113. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/sampling/__init__.py +0 -0
  114. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/sampling/forward_sampler.py +0 -0
  115. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/sampling/marginals_direct_sampler.py +0 -0
  116. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/sampling/sampler.py +0 -0
  117. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/sampling/uniform_sampler.py +0 -0
  118. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/sampling/wmc_direct_sampler.py +0 -0
  119. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/sampling/wmc_gibbs_sampler.py +0 -0
  120. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/sampling/wmc_metropolis_sampler.py +0 -0
  121. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/sampling/wmc_rejection_sampler.py +0 -0
  122. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/utils/__init__.py +0 -0
  123. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/utils/map_list.py +0 -0
  124. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/utils/map_set.py +0 -0
  125. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/utils/np_extras.py +0 -0
  126. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/utils/random_extras.py +0 -0
  127. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck/utils/tmp_dir.py +0 -0
  128. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/__init__.py +0 -0
  129. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/ace/__init__.py +0 -0
  130. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/ace/copy_ace_to_ck.py +0 -0
  131. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/ace/demo_ace.py +0 -0
  132. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/ace/simple_ace_demo.py +0 -0
  133. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/all_demos.py +0 -0
  134. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/circuit/__init__.py +0 -0
  135. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/circuit/demo_circuit_dump.py +0 -0
  136. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/circuit/demo_derivatives.py +0 -0
  137. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/circuit_compiler/__init__.py +0 -0
  138. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/circuit_compiler/compare_circuit_compilers.py +0 -0
  139. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/circuit_compiler/show_llvm_program.py +0 -0
  140. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/getting_started/__init__.py +0 -0
  141. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/getting_started/simple_demo.py +0 -0
  142. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm/__init__.py +0 -0
  143. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm/demo_pgm_dump.py +0 -0
  144. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm/demo_pgm_dump_stress.py +0 -0
  145. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm/demo_pgm_string_rendering.py +0 -0
  146. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm/show_examples.py +0 -0
  147. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/__init__.py +0 -0
  148. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/compare_pgm_compilers.py +0 -0
  149. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/demo_compiler_dump.py +0 -0
  150. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/demo_factor_elimination.py +0 -0
  151. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/demo_join_tree.py +0 -0
  152. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/demo_marginals_program.py +0 -0
  153. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/demo_mpe_program.py +0 -0
  154. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/demo_pgm_compiler.py +0 -0
  155. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/demo_recursive_conditioning.py +0 -0
  156. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/demo_variable_elimination.py +0 -0
  157. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/demo_wmc_program.py +0 -0
  158. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_compiler/time_fe_compiler.py +0 -0
  159. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_inference/__init__.py +0 -0
  160. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_inference/demo_inferencing_basic.py +0 -0
  161. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_inference/demo_inferencing_mpe_cancer.py +0 -0
  162. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_inference/demo_inferencing_wmc_and_mpe_sprinkler.py +0 -0
  163. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/pgm_inference/demo_inferencing_wmc_student.py +0 -0
  164. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/programs/__init__.py +0 -0
  165. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/programs/demo_program_buffer.py +0 -0
  166. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/programs/demo_program_multi.py +0 -0
  167. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/programs/demo_program_none.py +0 -0
  168. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/programs/demo_program_single.py +0 -0
  169. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/programs/demo_raw_program_dump.py +0 -0
  170. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/programs/demo_raw_program_interpreted.py +0 -0
  171. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/programs/demo_raw_program_llvm.py +0 -0
  172. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/sampling/__init__.py +0 -0
  173. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/sampling/check_sampler.py +0 -0
  174. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/sampling/demo_marginal_direct_sampler.py +0 -0
  175. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/sampling/demo_uniform_sampler.py +0 -0
  176. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/sampling/demo_wmc_direct_sampler.py +0 -0
  177. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/utils/__init__.py +0 -0
  178. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/utils/compare.py +0 -0
  179. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/utils/convert_network.py +0 -0
  180. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/utils/sample_model.py +0 -0
  181. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/ck_demos/utils/stop_watch.py +0 -0
  182. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/compiled_knowledge.egg-info/SOURCES.txt +0 -0
  183. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/compiled_knowledge.egg-info/dependency_links.txt +0 -0
  184. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/compiled_knowledge.egg-info/requires.txt +0 -0
  185. {compiled_knowledge-4.0.0a24 → compiled_knowledge-4.0.0a25}/src/compiled_knowledge.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compiled-knowledge
3
- Version: 4.0.0a24
3
+ Version: 4.0.0a25
4
4
  Summary: A Python package for compiling and querying discrete probabilistic graphical models.
5
5
  Author-email: Barry Drake <barry@compiledknowledge.org>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "compiled-knowledge"
3
- version = "4.0.0a24"
3
+ version = "4.0.0a25"
4
4
  description = "A Python package for compiling and querying discrete probabilistic graphical models."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -36,6 +36,7 @@ setuptools = "*"
36
36
  build = "*"
37
37
  cibuildwheel = "*"
38
38
  jupyter-book = "*"
39
+ sphinx = "*"
39
40
  twine = "*"
40
41
  toml = "*"
41
42
 
@@ -10,15 +10,16 @@ class TmpConst:
10
10
  A TmpConst enables the consistent, temporary setting and clearing
11
11
  of circuit variables to constant values.
12
12
 
13
- Example usage:
13
+ Example usage::
14
+
14
15
  with TmpConst(my_circuit) as tmp:
15
16
  tmp.set_const(0, 123.456)
16
17
  tmp.set_const(my_list_of_vars, 110.99)
17
18
  program = Program(my_top)
18
- # now use 'program'
19
+ # now use `program`
19
20
 
20
- Within the 'with' section, circuit variables are set to const values, which
21
- the compiler can optimise. When the 'with' section exits, the variables
21
+ Within the `with` section, circuit variables are set to const values, which
22
+ the compiler can optimise. When the `with` section exits, the variables
22
23
  are restored to their original state.
23
24
  """
24
25
  __slots__ = ('_circuit', '_undo')
@@ -213,10 +213,10 @@ def compile_llvm_program(
213
213
  Compile the given LLVM program.
214
214
 
215
215
  Returns:
216
- (engine, function) where
217
- engine: is an LLVM execution engine, which must remain
218
- in memory for the returned function to be valid.
219
- function: is the raw Python callable for the compiled function.
216
+ `engine` an LLVM execution engine, which must remain
217
+ in memory for the returned function to be valid,
218
+
219
+ `function` the raw Python callable for the compiled function.
220
220
  """
221
221
  _init_llvm()
222
222
 
@@ -8,7 +8,8 @@ class DiamondSquare(PGM):
8
8
  This PGM is the 'DiamondSquare' factor graph.
9
9
 
10
10
  The DiamondSquare is a factor graph with seven random variables (a, b, c, ..., h).
11
- Binary factors are between pairs of random variables creating the pattern:
11
+ Binary factors are between pairs of random variables creating the pattern::
12
+
12
13
  b
13
14
  / \
14
15
  / \
@@ -20,6 +21,7 @@ class DiamondSquare(PGM):
20
21
  \ /
21
22
  \ /
22
23
  g
24
+
23
25
  If include_unaries then, also includes one unary factor per random variable.
24
26
  """
25
27
 
@@ -8,12 +8,14 @@ class TriangleSquare(PGM):
8
8
  This PGM is the 'TriangleSquare' factor graph.
9
9
 
10
10
  The TriangleSquare is a factor graph with six random variables (a, b, c, ..., f).
11
- Binary factors are between pairs of random variables crating the pattern:
11
+ Binary factors are between pairs of random variables crating the pattern::
12
+
12
13
  b -- d
13
14
  / | | \
14
15
  a | | f
15
16
  \ | | /
16
17
  c -- e
18
+
17
19
  If include_unaries then, also includes one unary factor per random variable.
18
20
  """
19
21
 
@@ -7,12 +7,14 @@ class Truss(PGM):
7
7
  This PGM is the 'Truss' factor graph.
8
8
 
9
9
  The Truss is a factor graph with five random variables (a, b, c, d, e).
10
- Binary factors are between pairs of random variables creating the pattern:
10
+ Binary factors are between pairs of random variables creating the pattern::
11
+
11
12
  b ---- d
12
13
  / | / |
13
14
  a | / |
14
15
  \ | / |
15
16
  c ---- e
17
+
16
18
  If include_unaries then, also includes one unary factor per random variable.
17
19
  """
18
20
 
@@ -16,36 +16,37 @@ def read_network(input_stream, *, name: Optional[str] = None, network_builder: O
16
16
  The input can be a string or a stream.
17
17
  If the input is empty, then its is treated as an error.
18
18
 
19
- This input is expected to conform to the following format.
19
+ This input is expected to conform to the following format::
20
20
 
21
- <network> ::= <net_block> <node_block>* <potential_block>*
21
+ <network> ::= <net_block> <node_block>* <potential_block>*
22
22
 
23
- <net_block> ::= 'net' <block>
23
+ <net_block> ::= 'net' <block>
24
24
 
25
- <node_block> ::= 'node' <NAME> <block>
25
+ <node_block> ::= 'node' <NAME> <block>
26
26
 
27
- <potential_block> ::= 'potential' <link> <block>
27
+ <potential_block> ::= 'potential' <link> <block>
28
28
 
29
- <block> ::= '{' <sentence>* '}'
30
- <sentence> ::= <NAME> '=' <value> ';'
29
+ <block> ::= '{' <sentence>* '}'
30
+ <sentence> ::= <NAME> '=' <value> ';'
31
31
 
32
- <link> ::= '(' <NAME> ')'
33
- | '(' <NAME> '|' <NAME>+ ')'
32
+ <link> ::= '(' <NAME> ')'
33
+ | '(' <NAME> '|' <NAME>+ ')'
34
34
 
35
- <value> ::= <STRING> | <NUMBER> | <list>
36
- <list> ::='(' <value>* ')'
35
+ <value> ::= <STRING> | <NUMBER> | <list>
36
+ <list> ::='(' <value>* ')'
37
37
 
38
38
  The sentences of a <net_block> are ignored.
39
39
 
40
- The sentences of a <node_block>
41
- <name> of 'states' mandatory, with value that is a list of <STRING>
42
- other sentences are ignored.
40
+ In a <node_block>,
41
+ <name> of 'states' mandatory, with value that is a list of <STRING>
42
+ other sentences are ignored.
43
43
 
44
- The sentences of a <potential_block>
45
- <name> of 'data' mandatory, with value that is a list of (list of)* <NUMBER> (shape matching the link)
46
- other sentences are ignored.
44
+ In a <potential_block>,
45
+ <name> of 'data' is mandatory, with value that is a list of (list of) <NUMBER> (shape matching the link)
46
+ other sentences are ignored.
47
+
48
+ Here is a simple example input::
47
49
 
48
- Here is a simple example input:
49
50
  net{}
50
51
  node a
51
52
  {
@@ -62,8 +63,9 @@ def read_network(input_stream, *, name: Optional[str] = None, network_builder: O
62
63
  }
63
64
  potential ( b | a )
64
65
  {
65
- data = ((0.4 0.4 0.2)(0.4 0.4 0.2)) ;
66
+ data = ((0.4 0.4 0.2)(0.4 0.4 0.2));
66
67
  }
68
+
67
69
  """
68
70
  # Decorate the input stream
69
71
  input_stream = ParserInput(input_stream)
@@ -57,8 +57,10 @@ class ParserInput:
57
57
 
58
58
  def readline(self) -> str:
59
59
  """
60
+ Read a line of input.
61
+
60
62
  Returns:
61
- the next line (including the trailing '\n') or '' if EOF.
63
+ the next line (including the trailing newline) or empty string if EOF.
62
64
  """
63
65
  line = ''
64
66
  while True:
@@ -69,9 +71,11 @@ class ParserInput:
69
71
 
70
72
  def read_past_space(self, single_line: bool, comment_char=None) -> str:
71
73
  """
74
+ Read the input up to and including the first non-whitespace character.
75
+
72
76
  Returns:
73
- either empty string, '', if end of input, otherwise a single character string that is not whitespace.
74
- If single_line is True, then '\n' is treated as eof.
77
+ either empty string, if end of input, otherwise a single character string that is not whitespace.
78
+ If single_line is True, then newline is treated as eof.
75
79
  """
76
80
  c = self.read_one()
77
81
  while True:
@@ -15,33 +15,32 @@ from ck.utils.iter_extras import (
15
15
  from ck.utils.np_extras import NDArrayFloat64, NDArrayUInt8
16
16
 
17
17
  State: TypeAlias = Union[int, str, bool, float, None]
18
- State.__doc__ = \
19
- """
20
- The type for a possible state of a random variable.
21
- """
18
+ """
19
+ The type for a possible state of a random variable.
20
+ """
22
21
 
23
22
  Instance: TypeAlias = Sequence[int]
24
- Instance.__doc__ = \
25
- """
26
- An instance (of a sequence of random variables) is a sequence of integers
27
- that are state indexes, co-indexed with a known sequence of random variables.
28
- """
23
+ """
24
+ An instance (of a sequence of random variables) is a sequence of integers
25
+ that are state indexes, co-indexed with a known sequence of random variables.
26
+ """
29
27
 
30
28
  Key: TypeAlias = Union[Instance, int]
31
- Key.__doc__ = \
32
- """
33
- A key identifies an instance, either as an instance itself or a
34
- single integer, representing an instance with one dimension.
35
- """
29
+ """
30
+ A key identifies an instance, either as an instance itself or a
31
+ single integer, representing an instance with one dimension.
32
+ """
36
33
 
37
34
  Shape: TypeAlias = Sequence[int]
38
- Key.__doc__ = \
39
- """
40
- The type for the "shape" of a sequence of random variables.
41
- That is, the shape of (rv1, rv2, rv3) is (len(rv1), len(rv2), len(rv3)).
42
- """
35
+ """
36
+ The type for the "shape" of a sequence of random variables.
37
+ That is, the shape of (rv1, rv2, rv3) is (len(rv1), len(rv2), len(rv3)).
38
+ """
43
39
 
44
- DEFAULT_CPT_TOLERANCE: float = 0.000001 # A tolerance when checking CPT distributions sum to one (or zero).
40
+ DEFAULT_CPT_TOLERANCE: float = 0.000001
41
+ """
42
+ A tolerance when checking CPT distributions sum to one (or zero).
43
+ """
45
44
 
46
45
 
47
46
  class PGM:
@@ -214,14 +213,17 @@ class PGM:
214
213
  The returned random variable will have an `idx` equal to the value of
215
214
  `self.number_of_rvs` just prior to adding the new random variable.
216
215
 
216
+ The states of the random variable can be specified either as an integer
217
+ representing the number of states, or as a sequence of state values. If a
218
+ single integer, `n`, is provided then the states will be: 0, 1, ..., n-1.
219
+ If a sequence of states are provided then the states must be unique.
220
+
217
221
  Assumes:
218
222
  Provided states contain no duplicates.
219
223
 
220
224
  Args:
221
225
  name: a name for the random variable.
222
- states: either an integer number of states or a sequence of state values. If a
223
- single integer, `n`, is provided then the states will be 0, 1, ..., n-1.
224
- If a sequence of states are provided then the states must be unique.
226
+ states: either the number of states or a sequence of state values.
225
227
 
226
228
  Returns:
227
229
  a RandomVariable object belonging to this PGM.
@@ -241,10 +243,11 @@ class PGM:
241
243
 
242
244
  Assumes:
243
245
  The given random variables all belong to this PGM.
246
+
244
247
  The random variables contain no duplicates.
245
248
 
246
249
  Args:
247
- *rvs: the random variables.
250
+ rvs: the random variables.
248
251
 
249
252
  Returns:
250
253
  a Factor object belonging to this PGM.
@@ -336,17 +339,18 @@ class PGM:
336
339
  *input_rvs: RandomVariable
337
340
  ) -> Factor:
338
341
  """
339
- Add a sparse 0/1 factor to this PGM representing:
340
- result_rv == function(*rvs).
341
- That is:
342
+ Add a sparse 0/1 factor to this PGM representing `result_rv == function(*rvs)`.
343
+ That is::
344
+
342
345
  factor[result_s, *input_s] = 1, if result_s == function(*input_s);
343
346
  = 0, otherwise.
347
+
344
348
  Args:
345
349
  function: a function from state indexes of the input random variables to a state index
346
350
  of the result random variable. The function should take the same number of arguments
347
351
  as `input_rvs` and return a state index for `result_rv`.
348
352
  result_rv: the random variable defining result values.
349
- *input_rvs: the random variables defining input values.
353
+ input_rvs: the random variables defining input values.
350
354
 
351
355
  Returns:
352
356
  a Factor object belonging to this PGM, with a configured sparse potential function.
@@ -378,16 +382,17 @@ class PGM:
378
382
  """
379
383
  Render indicators as a string.
380
384
 
381
- For example:
385
+ For example::
382
386
  pgm = PGM()
383
387
  a = pgm.new_rv('A', ('x', 'y', 'z'))
384
388
  b = pgm.new_rv('B', (3, 5))
385
389
  print(pgm.indicator_str(a[0], b[1], a[2]))
386
- will print:
390
+
391
+ will print::
387
392
  A=x, B=5, A=z
388
393
 
389
394
  Args:
390
- *indicators: the indicators to render.
395
+ indicators: the indicators to render.
391
396
  sep: the separator to use between the random variable and its state.
392
397
  delim: the delimiter to used when rendering multiple indicators.
393
398
 
@@ -406,16 +411,17 @@ class PGM:
406
411
  """
407
412
  Render indicators as a string, grouping indicators by random variable.
408
413
 
409
- For example:
414
+ For example::
410
415
  pgm = PGM()
411
416
  a = pgm.new_rv('A', ('x', 'y', 'z'))
412
417
  b = pgm.new_rv('B', (3, 5))
413
418
  print(pgm.condition_str(a[0], b[1], a[2]))
414
- will print:
419
+
420
+ will print::
415
421
  A in {x, z}, B=5
416
422
 
417
423
  Args:
418
- *indicators: the indicators to render.
424
+ indicators: the indicators to render.
419
425
  Return:
420
426
  a string representation of the given indicators, as a condition.
421
427
  """
@@ -930,9 +936,9 @@ class RandomVariable(Sequence[Indicator]):
930
936
  in the random variable's PGM list of random variables.
931
937
 
932
938
  A random variable behaves like a sequence of Indicators, where each indicator represents a random
933
- variable being in a particular state. Specifically for a random variable rv, len(rv) is the
939
+ variable being in a particular state. Specifically for a random variable rv, `len(rv)` is the
934
940
  number of states of the random variable and rv[i] is the Indicators representing that
935
- rv is in the ith state. When sliced, the result is a tuple, i.e. rv[1:3] = (rv[1], rv[2]).
941
+ rv is in the ith state. When sliced, the result is a tuple, i.e. `rv[1:3] = (rv[1], rv[2])`.
936
942
 
937
943
  A RandomVariable has a name. This is for human convenience and has no functional purpose
938
944
  within a PGM.
@@ -942,15 +948,18 @@ class RandomVariable(Sequence[Indicator]):
942
948
  """
943
949
  Create a new random variable, in the given PGM.
944
950
 
951
+ The states of the random variable can be specified either as an integer
952
+ representing the number of states, or as a sequence of state values. If a
953
+ single integer, `n`, is provided then the states will be: 0, 1, ..., n-1.
954
+ If a sequence of states are provided then the states must be unique.
955
+
945
956
  Assumes:
946
957
  Provided states contain no duplicates.
947
958
 
948
959
  Args:
949
960
  pgm: the PGM that the random variable will belong to.
950
961
  name: a name for the random variable.
951
- states: either an integer number of states or a sequence of state values. If a
952
- single integer, `n`, is provided then the states will be 0, 1, ..., n-1.
953
- If a sequence of states are provided then the states must be unique.
962
+ states: either the number of states or a sequence of state values.
954
963
  """
955
964
  self._pgm: PGM = pgm
956
965
  self._name: str = name
@@ -1212,15 +1221,14 @@ class RVMap(Sequence[RandomVariable]):
1212
1221
  In addition to accessing a random variable by its index, an RVMap enables
1213
1222
  access to the PGM random variable via the name of each random variable.
1214
1223
 
1215
- For example, if `pgm.rvs[1]` is a random variable named `xray`, then:
1216
- ```
1217
- rvs = RVMap(pgm)
1224
+ For example, if `pgm.rvs[1]` is a random variable named `xray`, then::
1225
+
1226
+ rvs = RVMap(pgm)
1218
1227
 
1219
- # These all retrieve the same random variable object.
1220
- xray = rvs[1]
1221
- xray = rvs('xray')
1222
- xray = rvs.xray
1223
- ```
1228
+ # These all retrieve the same random variable object.
1229
+ xray = rvs[1]
1230
+ xray = rvs('xray')
1231
+ xray = rvs.xray
1224
1232
 
1225
1233
  To use an RVMap on a PGM, the random variable names must be unique across the PGM.
1226
1234
  """
@@ -1527,7 +1535,7 @@ class Factor:
1527
1535
  Set to the potential function to a new `ClausePotentialFunction` object.
1528
1536
 
1529
1537
  Args:
1530
- *key: defines the random variable states of the clause. The key is a sequence of
1538
+ key: defines the random variable states of the clause. The key is a sequence of
1531
1539
  random variable state indexes, co-indexed with `Factor.rvs`.
1532
1540
 
1533
1541
  Returns:
@@ -1556,7 +1564,7 @@ class Factor:
1556
1564
  return self._potential_function
1557
1565
 
1558
1566
 
1559
- @dataclass(frozen=True, eq=True)
1567
+ @dataclass(frozen=True, eq=True, slots=True)
1560
1568
  class ParamId:
1561
1569
  """
1562
1570
  A ParamId identifies a parameter of a potential function.
@@ -2164,7 +2172,7 @@ class DensePotentialFunction(PotentialFunction):
2164
2172
  """
2165
2173
  Set the values of the potential function using the given iterator.
2166
2174
 
2167
- Mapping instances to *values is as follows:
2175
+ Mapping instances to values is as follows:
2168
2176
  Given Factor(rv1, rv2) where rv1 has 2 states, and rv2 has 3 states:
2169
2177
  values[0] represents instance (0,0)
2170
2178
  values[1] represents instance (0,1)
@@ -2209,7 +2217,7 @@ class DensePotentialFunction(PotentialFunction):
2209
2217
  The order of values is the same as set_iter.
2210
2218
 
2211
2219
  Args:
2212
- *value: the values to use.
2220
+ value: the values to use.
2213
2221
 
2214
2222
  Returns:
2215
2223
  self
@@ -2414,7 +2422,7 @@ class SparsePotentialFunction(PotentialFunction):
2414
2422
  """
2415
2423
  Set the values of the potential function using the given iterator.
2416
2424
 
2417
- Mapping instances to *values is as follows:
2425
+ Mapping instances to values is as follows:
2418
2426
  Given Factor(rv1, rv2) where rv1 has 2 states, and rv2 has 3 states:
2419
2427
  values[0] represents instance (0,0)
2420
2428
  values[1] represents instance (0,1)
@@ -2636,7 +2644,7 @@ class CompactPotentialFunction(PotentialFunction):
2636
2644
  """
2637
2645
  Set the values of the potential function using the given iterator.
2638
2646
 
2639
- Mapping instances to *values is as follows:
2647
+ Mapping instances to `values` is as follows:
2640
2648
  Given Factor(rv1, rv2) where rv1 has 2 states, and rv2 has 3 states:
2641
2649
  values[0] represents instance (0,0)
2642
2650
  values[1] represents instance (0,1)
@@ -2679,7 +2687,7 @@ class CompactPotentialFunction(PotentialFunction):
2679
2687
  The order of values is the same as set_iter.
2680
2688
 
2681
2689
  Args:
2682
- *value: the values to use.
2690
+ value: the values to use.
2683
2691
 
2684
2692
  Returns:
2685
2693
  self
@@ -3071,7 +3079,8 @@ class CPTPotentialFunction(PotentialFunction):
3071
3079
  Calls self.set_cpd(parent_states, cpd) for each row (parent_states, cpd)
3072
3080
  in rows. Any unmentioned parent states will have zero probabilities.
3073
3081
 
3074
- Example usage, assuming three Boolean random variables:
3082
+ Example usage, assuming three Boolean random variables::
3083
+
3075
3084
  pgm.Factor(x, y, z).set_cpt().set(
3076
3085
  # y z x[0] x[1]
3077
3086
  ((0, 0), (0.1, 0.9)),
@@ -3079,9 +3088,9 @@ class CPTPotentialFunction(PotentialFunction):
3079
3088
  ((1, 0), (0.1, 0.9)),
3080
3089
  ((1, 1), (0.1, 0.9))
3081
3090
  )
3082
-
3091
+
3083
3092
  Args:
3084
- *rows: are tuples (key, cpd) used to set the potential function values.
3093
+ rows: are tuples (key, cpd) used to set the potential function values.
3085
3094
 
3086
3095
  Raises:
3087
3096
  ValueError: if a CPD is not valid.
@@ -3105,7 +3114,7 @@ class CPTPotentialFunction(PotentialFunction):
3105
3114
  Any list entry may be None, indicating 'guaranteed zero' for the associated parent states.
3106
3115
 
3107
3116
  Args:
3108
- *cpds: are the CPDs used to set the potential function values.
3117
+ cpds: are the CPDs used to set the potential function values.
3109
3118
 
3110
3119
  Raises:
3111
3120
  ValueError: if a CPD is not valid.
@@ -228,10 +228,9 @@ class MPEProgram(ProgramWithSlotmap):
228
228
  class MPEResult:
229
229
  """
230
230
  An MPE result is the result of MPE inference.
231
-
232
- Fields:
233
- wmc: the weighted model count value of the MPE solution.
234
- mpe: The MPE solution instance. If there are ties then this will just be once instance.
235
231
  """
236
232
  wmc: float
233
+ """the weighted model count value of the MPE solution."""
234
+
237
235
  mpe: Instance
236
+ """the MPE solution instance. If there are ties then this will just be once instance."""
@@ -16,33 +16,42 @@ class PGMCircuit:
16
16
  holds the values of the parameters. Specifically, given parameter id `param_id`, then
17
17
  `parameter_values[slot_map[param_id] - number_of_indicators]` is the value of the
18
18
  identified parameter as it was in the PGM.
19
-
20
- Fields:
21
- rvs: holds the random variables from the PGM as it was compiled, in order.
22
-
23
- conditions: any conditions on `rvs` that were compiled into the circuit.
24
-
25
- number_of_indicators: is the number of indicators in `rvs` which is
26
- `sum(len(rv) for rv in rvs`. Specifically, `circuit.vars[i]` is the circuit variable
27
- corresponding to the ith indicator, where `circuit` is `circuit_top.circuit` and
28
- indicators are ordered as per `rvs`.
29
-
30
- number_of_parameters: is the number of parameters from the PGM that are
31
- represented as circuit variables. This may be zero if parameters from the PGM
32
- were compiled as constants.
33
-
34
- slot_map[x]: gives the index of the circuit variable corresponding to x,
35
- where x is either a random variable indicator (Indicator) or a parameter id (ParamId).
36
-
37
19
  """
38
20
 
39
21
  rvs: Sequence[RandomVariable]
22
+ """holds the random variables from the PGM as it was compiled, in order."""
23
+
40
24
  conditions: Sequence[Indicator]
25
+ """any conditions on `rvs` that were compiled into the circuit."""
26
+
41
27
  circuit_top: CircuitNode
28
+ """the top circuit node defining the network function."""
29
+
42
30
  number_of_indicators: int
31
+ """
32
+ the number of indicators in `rvs` which is
33
+ `sum(len(rv) for rv in rvs`. Specifically, `circuit.vars[i]` is the circuit variable
34
+ corresponding to the ith indicator, where `circuit` is `circuit_top.circuit` and
35
+ indicators are ordered as per `rvs`.
36
+ """
37
+
43
38
  number_of_parameters: int
39
+ """
40
+ the number of parameters from the PGM that are
41
+ represented as circuit variables. This may be zero if parameters from the PGM
42
+ were compiled as constants.
43
+ """
44
+
44
45
  slot_map: SlotMap
46
+ """
47
+ gives the index of the circuit variable corresponding to x,
48
+ where x is either a random variable indicator (Indicator) or a parameter id (ParamId).
49
+ """
50
+
45
51
  parameter_values: NDArray
52
+ """
53
+ parameter values, co-indexed with the circuit variables, counting beyond `number_of_indicators`.
54
+ """
46
55
 
47
56
  def dump(self, *, prefix: str = '', indent: str = ' ') -> None:
48
57
  """
@@ -114,7 +114,10 @@ class ProgramWithSlotmap:
114
114
 
115
115
  def compute_conditioned(self, *condition: Condition) -> NDArrayNumeric:
116
116
  """
117
- Equivalent to:
117
+ Compute the program value, after setting the given condition.
118
+
119
+ Equivalent to::
120
+
118
121
  self.set_condition(*condition)
119
122
  return self.compute()
120
123
  """
@@ -11,17 +11,16 @@ from ck.utils.map_set import MapSet
11
11
  from ck.utils.np_extras import dtype_for_number_of_states, NDArrayFloat64, DTypeStates, NDArrayNumeric
12
12
 
13
13
  Condition: TypeAlias = None | Indicator | Iterable[Indicator]
14
- Condition.__doc__ = \
15
- """
16
- Type defining a condition. A condition is logically a set of
17
- indicators, each indicator representing a random variable being in some state.
18
-
19
- If multiple indicators of the same random variable appear in
20
- a condition, then they are interpreted as
21
- a disjunction, otherwise indicators are interpreted as
22
- a conjunction. E.g., the condition (X=0, Y=1, Y=3) means
23
- X=0 and (Y=1 or Y=3).
24
- """
14
+ """
15
+ Type defining a condition. A condition is logically a set of
16
+ indicators, each indicator representing a random variable being in some state.
17
+
18
+ If multiple indicators of the same random variable appear in
19
+ a condition, then they are interpreted as
20
+ a disjunction, otherwise indicators are interpreted as
21
+ a conjunction. E.g., the condition (X=0, Y=1, Y=3) means
22
+ X=0 and (Y=1 or Y=3).
23
+ """
25
24
 
26
25
  _NAN: float = np.nan # Not-a-number (i.e., the result of an invalid calculation).
27
26