ripple-down-rules 0.6.1__py3-none-any.whl → 0.6.11__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.
@@ -1,4 +1,4 @@
1
- __version__ = "0.6.1"
1
+ __version__ = "0.6.11"
2
2
 
3
3
  import logging
4
4
  logger = logging.Logger("rdr")
@@ -55,7 +55,7 @@ def general_rdr_classify(classifiers_dict: Dict[str, Union[ModuleType, RippleDow
55
55
  if attribute_name in new_conclusions:
56
56
  temp_case_query = CaseQuery(case_cp, attribute_name, rdr.conclusion_type, rdr.mutually_exclusive)
57
57
  update_case(temp_case_query, new_conclusions)
58
- if len(new_conclusions) == 0 or (len(classifiers_dict) == 1 and all(rdr.mutually_exclusive for rdr in classifiers_dict.values())):
58
+ if len(new_conclusions) == 0: #or (len(classifiers_dict) == 1 and all(rdr.mutually_exclusive for rdr in classifiers_dict.values())):
59
59
  break
60
60
  return conclusions
61
61
 
@@ -33,7 +33,8 @@ class RDRDecorator:
33
33
  viewer: Optional[RDRCaseViewer] = None,
34
34
  package_name: Optional[str] = None,
35
35
  use_generated_classifier: bool = False,
36
- ask_now: Callable[[Any], bool] = lambda _: True):
36
+ ask_now: Callable[[Any], bool] = lambda _: True,
37
+ fitting_decorator: Optional[Callable] = None):
37
38
  """
38
39
  :param models_dir: The directory to save/load the RDR models.
39
40
  :param output_type: The type of the output. This is used to create the RDR model.
@@ -66,6 +67,7 @@ class RDRDecorator:
66
67
  self.use_generated_classifier = use_generated_classifier
67
68
  self.generated_classifier: Optional[Callable] = None
68
69
  self.ask_now = ask_now
70
+ self.fitting_decorator = fitting_decorator
69
71
  self.load()
70
72
 
71
73
  def decorator(self, func: Callable) -> Callable:
@@ -79,8 +81,9 @@ class RDRDecorator:
79
81
  func_output = {self.output_name: func(*args, **kwargs)}
80
82
 
81
83
  case, case_dict = self.create_case_from_method(func, func_output, *args, **kwargs)
82
-
83
- if self.fit and not self.use_generated_classifier and self.ask_now(case_dict):
84
+
85
+ @self.fitting_decorator
86
+ def fit():
84
87
  if len(self.parsed_output_type) == 0:
85
88
  self.parsed_output_type = self.parse_output_type(func, self.output_type, *args)
86
89
  if self.expert is None:
@@ -89,10 +92,16 @@ class RDRDecorator:
89
92
  case_query = self.create_case_query_from_method(func, func_output,
90
93
  self.parsed_output_type,
91
94
  self.mutual_exclusive,
95
+ case, case_dict,
92
96
  *args, **kwargs)
97
+ # import pdb; pdb.set_trace()
93
98
  output = self.rdr.fit_case(case_query, expert=self.expert,
94
99
  update_existing_rules=self.update_existing_rules,
95
100
  viewer=self.viewer)
101
+ return output
102
+
103
+ if self.fit and not self.use_generated_classifier and self.ask_now(case_dict):
104
+ output = fit()
96
105
  else:
97
106
  if self.use_generated_classifier:
98
107
  if self.generated_classifier is None:
@@ -114,6 +123,8 @@ class RDRDecorator:
114
123
  func_output: Dict[str, Any],
115
124
  output_type: Sequence[Type],
116
125
  mutual_exclusive: bool,
126
+ case: Optional[Case] = None,
127
+ case_dict: Optional[Dict[str, Any]] = None,
117
128
  *args, **kwargs) -> CaseQuery:
118
129
  """
119
130
  Create a CaseQuery from the function and its arguments.
@@ -127,7 +138,8 @@ class RDRDecorator:
127
138
  :return: A CaseQuery object representing the case.
128
139
  """
129
140
  output_type = make_set(output_type)
130
- case, case_dict = RDRDecorator.create_case_from_method(func, func_output, *args, **kwargs)
141
+ if case is None or case_dict is None:
142
+ case, case_dict = RDRDecorator.create_case_from_method(func, func_output, *args, **kwargs)
131
143
  scope = func.__globals__
132
144
  scope.update(case_dict)
133
145
  func_args_type_hints = get_type_hints(func)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ripple_down_rules
3
- Version: 0.6.1
3
+ Version: 0.6.11
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,8 +1,8 @@
1
- ripple_down_rules/__init__.py,sha256=B8pB51s_DLQLsz-ddWBpBxmHt45Fr_FCoKmP-nvXKJ4,99
1
+ ripple_down_rules/__init__.py,sha256=HFiQNi2SqhUFClhVWHplxqW2PHHMj-43eIFUOxkn4as,100
2
2
  ripple_down_rules/experts.py,sha256=4-dMIVeMzFXCLYl_XBG_P7_Xs4sZih9-vZxCIPri6dA,12958
3
- ripple_down_rules/helpers.py,sha256=OVjQm57hm4yUkGrmQB0w3GmuILdYP9yCiJ4QrwfZPeo,4596
3
+ ripple_down_rules/helpers.py,sha256=6njZZoxOa5MH47wky4w2llrGYFK_llfny7NQZCEejxU,4598
4
4
  ripple_down_rules/rdr.py,sha256=G0UWETaXddDOaNWTqfxPWkCSDiWkMEU_aBUWcsnJUN0,56147
5
- ripple_down_rules/rdr_decorators.py,sha256=0GpWuAOPLYc8WFc5SN8PgHRLNgcHw8dNMmeIbaB8Los,10085
5
+ ripple_down_rules/rdr_decorators.py,sha256=cqfLaIDIyCjlR3tsIgOWJDdDsDk1nA1Atx-vlKFaIxY,10646
6
6
  ripple_down_rules/rules.py,sha256=Dk4yGCy5oV10mOv5rRLcmtIu9J60WBPol9b7ELFn6fY,21522
7
7
  ripple_down_rules/start-code-server.sh,sha256=otClk7VmDgBOX2TS_cjws6K0UwvgAUJhoA0ugkPCLqQ,949
8
8
  ripple_down_rules/utils.py,sha256=vFoz5HcRgkf7_s-zdWSg54xI9PCMcdDzcdFGdas7KBA,62350
@@ -17,8 +17,8 @@ ripple_down_rules/user_interface/ipython_custom_shell.py,sha256=yp-F8YRWGhj1PLB3
17
17
  ripple_down_rules/user_interface/object_diagram.py,sha256=FEa2HaYR9QmTE6NsOwBvZ0jqmu3DKyg6mig2VE5ZP4Y,4956
18
18
  ripple_down_rules/user_interface/prompt.py,sha256=JceEUGYsd0lIvd-v2y3D3swoo96_C0lxfp3CxM7Vfts,8900
19
19
  ripple_down_rules/user_interface/template_file_creator.py,sha256=kwBbFLyN6Yx2NTIHPSwOoytWgbJDYhgrUOVFw_jkDQ4,13522
20
- ripple_down_rules-0.6.1.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
21
- ripple_down_rules-0.6.1.dist-info/METADATA,sha256=ykWY4i5avTIJHNvn3E8_8E398isJFxzzACRL-x_G5Fs,48213
22
- ripple_down_rules-0.6.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- ripple_down_rules-0.6.1.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
24
- ripple_down_rules-0.6.1.dist-info/RECORD,,
20
+ ripple_down_rules-0.6.11.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
21
+ ripple_down_rules-0.6.11.dist-info/METADATA,sha256=1pKWXY6fCKqe6fFgW_3fTrqh-hI2rODPa53cnU4K1RQ,48214
22
+ ripple_down_rules-0.6.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ ripple_down_rules-0.6.11.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
24
+ ripple_down_rules-0.6.11.dist-info/RECORD,,