ripple-down-rules 0.5.92__tar.gz → 0.5.94__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.
Files changed (152) hide show
  1. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/.gitignore +2 -0
  2. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/PKG-INFO +1 -1
  3. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/__init__.py +1 -1
  4. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/helpers.py +1 -1
  5. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/rdr.py +8 -5
  6. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/rdr_decorators.py +1 -1
  7. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/user_interface/ipython_custom_shell.py +1 -1
  8. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/user_interface/template_file_creator.py +0 -1
  9. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/utils.py +35 -46
  10. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules.egg-info/PKG-INFO +1 -1
  11. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_results/datasets_physical_object_is_a_robot/rdr_metadata/datasets_physical_object_is_a_robot.json +4 -4
  12. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_results/datasets_physical_object_select_objects_that_are_parts_of_robot/rdr_metadata/datasets_physical_object_select_objects_that_are_parts_of_robot.json +6 -6
  13. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/.github/workflows/build_and_deploy_doc.yml +0 -0
  14. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/.github/workflows/ci.yml +0 -0
  15. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/.github/workflows/publish-to-test-pypi.yml +0 -0
  16. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/.idea/shelf/Uncommitted_changes_before_Checkout_at_2_4_25,_6_32_PM_[Changes]/shelved.patch +0 -0
  17. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/.idea/shelf/Uncommitted_changes_before_Checkout_at_2_4_25,_6_32_PM_[Changes]1/shelved.patch +0 -0
  18. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/LICENSE +0 -0
  19. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/README.md +0 -0
  20. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/doc/_config.yml +0 -0
  21. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/doc/_toc.yml +0 -0
  22. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/doc/bibliography.md +0 -0
  23. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/doc/intro.md +0 -0
  24. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/doc/references.bib +0 -0
  25. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/doc/requirements.txt +0 -0
  26. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/examples/__init__.py +0 -0
  27. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/examples/animal_species.py +0 -0
  28. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/examples/part_containment_rdr/__init__.py +0 -0
  29. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/examples/part_containment_rdr/rdr_metadata/part_containment_rdr.json +0 -0
  30. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/examples/part_containment_rdr/robot_contained_objects_mcrdr.py +0 -0
  31. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/examples/part_containment_rdr/robot_contained_objects_mcrdr_defs.py +0 -0
  32. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/examples/part_containment_rdr/robot_rdr.py +0 -0
  33. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/examples/relational_example.py +0 -0
  34. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/images/scrdr.dot +0 -0
  35. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/images/scrdr.png +0 -0
  36. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/images/thinking_pr2.jpg +0 -0
  37. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/pyproject.toml +0 -0
  38. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/pytest.ini +0 -0
  39. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/requirements-dev-ci.txt +0 -0
  40. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/requirements-dev.txt +0 -0
  41. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/requirements-gui.txt +0 -0
  42. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/requirements-viz.txt +0 -0
  43. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/requirements.txt +0 -0
  44. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_mcrdr_extra.dot +0 -0
  45. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_mcrdr_extra.png +0 -0
  46. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_mcrdr_stop_only.dot +0 -0
  47. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_mcrdr_stop_only.png +0 -0
  48. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_mcrdr_stop_plus_rule.dot +0 -0
  49. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_mcrdr_stop_plus_rule.png +0 -0
  50. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_scrdr.dot +0 -0
  51. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_scrdr.png +0 -0
  52. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_scrdr_2.dot +0 -0
  53. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_scrdr_2.png +0 -0
  54. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_scrdr_3.dot +0 -0
  55. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/complete_scrdr_3.png +0 -0
  56. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/grdr_Habitat.dot +0 -0
  57. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/grdr_Habitat.png +0 -0
  58. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/grdr_Species.dot +0 -0
  59. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/grdr_Species.png +0 -0
  60. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/mcrdr_extra.dot +0 -0
  61. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/mcrdr_extra.png +0 -0
  62. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/mcrdr_extra_classify.dot +0 -0
  63. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/mcrdr_extra_classify.png +0 -0
  64. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/mcrdr_stop_plus_rule_combined.dot +0 -0
  65. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/mcrdr_stop_plus_rule_combined.png +0 -0
  66. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/partial_mcrdr_extra.dot +0 -0
  67. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/partial_mcrdr_extra.png +0 -0
  68. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/relational_scrdr_classify.dot +0 -0
  69. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/results/relational_scrdr_classify.png +0 -0
  70. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/setup.cfg +0 -0
  71. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/datastructures/__init__.py +0 -0
  72. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/datastructures/callable_expression.py +0 -0
  73. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/datastructures/case.py +0 -0
  74. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/datastructures/dataclasses.py +0 -0
  75. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/datastructures/enums.py +0 -0
  76. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/experts.py +0 -0
  77. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/rules.py +0 -0
  78. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/start-code-server.sh +0 -0
  79. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/user_interface/__init__.py +0 -0
  80. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/user_interface/gui.py +0 -0
  81. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/user_interface/object_diagram.py +0 -0
  82. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules/user_interface/prompt.py +0 -0
  83. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules.egg-info/SOURCES.txt +0 -0
  84. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules.egg-info/dependency_links.txt +0 -0
  85. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules.egg-info/requires.txt +0 -0
  86. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/src/ripple_down_rules.egg-info/top_level.txt +0 -0
  87. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/__init__.py +0 -0
  88. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/conf/__init__.py +0 -0
  89. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/conf/world/__init__.py +0 -0
  90. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/conf/world/base_config.py +0 -0
  91. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/conf/world/handles_and_containers.py +0 -0
  92. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/conftest.py +0 -0
  93. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/datasets.py +0 -0
  94. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/factories/__init__.py +0 -0
  95. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/factories/world/__init__.py +0 -0
  96. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/factories/world/handles_and_containers.py +0 -0
  97. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/correct_drawer_rdr_expert_answers_fit.json +0 -0
  98. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/drawer_cabinet_expert_answers_fit.json +0 -0
  99. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/grdr_expert_answers_classify.json +0 -0
  100. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/grdr_expert_answers_fit.json +0 -0
  101. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/grdr_expert_answers_fit_extra.json +0 -0
  102. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/grdr_expert_answers_fit_no_targets.json +0 -0
  103. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mcrdr_expert_answers_classify.json +0 -0
  104. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mcrdr_expert_answers_fit_no_targets.json +0 -0
  105. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mcrdr_expert_answers_stop_only_fit.json +0 -0
  106. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mcrdr_extra_expert_answers_classify.json +0 -0
  107. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mcrdr_extra_expert_answers_fit.json +0 -0
  108. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mcrdr_multi_line_expert_answers_fit.json +0 -0
  109. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mcrdr_stop_only_answers_fit.json +0 -0
  110. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mcrdr_stop_plus_rule_answers_fit.json +0 -0
  111. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mcrdr_stop_plus_rule_combined_expert_answers_fit.json +0 -0
  112. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mcrdr_stop_plus_rule_expert_answers_fit.json +0 -0
  113. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/mutagenic_expert_answers.json +0 -0
  114. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/relational_scrdr_expert_answers_classify.json +0 -0
  115. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/scrdr_expert_answers_classify.json +0 -0
  116. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/scrdr_expert_answers_fit.json +0 -0
  117. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/scrdr_expert_answers_fit_no_targets.json +0 -0
  118. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/scrdr_multi_line_expert_answers_fit.json +0 -0
  119. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_expert_answers/scrdr_world_expert_answers_fit.json +0 -0
  120. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_generated_rdrs/__init__.py +0 -0
  121. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_helpers/__init__.py +0 -0
  122. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_helpers/helpers.py +0 -0
  123. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_helpers/object_diagram_case_query.png +0 -0
  124. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_helpers/object_diagram_person.png +0 -0
  125. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_json_serialization.py +0 -0
  126. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_object_diagram.py +0 -0
  127. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_on_mutagenic.py +0 -0
  128. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_rdr.py +0 -0
  129. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_rdr_alchemy.py +0 -0
  130. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_rdr_decorators.py +0 -0
  131. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_rdr_helpers_rdrs.py +0 -0
  132. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_rdr_world/__init__.py +0 -0
  133. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_rdr_world/conftest.py +0 -0
  134. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_rdr_world/test_rdr_world.py +0 -0
  135. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_relational_rdr.py +0 -0
  136. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_relational_rdr_alchemy.py +0 -0
  137. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_results/datasets_physical_object_is_a_robot/__init__.py +0 -0
  138. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_results/datasets_physical_object_is_a_robot/physical_object_is_a_robot_output__scrdr.py +0 -0
  139. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_results/datasets_physical_object_is_a_robot/physical_object_is_a_robot_output__scrdr_defs.py +1 -1
  140. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_results/datasets_physical_object_is_a_robot/physical_object_is_a_robot_rdr.py +2 -2
  141. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_results/datasets_physical_object_select_objects_that_are_parts_of_robot/__init__.py +0 -0
  142. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_results/datasets_physical_object_select_objects_that_are_parts_of_robot/physical_object_select_objects_that_are_parts_of_robot_output__mcrdr.py +1 -1
  143. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_results/datasets_physical_object_select_objects_that_are_parts_of_robot/physical_object_select_objects_that_are_parts_of_robot_output__mcrdr_defs.py +1 -1
  144. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_results/datasets_physical_object_select_objects_that_are_parts_of_robot/physical_object_select_objects_that_are_parts_of_robot_rdr.py +2 -2
  145. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_sql_model.py +0 -0
  146. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_template_file_creator.py +0 -0
  147. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_user_interface/__init__.py +0 -0
  148. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_user_interface/test_ipython.py +0 -0
  149. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_user_interface/test_ipython_copilot.py +0 -0
  150. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_user_interface/test_prompt.py +0 -0
  151. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_user_interface/test_qt_gui_inline.py +0 -0
  152. {ripple_down_rules-0.5.92 → ripple_down_rules-0.5.94}/test/test_utils.py +0 -0
@@ -1,2 +1,4 @@
1
1
  *.pyc
2
2
  *.egg-info
3
+ *.pkl
4
+ build/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ripple_down_rules
3
- Version: 0.5.92
3
+ Version: 0.5.94
4
4
  Summary: Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning.
5
5
  Author-email: Abdelrhman Bassiouny <abassiou@uni-bremen.de>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,4 +1,4 @@
1
- __version__ = "0.5.92"
1
+ __version__ = "0.5.94"
2
2
 
3
3
  import logging
4
4
  logger = logging.Logger("rdr")
@@ -36,7 +36,7 @@ def general_rdr_classify(classifiers_dict: Dict[str, Union[ModuleType, RippleDow
36
36
  new_conclusions = {}
37
37
  for attribute_name, rdr in classifiers_dict.items():
38
38
  pred_atts = rdr.classify(case_cp, case_query=case_query)
39
- if pred_atts is None:
39
+ if pred_atts is None and type(None) not in rdr.conclusion_type:
40
40
  continue
41
41
  if rdr.mutually_exclusive:
42
42
  if attribute_name not in conclusions or \
@@ -139,13 +139,15 @@ class RippleDownRules(SubclassJSONSerializer, ABC):
139
139
  model_dir = os.path.join(load_dir, model_name)
140
140
  json_file = os.path.join(model_dir, cls.metadata_folder, model_name)
141
141
  rdr = cls.from_json_file(json_file)
142
+ rdr.save_dir = load_dir
143
+ rdr.model_name = model_name
142
144
  try:
143
145
  rdr.update_from_python(model_dir, package_name=package_name)
146
+ rdr.to_json_file(json_file)
144
147
  except (FileNotFoundError, ValueError) as e:
145
148
  logger.warning(f"Could not load the python file for the model {model_name} from {model_dir}. "
146
149
  f"Make sure the file exists and is valid.")
147
- rdr.save_dir = load_dir
148
- rdr.model_name = model_name
150
+ rdr.save(save_dir=load_dir, model_name=model_name, package_name=package_name)
149
151
  return rdr
150
152
 
151
153
  @abstractmethod
@@ -296,7 +298,7 @@ class RippleDownRules(SubclassJSONSerializer, ABC):
296
298
  :param update_existing: Whether to update rules that gave the required type of conclusions.
297
299
  :return: True if the rdr should ask the expert, False otherwise.
298
300
  """
299
- if conclusions is None:
301
+ if conclusions is None and type(None) not in case_query.core_attribute_type:
300
302
  return True
301
303
  elif is_iterable(conclusions) and len(conclusions) == 0:
302
304
  return True
@@ -571,8 +573,9 @@ class RDRWithCodeWriter(RippleDownRules, ABC):
571
573
  :return: The type of the conclusion of the RDR classifier.
572
574
  """
573
575
  all_types = []
574
- for rule in [self.start_rule] + list(self.start_rule.descendants):
575
- all_types.extend(list(rule.conclusion.conclusion_type))
576
+ if self.start_rule is not None:
577
+ for rule in [self.start_rule] + list(self.start_rule.descendants):
578
+ all_types.extend(list(rule.conclusion.conclusion_type))
576
579
  return tuple(set(all_types))
577
580
 
578
581
  @property
@@ -120,7 +120,7 @@ class RDRDecorator:
120
120
  func_args_type_hints = get_type_hints(func)
121
121
  output_name = list(func_output.keys())[0]
122
122
  func_args_type_hints.update({output_name: Union[tuple(output_type)]})
123
- return CaseQuery(case, output_name, Union[tuple(output_type)],
123
+ return CaseQuery(case, output_name, tuple(output_type),
124
124
  mutual_exclusive, scope=scope,
125
125
  is_function=True, function_args_type_hints=func_args_type_hints)
126
126
 
@@ -128,7 +128,7 @@ class IPythonShell:
128
128
  break
129
129
  except Exception as e:
130
130
  logging.error(e)
131
- print(f"{Fore.RED}ERROR::{e}{Style.RESET_ALL}")
131
+ print(f"{Fore.RED}ERROR:: {e}{Style.RESET_ALL}")
132
132
 
133
133
  def update_user_input_from_code_lines(self):
134
134
  """
@@ -225,7 +225,6 @@ class TemplateFileCreator:
225
225
  import_types.extend(case_type_imports)
226
226
  import_types.extend(output_type_imports)
227
227
  imports = get_imports_from_types(import_types, excluded_modules=["IPython.core.interactiveshell"])
228
- imports = set(imports)
229
228
  return '\n'.join(imports)
230
229
 
231
230
  @staticmethod
@@ -85,30 +85,6 @@ def are_results_subclass_of_types(result_types: List[Any], types_: List[Type]) -
85
85
  return True
86
86
 
87
87
 
88
- def _get_imports_from_types(types: List[Type]) -> List[str]:
89
- """
90
- Get the import statements for a list of types.
91
-
92
- :param types: The types to get the import statements for.
93
- :return: The import statements as a string.
94
- """
95
- imports = map(get_import_from_type, types)
96
- return list({i for i in imports if i is not None})
97
-
98
-
99
- def get_import_from_type(type_: Type) -> Optional[str]:
100
- """
101
- Get the import statement for a given type.
102
-
103
- :param type_: The type to get the import statement for.
104
- :return: The import statement as a string.
105
- """
106
- if hasattr(type_, "__module__") and hasattr(type_, "__name__"):
107
- if type_.__module__ == "builtins":
108
- return
109
- return f"from {type_.__module__} import {type_.__name__}"
110
-
111
-
112
88
  def get_imports_from_scope(scope: Dict[str, Any]) -> List[str]:
113
89
  """
114
90
  Get the imports from the given scope.
@@ -116,12 +92,7 @@ def get_imports_from_scope(scope: Dict[str, Any]) -> List[str]:
116
92
  :param scope: The scope to get the imports from.
117
93
  :return: The imports as a string.
118
94
  """
119
- imports = []
120
- for k, v in scope.items():
121
- if not hasattr(v, "__module__") or not hasattr(v, "__name__") or v.__module__ is None:
122
- continue
123
- imports.append(f"from {v.__module__} import {v.__name__}")
124
- return imports
95
+ return get_imports_from_types(list(scope.values()))
125
96
 
126
97
 
127
98
  def extract_imports(file_path: Optional[str] = None, tree: Optional[ast.AST] = None,
@@ -861,16 +832,18 @@ def get_relative_import(target_file_path, imported_module_path: Optional[str] =
861
832
  :return: A relative import path as a string.
862
833
  """
863
834
  # Convert to absolute paths
864
- target_path = Path(target_file_path).resolve()
865
- if package_name is not None:
866
- target_path = Path(get_path_starting_from_latest_encounter_of(str(target_path), package_name))
867
835
  if module is not None:
868
836
  imported_module_path = sys.modules[module].__file__
869
837
  if imported_module_path is None:
870
838
  raise ValueError("Either imported_module_path or module must be provided")
839
+ target_path = Path(target_file_path).resolve()
840
+ imported_file_name = Path(imported_module_path).name
841
+ target_file_name = Path(target_file_path).name
842
+ if package_name is not None:
843
+ target_path = Path(get_path_starting_from_latest_encounter_of(str(target_path), package_name, [target_file_name]))
871
844
  imported_path = Path(imported_module_path).resolve()
872
845
  if package_name is not None:
873
- imported_path = Path(get_path_starting_from_latest_encounter_of(str(imported_path), package_name))
846
+ imported_path = Path(get_path_starting_from_latest_encounter_of(str(imported_path), package_name, [imported_file_name]))
874
847
 
875
848
  # Compute relative path from target to imported module
876
849
  rel_path = os.path.relpath(imported_path.parent, target_path.parent)
@@ -878,29 +851,45 @@ def get_relative_import(target_file_path, imported_module_path: Optional[str] =
878
851
  # Convert path to Python import format
879
852
  rel_parts = [part.replace('..', '.') for part in Path(rel_path).parts]
880
853
  rel_parts = rel_parts if rel_parts else ['']
881
- dot_parts = [part for part in rel_parts if part == '.']
882
- non_dot_parts = [part for part in rel_parts if part != '.']
854
+ # dot_parts = [part for part in rel_parts if part == '.']
855
+ # non_dot_parts = [part for part in rel_parts if part != '.']
883
856
 
884
857
 
885
858
  # Join the parts and add the module name
886
- joined_parts = "".join(dot_parts) + ".".join(non_dot_parts) + f".{imported_path.stem}"
887
- joined_parts = f".{joined_parts}" if not joined_parts.startswith(".") else joined_parts
859
+ # joined_parts = "".join(dot_parts) + ".".join(non_dot_parts) + f".{imported_path.stem}"
860
+ joined_parts = "." + "".join(rel_parts)
861
+ joined_parts += imported_path.stem if joined_parts.endswith(".") else f".{imported_path.stem}"
862
+ # joined_parts = f".{joined_parts}" if not joined_parts.startswith(".") else joined_parts
888
863
 
889
864
  return joined_parts
890
865
 
891
866
 
892
- def get_path_starting_from_latest_encounter_of(path: str, package_name: str) -> Optional[str]:
867
+ def get_path_starting_from_latest_encounter_of(path: str, package_name: str, should_contain: List[str]) -> str:
893
868
  """
894
869
  Get the path starting from the package name.
895
870
 
896
871
  :param path: The full path to the file.
897
872
  :param package_name: The name of the package to start from.
898
- :return: The path starting from the package name or None if not found.
899
- """
900
- if package_name in path:
901
- idx = path.rfind(package_name)
902
- return path[idx:]
903
- return None
873
+ :param should_contain: The names of the files or directorys to look for.
874
+ :return: The path starting from the package name that contains all the names in should_contain, otherwise raise an error.
875
+ :raise ValueError: If the path does not contain all the names in should_contain.
876
+ """
877
+ path_parts = path.split(os.path.sep)
878
+ if package_name not in path_parts:
879
+ raise ValueError(f"Could not find {package_name} in {path}")
880
+ idx = path_parts.index(package_name)
881
+ prev_idx = idx
882
+ while all(sc in path_parts[idx:] for sc in should_contain):
883
+ prev_idx = idx
884
+ try:
885
+ idx = path_parts.index(package_name, idx + 1)
886
+ except ValueError:
887
+ break
888
+ if all(sc in path_parts[idx:] for sc in should_contain):
889
+ path_parts = path_parts[prev_idx:]
890
+ return os.path.join(*path_parts)
891
+ else:
892
+ raise ValueError(f"Could not find {should_contain} in {path}")
904
893
 
905
894
 
906
895
  def get_imports_from_types(type_objs: Iterable[Type],
@@ -959,7 +948,7 @@ def get_imports_from_types(type_objs: Iterable[Type],
959
948
  import_path = get_relative_import(target_file_path, module=module, package_name=package_name)
960
949
  lines.append(f"from {import_path} import {joined}")
961
950
  lines.extend(stem_imports)
962
- return sorted(lines)
951
+ return lines
963
952
 
964
953
 
965
954
  def get_method_args_as_dict(method: Callable, *args, **kwargs) -> Dict[str, Any]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ripple_down_rules
3
- Version: 0.5.92
3
+ Version: 0.5.94
4
4
  Summary: Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning.
5
5
  Author-email: Abdelrhman Bassiouny <abassiou@uni-bremen.de>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -12,9 +12,9 @@
12
12
  "builtins.bool"
13
13
  ],
14
14
  "scope": {
15
+ "Dict": "typing.Dict",
15
16
  "PhysicalObject": "test.datasets.PhysicalObject",
16
- "Robot": "test.datasets.Robot",
17
- "Dict": "typing.Dict"
17
+ "Robot": "test.datasets.Robot"
18
18
  },
19
19
  "conclusion": {
20
20
  "_type": "builtins.NoneType",
@@ -29,9 +29,9 @@
29
29
  "builtins.bool"
30
30
  ],
31
31
  "scope": {
32
+ "Dict": "typing.Dict",
32
33
  "PhysicalObject": "test.datasets.PhysicalObject",
33
- "Robot": "test.datasets.Robot",
34
- "Dict": "typing.Dict"
34
+ "Robot": "test.datasets.Robot"
35
35
  },
36
36
  "conclusion": {
37
37
  "_type": "builtins.NoneType",
@@ -12,11 +12,11 @@
12
12
  "builtins.bool"
13
13
  ],
14
14
  "scope": {
15
- "PhysicalObject": "test.datasets.PhysicalObject",
16
- "Robot": "test.datasets.Robot",
17
15
  "Dict": "typing.Dict",
18
16
  "List": "typing.List",
19
- "Union": "typing.Union"
17
+ "Union": "typing.Union",
18
+ "PhysicalObject": "test.datasets.PhysicalObject",
19
+ "Robot": "test.datasets.Robot"
20
20
  },
21
21
  "conclusion": {
22
22
  "_type": "builtins.NoneType",
@@ -33,11 +33,11 @@
33
33
  "builtins.list"
34
34
  ],
35
35
  "scope": {
36
- "PhysicalObject": "test.datasets.PhysicalObject",
37
- "Robot": "test.datasets.Robot",
38
36
  "Dict": "typing.Dict",
39
37
  "List": "typing.List",
40
- "Union": "typing.Union"
38
+ "Union": "typing.Union",
39
+ "PhysicalObject": "test.datasets.PhysicalObject",
40
+ "Robot": "test.datasets.Robot"
41
41
  },
42
42
  "conclusion": {
43
43
  "_type": "builtins.NoneType",
@@ -1,5 +1,5 @@
1
- from ...datasets import PhysicalObject, Robot
2
1
  from typing import Dict
2
+ from ...datasets import PhysicalObject, Robot
3
3
 
4
4
 
5
5
  def conditions_226969243620390858682731042391766665817(case):
@@ -1,6 +1,6 @@
1
- from ripple_down_rules.datastructures.case import Case, create_case
2
- from ripple_down_rules.helpers import general_rdr_classify
3
1
  from typing import Any, Dict
2
+ from ripple_down_rules.helpers import general_rdr_classify
3
+ from ripple_down_rules.datastructures.case import Case, create_case
4
4
  from . import physical_object_is_a_robot_output__scrdr as output__classifier
5
5
 
6
6
  classifiers_dict = dict()
@@ -1,6 +1,6 @@
1
- from ripple_down_rules.datastructures.case import Case, create_case
2
1
  from ripple_down_rules.utils import make_set
3
2
  from typing import Set, Union
3
+ from ripple_down_rules.datastructures.case import Case, create_case
4
4
  from .physical_object_select_objects_that_are_parts_of_robot_output__mcrdr_defs import *
5
5
 
6
6
 
@@ -1,5 +1,5 @@
1
- from ...datasets import PhysicalObject, Robot
2
1
  from typing import Dict, List, Union
2
+ from ...datasets import PhysicalObject, Robot
3
3
 
4
4
 
5
5
  def conditions_164855806603893754507167918997373216146(case):
@@ -1,6 +1,6 @@
1
- from ripple_down_rules.datastructures.case import Case, create_case
2
- from ripple_down_rules.helpers import general_rdr_classify
3
1
  from typing import Any, Dict
2
+ from ripple_down_rules.helpers import general_rdr_classify
3
+ from ripple_down_rules.datastructures.case import Case, create_case
4
4
  from . import physical_object_select_objects_that_are_parts_of_robot_output__mcrdr as output__classifier
5
5
 
6
6
  classifiers_dict = dict()