Skip to content

Commit 78ff570

Browse files
authored
Merge pull request #61 from lab-v2/bug-predicate-map
fixed bug in predicate map implementation
2 parents 8c2f860 + 7342c35 commit 78ff570

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

pyreason/scripts/interpretation/interpretation.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,11 @@ def _init_interpretations_node(nodes, specific_labels, num_ga):
140140

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

147-
for l, ns in specific_labels.items():
148-
predicate_map[l] = numba.typed.List(ns)
149-
150148
return interpretations, predicate_map
151149

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

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

168-
for l, es in specific_labels.items():
169-
predicate_map[l] = numba.typed.List(es)
170-
171167
return interpretations, predicate_map
172168

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

1859+
if l in predicate_map:
1860+
predicate_map[l].append(edge)
1861+
else:
1862+
predicate_map[l] = numba.typed.List([edge])
1863+
18631864
return edge, new_edge
18641865

18651866

pyreason/scripts/interpretation/interpretation_parallel.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,11 @@ def _init_interpretations_node(nodes, specific_labels, num_ga):
140140

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

147-
for l, ns in specific_labels.items():
148-
predicate_map[l] = numba.typed.List(ns)
149-
150148
return interpretations, predicate_map
151149

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

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

168-
for l, es in specific_labels.items():
169-
predicate_map[l] = numba.typed.List(es)
170-
171167
return interpretations, predicate_map
172168

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

224220
@staticmethod
225-
@numba.njit(cache=True, parallel=True)
221+
@numba.njit(cache=True, parallel=False)
226222
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):
227223
t = prev_reasoning_data[0]
228224
fp_cnt = prev_reasoning_data[1]
@@ -1860,6 +1856,11 @@ def _add_edge(source, target, neighbors, reverse_neighbors, nodes, edges, l, int
18601856
interpretations_edge[edge].world[l] = interval.closed(0, 1)
18611857
num_ga[t] += 1
18621858

1859+
if l in predicate_map:
1860+
predicate_map[l].append(edge)
1861+
else:
1862+
predicate_map[l] = numba.typed.List([edge])
1863+
18631864
return edge, new_edge
18641865

18651866

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='pyreason',
11-
version='3.0.0',
11+
version='3.0.1',
1212
author='Dyuman Aditya',
1313
author_email='[email protected]',
1414
description='An explainable inference software supporting annotated, real valued, graph based and temporal logic',

0 commit comments

Comments
 (0)