ripple-down-rules 0.4.4__tar.gz → 0.4.7__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 (42) hide show
  1. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/PKG-INFO +17 -3
  2. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/pyproject.toml +19 -6
  3. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/user_interface/prompt.py +2 -2
  4. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/user_interface/template_file_creator.py +12 -8
  5. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/utils.py +2 -1
  6. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules.egg-info/PKG-INFO +17 -3
  7. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules.egg-info/SOURCES.txt +2 -0
  8. ripple_down_rules-0.4.7/src/ripple_down_rules.egg-info/requires.txt +16 -0
  9. ripple_down_rules-0.4.7/test/test_template_file_creator.py +42 -0
  10. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/LICENSE +0 -0
  11. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/README.md +0 -0
  12. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/setup.cfg +0 -0
  13. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/__init__.py +0 -0
  14. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/datasets.py +0 -0
  15. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/datastructures/__init__.py +0 -0
  16. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/datastructures/callable_expression.py +0 -0
  17. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/datastructures/case.py +0 -0
  18. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/datastructures/dataclasses.py +0 -0
  19. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/datastructures/enums.py +0 -0
  20. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/experts.py +0 -0
  21. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/failures.py +0 -0
  22. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/helpers.py +0 -0
  23. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/rdr.py +0 -0
  24. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/rdr_decorators.py +0 -0
  25. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/rules.py +0 -0
  26. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/user_interface/__init__.py +0 -0
  27. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/user_interface/gui.py +0 -0
  28. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/user_interface/ipython_custom_shell.py +0 -0
  29. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules/user_interface/object_diagram.py +0 -0
  30. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules.egg-info/dependency_links.txt +0 -0
  31. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/src/ripple_down_rules.egg-info/top_level.txt +0 -0
  32. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_json_serialization.py +0 -0
  33. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_object_diagram.py +0 -0
  34. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_on_mutagenic.py +0 -0
  35. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_rdr.py +0 -0
  36. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_rdr_alchemy.py +0 -0
  37. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_rdr_decorators.py +0 -0
  38. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_rdr_world.py +0 -0
  39. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_relational_rdr.py +0 -0
  40. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_relational_rdr_alchemy.py +0 -0
  41. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_sql_model.py +0 -0
  42. {ripple_down_rules-0.4.4 → ripple_down_rules-0.4.7}/test/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ripple_down_rules
3
- Version: 0.4.4
3
+ Version: 0.4.7
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
@@ -677,12 +677,26 @@ License: GNU GENERAL PUBLIC LICENSE
677
677
  the library. If this is what you want to do, use the GNU Lesser General
678
678
  Public License instead of this License. But first, please read
679
679
  <https://www.gnu.org/licenses/why-not-lgpl.html>.
680
- Project-URL: Homepage, https://github.com/AbdelrhmanBassiouny/ripple_down_rules
681
680
  Keywords: robotics,knowledge,reasoning,representation
682
681
  Classifier: Programming Language :: Python :: 3
683
- Requires-Python: >=3.10
684
682
  Description-Content-Type: text/markdown
685
683
  License-File: LICENSE
684
+ Requires-Dist: anytree>=2.8.0
685
+ Requires-Dist: pandas>=2.0.3
686
+ Requires-Dist: networkx>=3.1
687
+ Requires-Dist: ordered_set>=4
688
+ Requires-Dist: pygraphviz>=1.7
689
+ Requires-Dist: ucimlrepo>=0.0.7
690
+ Requires-Dist: typing-extensions>=4.12.2
691
+ Requires-Dist: matplotlib>=3.7.5
692
+ Requires-Dist: sqlalchemy
693
+ Requires-Dist: pyqt6
694
+ Requires-Dist: qtconsole
695
+ Requires-Dist: graphviz
696
+ Requires-Dist: tabulate
697
+ Requires-Dist: ipython
698
+ Requires-Dist: requests
699
+ Requires-Dist: colorama
686
700
  Dynamic: license-file
687
701
 
688
702
  # Ripple Down Rules (RDR)
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "ripple_down_rules"
9
- version = "0.4.4"
9
+ version = "0.4.7"
10
10
  description = "Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning."
11
11
  readme = "README.md"
12
12
  authors = [{ name = "Abdelrhman Bassiouny", email = "abassiou@uni-bremen.de" }]
@@ -15,8 +15,21 @@ classifiers = [
15
15
  "Programming Language :: Python :: 3",
16
16
  ]
17
17
  keywords = ["robotics", "knowledge", "reasoning", "representation"]
18
- dependencies = []
19
- requires-python = ">=3.10"
20
-
21
- [project.urls]
22
- Homepage = "https://github.com/AbdelrhmanBassiouny/ripple_down_rules"
18
+ dependencies = [
19
+ "anytree>=2.8.0",
20
+ "pandas>=2.0.3",
21
+ "networkx>=3.1",
22
+ "ordered_set>=4",
23
+ "pygraphviz>=1.7",
24
+ "ucimlrepo>=0.0.7",
25
+ "typing-extensions>=4.12.2",
26
+ "matplotlib>=3.7.5",
27
+ "sqlalchemy",
28
+ "pyqt6",
29
+ "qtconsole",
30
+ "graphviz",
31
+ "tabulate",
32
+ "ipython",
33
+ "requests",
34
+ "colorama",
35
+ ]
@@ -134,14 +134,14 @@ class UserPrompt:
134
134
  """
135
135
  while True:
136
136
  if user_input is None:
137
- if QApplication.instance() is None:
137
+ if self.viewer is None:
138
138
  shell = IPythonShell() if shell is None else shell
139
139
  shell.run()
140
140
  user_input = shell.user_input
141
141
  else:
142
142
  app = QApplication.instance()
143
143
  if app is None:
144
- app = QApplication([])
144
+ raise RuntimeError("QApplication instance is None. Please run the application first.")
145
145
  self.viewer.show()
146
146
  app.exec()
147
147
  user_input = self.viewer.user_input
@@ -79,7 +79,7 @@ class TemplateFileCreator:
79
79
  self.case_query = case_query
80
80
  self.output_type = self.get_output_type()
81
81
  self.user_edit_line = 0
82
- self.func_name: str = self.get_func_name()
82
+ self.func_name: str = self.get_func_name(self.prompt_for, self.case_query)
83
83
  self.func_doc: str = self.get_func_doc()
84
84
  self.function_signature: str = self.get_function_signature()
85
85
  self.editor: Optional[Editor] = detect_available_editor()
@@ -146,7 +146,7 @@ class TemplateFileCreator:
146
146
 
147
147
  def get_function_signature(self) -> str:
148
148
  if self.func_name is None:
149
- self.func_name = self.get_func_name()
149
+ self.func_name = self.get_func_name(self.prompt_for, self.case_query)
150
150
  output_type_hint = self.get_output_type_hint()
151
151
  func_args = self.get_func_args()
152
152
  return f"def {self.func_name}({func_args}){output_type_hint}:"
@@ -238,15 +238,19 @@ class TemplateFileCreator:
238
238
  else:
239
239
  return f"Get possible value(s) for {self.case_query.name}"
240
240
 
241
- def get_func_name(self) -> Optional[str]:
241
+ @staticmethod
242
+ def get_func_name(prompt_for, case_query) -> Optional[str]:
242
243
  func_name = ""
243
- if self.prompt_for == PromptFor.Conditions:
244
- func_name = f"{self.prompt_for.value.lower()}_for_"
245
- case_name = self.case_query.name.replace(".", "_")
246
- if self.case_query.is_function:
244
+ if prompt_for == PromptFor.Conditions:
245
+ func_name = f"{prompt_for.value.lower()}_for_"
246
+ case_name = case_query.name.replace(".", "_")
247
+ if case_query.is_function:
247
248
  # convert any CamelCase word into snake_case by adding _ before each capital letter
248
- case_name = case_name.replace(f"_{self.case_query.attribute_name}", "")
249
+ case_name = case_name.replace(f"_{case_query.attribute_name}", "")
249
250
  func_name += case_name
251
+ attr_types = [t for t in case_query.core_attribute_type if t.__module__ != "builtins" and t is not None
252
+ and t is not type(None)]
253
+ func_name += f"_of_type_{'_or_'.join(map(lambda c: c.__name__, attr_types))}"
250
254
  return str_to_snake_case(func_name)
251
255
 
252
256
  @cached_property
@@ -14,6 +14,7 @@ from collections import UserDict
14
14
  from copy import deepcopy, copy
15
15
  from dataclasses import is_dataclass, fields
16
16
  from enum import Enum
17
+ from textwrap import dedent
17
18
  from types import NoneType
18
19
 
19
20
  import matplotlib
@@ -168,7 +169,7 @@ def extract_function_source(file_path: str,
168
169
  if not include_signature:
169
170
  func_lines = func_lines[1:]
170
171
  line_numbers.append((node.lineno, node.end_lineno))
171
- functions_source[node.name] = "\n".join(func_lines) if join_lines else func_lines
172
+ functions_source[node.name] = dedent("\n".join(func_lines)) if join_lines else func_lines
172
173
  if len(functions_source) == len(function_names):
173
174
  break
174
175
  if len(functions_source) != len(function_names):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ripple_down_rules
3
- Version: 0.4.4
3
+ Version: 0.4.7
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
@@ -677,12 +677,26 @@ License: GNU GENERAL PUBLIC LICENSE
677
677
  the library. If this is what you want to do, use the GNU Lesser General
678
678
  Public License instead of this License. But first, please read
679
679
  <https://www.gnu.org/licenses/why-not-lgpl.html>.
680
- Project-URL: Homepage, https://github.com/AbdelrhmanBassiouny/ripple_down_rules
681
680
  Keywords: robotics,knowledge,reasoning,representation
682
681
  Classifier: Programming Language :: Python :: 3
683
- Requires-Python: >=3.10
684
682
  Description-Content-Type: text/markdown
685
683
  License-File: LICENSE
684
+ Requires-Dist: anytree>=2.8.0
685
+ Requires-Dist: pandas>=2.0.3
686
+ Requires-Dist: networkx>=3.1
687
+ Requires-Dist: ordered_set>=4
688
+ Requires-Dist: pygraphviz>=1.7
689
+ Requires-Dist: ucimlrepo>=0.0.7
690
+ Requires-Dist: typing-extensions>=4.12.2
691
+ Requires-Dist: matplotlib>=3.7.5
692
+ Requires-Dist: sqlalchemy
693
+ Requires-Dist: pyqt6
694
+ Requires-Dist: qtconsole
695
+ Requires-Dist: graphviz
696
+ Requires-Dist: tabulate
697
+ Requires-Dist: ipython
698
+ Requires-Dist: requests
699
+ Requires-Dist: colorama
686
700
  Dynamic: license-file
687
701
 
688
702
  # Ripple Down Rules (RDR)
@@ -13,6 +13,7 @@ src/ripple_down_rules/utils.py
13
13
  src/ripple_down_rules.egg-info/PKG-INFO
14
14
  src/ripple_down_rules.egg-info/SOURCES.txt
15
15
  src/ripple_down_rules.egg-info/dependency_links.txt
16
+ src/ripple_down_rules.egg-info/requires.txt
16
17
  src/ripple_down_rules.egg-info/top_level.txt
17
18
  src/ripple_down_rules/datastructures/__init__.py
18
19
  src/ripple_down_rules/datastructures/callable_expression.py
@@ -35,4 +36,5 @@ test/test_rdr_world.py
35
36
  test/test_relational_rdr.py
36
37
  test/test_relational_rdr_alchemy.py
37
38
  test/test_sql_model.py
39
+ test/test_template_file_creator.py
38
40
  test/test_utils.py
@@ -0,0 +1,16 @@
1
+ anytree>=2.8.0
2
+ pandas>=2.0.3
3
+ networkx>=3.1
4
+ ordered_set>=4
5
+ pygraphviz>=1.7
6
+ ucimlrepo>=0.0.7
7
+ typing-extensions>=4.12.2
8
+ matplotlib>=3.7.5
9
+ sqlalchemy
10
+ pyqt6
11
+ qtconsole
12
+ graphviz
13
+ tabulate
14
+ ipython
15
+ requests
16
+ colorama
@@ -0,0 +1,42 @@
1
+ from unittest import TestCase
2
+
3
+ from ripple_down_rules.datastructures.dataclasses import CaseQuery
4
+ from ripple_down_rules.datastructures.enums import PromptFor
5
+ from ripple_down_rules.user_interface.template_file_creator import TemplateFileCreator
6
+ from test_rdr_world import World, Handle, Container
7
+
8
+
9
+ class TestTemplateFileCreator(TestCase):
10
+
11
+ def test_func_name_with_one_type(self):
12
+ # Test the function name
13
+ world = World()
14
+ case_query: CaseQuery = CaseQuery(world, "views", (Handle,), False)
15
+
16
+ func_name = TemplateFileCreator.get_func_name(PromptFor.Conclusion, case_query)
17
+ self.assertEqual(func_name, "world_views_of_type_handle")
18
+
19
+ func_name = TemplateFileCreator.get_func_name(PromptFor.Conditions, case_query)
20
+ self.assertEqual(func_name, "conditions_for_world_views_of_type_handle")
21
+
22
+ def test_func_name_with_two_type(self):
23
+ # Test the function name
24
+ world = World()
25
+ case_query: CaseQuery = CaseQuery(world, "views", (Handle, Container), False)
26
+
27
+ func_name = TemplateFileCreator.get_func_name(PromptFor.Conclusion, case_query)
28
+ self.assertEqual(func_name, "world_views_of_type_handle_or_container")
29
+
30
+ func_name = TemplateFileCreator.get_func_name(PromptFor.Conditions, case_query)
31
+ self.assertEqual(func_name, "conditions_for_world_views_of_type_handle_or_container")
32
+
33
+ def test_func_name_with_not_needed_types(self):
34
+ # Test the function name
35
+ world = World()
36
+ case_query: CaseQuery = CaseQuery(world, "views", (Handle, list, bool, type(None)), False)
37
+
38
+ func_name = TemplateFileCreator.get_func_name(PromptFor.Conclusion, case_query)
39
+ self.assertEqual(func_name, "world_views_of_type_handle")
40
+
41
+ func_name = TemplateFileCreator.get_func_name(PromptFor.Conditions, case_query)
42
+ self.assertEqual(func_name, "conditions_for_world_views_of_type_handle")