Skip to content

Commit

Permalink
more debugging (!!wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
cknoll committed Dec 19, 2023
1 parent a1b9d55 commit 00378d0
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/pyirk/ruleengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,17 @@ def repl(m):
return res


def _resolve_local_node(self, node):
def _resolve_local_node(self, node=None, uri=None):
"""
return item or literal
"""

uri = self.local_nodes.b.get(node)
assert not (node is None and uri is None)

if uri is None:
uri = self.local_nodes.b.get(node)
else:
assert node is None
assert uri is not None
lit = self.parent.literals.a.get(uri)
if lit is not None:
Expand All @@ -504,9 +509,9 @@ def _get_understandable_local_nodes(self):
It is intendend for debugging only.
"""
res = {}
for k, v in self.local_nodes.a.items():
for k_uri, v in self.local_nodes.a.items():

item_or_lit = self._resolve_local_node(k)
item_or_lit = self._resolve_local_node(uri=k_uri)
res[str(item_or_lit)] = v
return res

Expand Down Expand Up @@ -540,6 +545,9 @@ def apply_graph_premise(self) -> core.RuleResult:
#
# TODO: to debug the result_maps data structure the following things might be helpful:
# - a visualization of the prototype graph self.P
dbg = self._get_understandable_result_maps(result_maps)

# now apply condition funcs (to filter the results) and consequent funcs (to do something)
res = self._process_result_map(result_maps)
res.apply_time = time.time() - t0

Expand Down Expand Up @@ -902,6 +910,7 @@ def match_subgraph_P(self) -> List[dict]:
# 2: <Item I9642["local exponential stability"]>
# }, ... ]

# IPS()
return new_res

def _get_by_uri(self, uri):
Expand Down Expand Up @@ -939,6 +948,9 @@ def _node_matcher(self, n1d: dict, n2d: dict) -> bool:
see also: function edge_matcher
"""

# cond = not n1d["is_literal"] and n1d["itm"].R4 is not None and "square matrix" in str(n1d["itm"].R4)
cond = not n1d["is_literal"] and n1d["itm"].short_key == "Ia7720"

if n1d["is_literal"]:
if n2d.get("is_variable_literal"):
return True
Expand Down Expand Up @@ -1255,6 +1267,8 @@ def edge_matcher(e1d: AtlasView, e2d: AtlasView) -> bool:

e2d = e2d[0]

# IPS("R5938" in str(e1d) + str(e2d))

if e2d["rel_uri"] == wildcard_relation_uri:
# wildcard relations matches any relation which has the required relation properties

Expand Down

0 comments on commit 00378d0

Please sign in to comment.