Skip to content

Commit

Permalink
Merge pull request #61 from lab-v2/bug-predicate-map
Browse files Browse the repository at this point in the history
fixed bug in predicate map implementation
  • Loading branch information
dyumanaditya authored Dec 15, 2024
2 parents 8c2f860 + 7342c35 commit 78ff570
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
13 changes: 7 additions & 6 deletions pyreason/scripts/interpretation/interpretation.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,11 @@ def _init_interpretations_node(nodes, specific_labels, num_ga):

# Specific labels
for l, ns in specific_labels.items():
predicate_map[l] = numba.typed.List(ns)
for n in ns:
interpretations[n].world[l] = interval.closed(0.0, 1.0)
num_ga[0] += 1

for l, ns in specific_labels.items():
predicate_map[l] = numba.typed.List(ns)

return interpretations, predicate_map

@staticmethod
Expand All @@ -161,13 +159,11 @@ def _init_interpretations_edge(edges, specific_labels, num_ga):

# Specific labels
for l, es in specific_labels.items():
predicate_map[l] = numba.typed.List(es)
for e in es:
interpretations[e].world[l] = interval.closed(0.0, 1.0)
num_ga[0] += 1

for l, es in specific_labels.items():
predicate_map[l] = numba.typed.List(es)

return interpretations, predicate_map

@staticmethod
Expand Down Expand Up @@ -1860,6 +1856,11 @@ def _add_edge(source, target, neighbors, reverse_neighbors, nodes, edges, l, int
interpretations_edge[edge].world[l] = interval.closed(0, 1)
num_ga[t] += 1

if l in predicate_map:
predicate_map[l].append(edge)
else:
predicate_map[l] = numba.typed.List([edge])

return edge, new_edge


Expand Down
15 changes: 8 additions & 7 deletions pyreason/scripts/interpretation/interpretation_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,11 @@ def _init_interpretations_node(nodes, specific_labels, num_ga):

# Specific labels
for l, ns in specific_labels.items():
predicate_map[l] = numba.typed.List(ns)
for n in ns:
interpretations[n].world[l] = interval.closed(0.0, 1.0)
num_ga[0] += 1

for l, ns in specific_labels.items():
predicate_map[l] = numba.typed.List(ns)

return interpretations, predicate_map

@staticmethod
Expand All @@ -161,13 +159,11 @@ def _init_interpretations_edge(edges, specific_labels, num_ga):

# Specific labels
for l, es in specific_labels.items():
predicate_map[l] = numba.typed.List(es)
for e in es:
interpretations[e].world[l] = interval.closed(0.0, 1.0)
num_ga[0] += 1

for l, es in specific_labels.items():
predicate_map[l] = numba.typed.List(es)

return interpretations, predicate_map

@staticmethod
Expand Down Expand Up @@ -222,7 +218,7 @@ def _start_fp(self, rules, max_facts_time, verbose, again):
print('Fixed Point iterations:', fp_cnt)

@staticmethod
@numba.njit(cache=True, parallel=True)
@numba.njit(cache=True, parallel=False)
def reason(interpretations_node, interpretations_edge, predicate_map_node, predicate_map_edge, tmax, prev_reasoning_data, rules, nodes, edges, neighbors, reverse_neighbors, rules_to_be_applied_node, rules_to_be_applied_edge, edges_to_be_added_node_rule, edges_to_be_added_edge_rule, rules_to_be_applied_node_trace, rules_to_be_applied_edge_trace, facts_to_be_applied_node, facts_to_be_applied_edge, facts_to_be_applied_node_trace, facts_to_be_applied_edge_trace, ipl, rule_trace_node, rule_trace_edge, rule_trace_node_atoms, rule_trace_edge_atoms, reverse_graph, atom_trace, save_graph_attributes_to_rule_trace, persistent, inconsistency_check, store_interpretation_changes, update_mode, allow_ground_rules, max_facts_time, annotation_functions, convergence_mode, convergence_delta, num_ga, verbose, again):
t = prev_reasoning_data[0]
fp_cnt = prev_reasoning_data[1]
Expand Down Expand Up @@ -1860,6 +1856,11 @@ def _add_edge(source, target, neighbors, reverse_neighbors, nodes, edges, l, int
interpretations_edge[edge].world[l] = interval.closed(0, 1)
num_ga[t] += 1

if l in predicate_map:
predicate_map[l].append(edge)
else:
predicate_map[l] = numba.typed.List([edge])

return edge, new_edge


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='pyreason',
version='3.0.0',
version='3.0.1',
author='Dyuman Aditya',
author_email='[email protected]',
description='An explainable inference software supporting annotated, real valued, graph based and temporal logic',
Expand Down

0 comments on commit 78ff570

Please sign in to comment.