ripple-down-rules 0.6.51__py3-none-any.whl → 0.6.60__py3-none-any.whl
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.
- ripple_down_rules/__init__.py +12 -4
- ripple_down_rules/datastructures/dataclasses.py +52 -9
- ripple_down_rules/datastructures/enums.py +14 -87
- ripple_down_rules/datastructures/field_info.py +177 -0
- ripple_down_rules/datastructures/tracked_object.py +208 -0
- ripple_down_rules/helpers.py +37 -2
- ripple_down_rules/predicates.py +97 -0
- ripple_down_rules/rdr.py +10 -6
- ripple_down_rules/rdr_decorators.py +44 -34
- ripple_down_rules/rules.py +166 -97
- ripple_down_rules/user_interface/ipython_custom_shell.py +9 -1
- ripple_down_rules/user_interface/prompt.py +37 -37
- ripple_down_rules/user_interface/template_file_creator.py +3 -0
- ripple_down_rules/utils.py +32 -5
- {ripple_down_rules-0.6.51.dist-info → ripple_down_rules-0.6.60.dist-info}/METADATA +3 -1
- ripple_down_rules-0.6.60.dist-info/RECORD +28 -0
- ripple_down_rules-0.6.51.dist-info/RECORD +0 -25
- {ripple_down_rules-0.6.51.dist-info → ripple_down_rules-0.6.60.dist-info}/WHEEL +0 -0
- {ripple_down_rules-0.6.51.dist-info → ripple_down_rules-0.6.60.dist-info}/licenses/LICENSE +0 -0
- {ripple_down_rules-0.6.51.dist-info → ripple_down_rules-0.6.60.dist-info}/top_level.txt +0 -0
ripple_down_rules/utils.py
CHANGED
@@ -269,7 +269,8 @@ def encapsulate_user_input(user_input: str, func_signature: str, func_doc: Optio
|
|
269
269
|
:param func_doc: The function docstring to use for encapsulation.
|
270
270
|
:return: The encapsulated user input string.
|
271
271
|
"""
|
272
|
-
|
272
|
+
func_name = func_signature.split('(')[0].strip()
|
273
|
+
if func_name not in user_input:
|
273
274
|
new_user_input = func_signature + "\n "
|
274
275
|
if func_doc is not None:
|
275
276
|
new_user_input += f"\"\"\"{func_doc}\"\"\"" + "\n "
|
@@ -697,18 +698,21 @@ def capture_variable_assignment(code: str, variable_name: str) -> Optional[str]:
|
|
697
698
|
return assignment
|
698
699
|
|
699
700
|
|
700
|
-
def get_func_rdr_model_path(func: Callable, model_dir: str) -> str:
|
701
|
+
def get_func_rdr_model_path(func: Callable, model_dir: str, include_file_name: bool = False) -> str:
|
701
702
|
"""
|
702
703
|
:param func: The function to get the model path for.
|
703
704
|
:param model_dir: The directory to save the model to.
|
705
|
+
:param include_file_name: Whether to include the file name in the model name.
|
704
706
|
:return: The path to the model file.
|
705
707
|
"""
|
706
|
-
return os.path.join(model_dir,
|
708
|
+
return os.path.join(model_dir, get_func_rdr_model_name(func, include_file_name=include_file_name),
|
709
|
+
f"{get_func_rdr_model_name(func)}_rdr.py")
|
707
710
|
|
708
711
|
|
709
712
|
def get_func_rdr_model_name(func: Callable, include_file_name: bool = False) -> str:
|
710
713
|
"""
|
711
714
|
:param func: The function to get the model name for.
|
715
|
+
:param include_file_name: Whether to include the file name in the model name.
|
712
716
|
:return: The name of the model.
|
713
717
|
"""
|
714
718
|
func_name = get_method_name(func)
|
@@ -720,7 +724,7 @@ def get_func_rdr_model_name(func: Callable, include_file_name: bool = False) ->
|
|
720
724
|
model_name = ''
|
721
725
|
model_name += f"{func_class_name}_" if func_class_name else ""
|
722
726
|
model_name += f"{func_name}"
|
723
|
-
return model_name
|
727
|
+
return str_to_snake_case(model_name)
|
724
728
|
|
725
729
|
|
726
730
|
def stringify_hint(tp):
|
@@ -1116,7 +1120,8 @@ def get_method_class_name_if_exists(method: Callable) -> Optional[str]:
|
|
1116
1120
|
return method.__self__.__name__
|
1117
1121
|
elif hasattr(method.__self__, "__class__"):
|
1118
1122
|
return method.__self__.__class__.__name__
|
1119
|
-
return method.__qualname__.split('.')[0]
|
1123
|
+
return (method.__qualname__.split('.')[0]
|
1124
|
+
if hasattr(method, "__qualname__") and '.' in method.__qualname__ else None)
|
1120
1125
|
|
1121
1126
|
|
1122
1127
|
def get_method_class_if_exists(method: Callable, *args) -> Optional[Type]:
|
@@ -1214,6 +1219,7 @@ def get_full_class_name(cls):
|
|
1214
1219
|
def recursive_subclasses(cls):
|
1215
1220
|
"""
|
1216
1221
|
Copied from: https://github.com/tomsch420/random-events/blob/master/src/random_events/utils.py#L6C1-L21C101
|
1222
|
+
|
1217
1223
|
:param cls: The class.
|
1218
1224
|
:return: A list of the classes subclasses.
|
1219
1225
|
"""
|
@@ -1684,6 +1690,13 @@ def get_all_subclasses(cls: Type) -> Dict[str, Type]:
|
|
1684
1690
|
return all_subclasses
|
1685
1691
|
|
1686
1692
|
|
1693
|
+
def make_tuple(value: Any) -> Any:
|
1694
|
+
"""
|
1695
|
+
Make a tuple from a value.
|
1696
|
+
"""
|
1697
|
+
return tuple(value) if is_iterable(value) else (value,)
|
1698
|
+
|
1699
|
+
|
1687
1700
|
def make_set(value: Any) -> Set:
|
1688
1701
|
"""
|
1689
1702
|
Make a set from a value.
|
@@ -2155,3 +2168,17 @@ def encapsulate_code_lines_into_a_function(code_lines: List[str], function_name:
|
|
2155
2168
|
if f"return {function_name}({args})" not in code:
|
2156
2169
|
code = code.strip() + f"\nreturn {function_name}({args})"
|
2157
2170
|
return code
|
2171
|
+
|
2172
|
+
|
2173
|
+
def get_method_object_from_pytest_request(request) -> Callable:
|
2174
|
+
test_module = request.module.__name__ # e.g., "test_my_module"
|
2175
|
+
test_class = request.cls.__name__ if request.cls else None # if inside a class
|
2176
|
+
test_name = request.node.name
|
2177
|
+
func = importlib.import_module(test_module)
|
2178
|
+
if test_class:
|
2179
|
+
func = getattr(getattr(func, test_class), test_name)
|
2180
|
+
else:
|
2181
|
+
func = getattr(func, test_name)
|
2182
|
+
return func
|
2183
|
+
|
2184
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ripple_down_rules
|
3
|
-
Version: 0.6.
|
3
|
+
Version: 0.6.60
|
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
|
@@ -696,6 +696,8 @@ Requires-Dist: sqlalchemy
|
|
696
696
|
Requires-Dist: pandas
|
697
697
|
Requires-Dist: pyparsing>=3.2.3
|
698
698
|
Requires-Dist: omegaconf
|
699
|
+
Requires-Dist: rustworkx
|
700
|
+
Requires-Dist: pydot
|
699
701
|
Provides-Extra: viz
|
700
702
|
Requires-Dist: networkx>=3.1; extra == "viz"
|
701
703
|
Requires-Dist: matplotlib>=3.7.5; extra == "viz"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
ripple_down_rules/__init__.py,sha256=nnv2FjfJWL9gNuqLKXbj64QDYQlQElO28_32Pb5SG-I,585
|
2
|
+
ripple_down_rules/experts.py,sha256=KXwWCmDrCffu9HW3yNewqWc1e5rnPI5Rnc981w_5M7U,17896
|
3
|
+
ripple_down_rules/failures.py,sha256=ZPypPwKjyVcJkY9YG6p538ld8ZzpdW6CrC1RmJi44Ek,42
|
4
|
+
ripple_down_rules/helpers.py,sha256=ZnmhVJs5MBopRp3-lj-Pqgd0j6EOJW1fiQe60Rnp2nE,7360
|
5
|
+
ripple_down_rules/predicates.py,sha256=18_lir_rDtXrtLcwfd1t8x2iq8JMMmXshPQ5RW1p5Es,3211
|
6
|
+
ripple_down_rules/rdr.py,sha256=lI2bdMPN0Oda8Z4kG0Yc7d8Jhci9BIaNhbHJ-Uv1JUU,84547
|
7
|
+
ripple_down_rules/rdr_decorators.py,sha256=rlUQcukp3HIl58p9BqH9Q8SK2MtQUOK8IBE1Wlp1d4w,12468
|
8
|
+
ripple_down_rules/rules.py,sha256=1gPg4Qrp1r3JAey1woHPH57ONHyZcsLq4foR5pafVTA,30735
|
9
|
+
ripple_down_rules/start-code-server.sh,sha256=otClk7VmDgBOX2TS_cjws6K0UwvgAUJhoA0ugkPCLqQ,949
|
10
|
+
ripple_down_rules/utils.py,sha256=MFb4pKFq0fOhbTIAR5I6r39djU0YS1Yq-Km9k9OnuFM,81748
|
11
|
+
ripple_down_rules/datastructures/__init__.py,sha256=V2aNgf5C96Y5-IGghra3n9uiefpoIm_QdT7cc_C8cxQ,111
|
12
|
+
ripple_down_rules/datastructures/callable_expression.py,sha256=Eq8_9wlFIZex3Y3htwg-AKu-B7053f0Qk6dvMo1Nlts,13815
|
13
|
+
ripple_down_rules/datastructures/case.py,sha256=dfLnrjsHIVF2bgbz-4ID7OdQvw68V71btCeTK372P-g,15667
|
14
|
+
ripple_down_rules/datastructures/dataclasses.py,sha256=puZjT-B6DDO8PU_uk05exYvXYKk9ltwoiXuO9yqWaC4,15045
|
15
|
+
ripple_down_rules/datastructures/enums.py,sha256=oiI8uPPmiAdJwvJkoAsOkxH7hyGwqt6x_K4fsFd8kDM,4445
|
16
|
+
ripple_down_rules/datastructures/field_info.py,sha256=7vxrLGbP9XIjKr5QKdQhpIE36t0vRQZkZqX-A0M68UE,5397
|
17
|
+
ripple_down_rules/datastructures/tracked_object.py,sha256=mWJ4kuhUfd5gbG3DFL1zBUHjKT0zo8ocGssxy4PgnGw,8345
|
18
|
+
ripple_down_rules/user_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
|
+
ripple_down_rules/user_interface/gui.py,sha256=K6cvA9TOXIDpk0quGCamrWqDRlvz0QruDaTj4Y4PWWI,28544
|
20
|
+
ripple_down_rules/user_interface/ipython_custom_shell.py,sha256=b4HkbClZIxRMH_YKOYBqDqt2z2LzKEOxvcroSa34AIg,7976
|
21
|
+
ripple_down_rules/user_interface/object_diagram.py,sha256=FEa2HaYR9QmTE6NsOwBvZ0jqmu3DKyg6mig2VE5ZP4Y,4956
|
22
|
+
ripple_down_rules/user_interface/prompt.py,sha256=ZjuOkncQd1ape79bygjsVk-zixnT1vBxwK2kK8LtE2Q,10439
|
23
|
+
ripple_down_rules/user_interface/template_file_creator.py,sha256=HeqI37zfgimivDLnsVsnvKu5utj8Zoq0Ou7G4fbciK0,13783
|
24
|
+
ripple_down_rules-0.6.60.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
25
|
+
ripple_down_rules-0.6.60.dist-info/METADATA,sha256=ExGgaA1xdOMTkqtoNtDhR3ZkpA7Mh2BHjRu0Q4bdXbI,48340
|
26
|
+
ripple_down_rules-0.6.60.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
27
|
+
ripple_down_rules-0.6.60.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
|
28
|
+
ripple_down_rules-0.6.60.dist-info/RECORD,,
|
@@ -1,25 +0,0 @@
|
|
1
|
-
ripple_down_rules/__init__.py,sha256=CEBeSdz-FJtYgbev1cmm7aT0S9BXptU3COOsvgBLT2M,375
|
2
|
-
ripple_down_rules/experts.py,sha256=KXwWCmDrCffu9HW3yNewqWc1e5rnPI5Rnc981w_5M7U,17896
|
3
|
-
ripple_down_rules/failures.py,sha256=ZPypPwKjyVcJkY9YG6p538ld8ZzpdW6CrC1RmJi44Ek,42
|
4
|
-
ripple_down_rules/helpers.py,sha256=sVU1Q7HPbMh57X8zDYP6vj1maDoaVAvnXHpUYIbr_As,5715
|
5
|
-
ripple_down_rules/rdr.py,sha256=M7CEjHIegJWiDZtn-B8Qf9CpMvplAkrFX3HiiyGQC7M,84292
|
6
|
-
ripple_down_rules/rdr_decorators.py,sha256=mu7pZM6tqjkjoKg1m4f5yXhaRL8RiZu75ABaU275qTY,11751
|
7
|
-
ripple_down_rules/rules.py,sha256=L4Ws-x3g5ljE0GrDt4LAib2qtR1C1_Ra4cRcIB-IQDI,28702
|
8
|
-
ripple_down_rules/start-code-server.sh,sha256=otClk7VmDgBOX2TS_cjws6K0UwvgAUJhoA0ugkPCLqQ,949
|
9
|
-
ripple_down_rules/utils.py,sha256=5UL4h-m5Q4l7RyCYqmUmDDxUAkFqPYpFa3QldDYoJUE,80752
|
10
|
-
ripple_down_rules/datastructures/__init__.py,sha256=V2aNgf5C96Y5-IGghra3n9uiefpoIm_QdT7cc_C8cxQ,111
|
11
|
-
ripple_down_rules/datastructures/callable_expression.py,sha256=Eq8_9wlFIZex3Y3htwg-AKu-B7053f0Qk6dvMo1Nlts,13815
|
12
|
-
ripple_down_rules/datastructures/case.py,sha256=dfLnrjsHIVF2bgbz-4ID7OdQvw68V71btCeTK372P-g,15667
|
13
|
-
ripple_down_rules/datastructures/dataclasses.py,sha256=3vX52WrAHgVyw0LUSgSBOVFaQNTSxU8hQpdr7cW-tSg,13278
|
14
|
-
ripple_down_rules/datastructures/enums.py,sha256=CvcROl8fE7A6uTbMfs2lLpyxwS_ZFtFcQlBDDKFfoHc,6059
|
15
|
-
ripple_down_rules/user_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
ripple_down_rules/user_interface/gui.py,sha256=K6cvA9TOXIDpk0quGCamrWqDRlvz0QruDaTj4Y4PWWI,28544
|
17
|
-
ripple_down_rules/user_interface/ipython_custom_shell.py,sha256=GQf5Je5szkPH17g42zHQ3cKy_MATywXV2bCpwSKKsZE,7711
|
18
|
-
ripple_down_rules/user_interface/object_diagram.py,sha256=FEa2HaYR9QmTE6NsOwBvZ0jqmu3DKyg6mig2VE5ZP4Y,4956
|
19
|
-
ripple_down_rules/user_interface/prompt.py,sha256=WPbw_8_-8SpF2ISyRZRuFwPKBEuGC4HaX3lbCPFHhh8,10314
|
20
|
-
ripple_down_rules/user_interface/template_file_creator.py,sha256=uSbosZS15MOR3Nv7M3MrFuoiKXyP4cBId-EK3I6stHM,13660
|
21
|
-
ripple_down_rules-0.6.51.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
22
|
-
ripple_down_rules-0.6.51.dist-info/METADATA,sha256=uq85MFVRjE4NgR42SGGABOKLLbigoHn776Pa_P74oaU,48294
|
23
|
-
ripple_down_rules-0.6.51.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
24
|
-
ripple_down_rules-0.6.51.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
|
25
|
-
ripple_down_rules-0.6.51.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|