Skip to content

Commit 8cb7baa

Browse files
committed
Add check for empty dict
1 parent a8741cd commit 8cb7baa

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

pyreason/scripts/interpretation/interpretation.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,8 +1720,14 @@ def is_satisfied_node(interpretations, comp, na, minimized_predicates):
17201720
print(' world keys:')
17211721
for k in world.world.keys():
17221722
print(' ', k.get_value(), '= [', float_to_str(world.world[k].l), ',', float_to_str(world.world[k].u), ']')
1723-
# Minimized predicate: if world bound is [0,1] (unknown), treat as [0,0] (false)
1723+
# Minimized predicate check
17241724
if na[0] in minimized_predicates:
1725+
if na[0] not in world.world:
1726+
# Label not in world — missing = unknown [0,1] = treat as [0,0]
1727+
print(' MINIMIZED (label not in world): treating as [0,0]')
1728+
result = interval.closed(0, 0) in na[1]
1729+
print(' result:', result)
1730+
return result
17251731
world_bnd = world.world[na[0]]
17261732
if world_bnd.lower == 0.0 and world_bnd.upper == 1.0:
17271733
print(' MINIMIZED: world bound [0,1] -> treating as [0,0]')
@@ -1787,8 +1793,14 @@ def is_satisfied_edge(interpretations, comp, na, minimized_predicates):
17871793
print(' world keys:')
17881794
for k in world.world.keys():
17891795
print(' ', k.get_value(), '= [', float_to_str(world.world[k].l), ',', float_to_str(world.world[k].u), ']')
1790-
# Minimized predicate: if world bound is [0,1] (unknown), treat as [0,0] (false)
1796+
# Minimized predicate check
17911797
if na[0] in minimized_predicates:
1798+
if na[0] not in world.world:
1799+
# Label not in world — missing = unknown [0,1] = treat as [0,0]
1800+
print(' MINIMIZED (label not in world): treating as [0,0]')
1801+
result = interval.closed(0, 0) in na[1]
1802+
print(' result:', result)
1803+
return result
17921804
world_bnd = world.world[na[0]]
17931805
if world_bnd.lower == 0.0 and world_bnd.upper == 1.0:
17941806
print(' MINIMIZED: world bound [0,1] -> treating as [0,0]')

pyreason/scripts/interpretation/interpretation_fp.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,8 +1830,14 @@ def is_satisfied_node(interpretations, comp, na, minimized_predicates):
18301830
print(' world keys:')
18311831
for k in world.world.keys():
18321832
print(' ', k.get_value(), '= [', float_to_str(world.world[k].l), ',', float_to_str(world.world[k].u), ']')
1833-
# Minimized predicate: if world bound is [0,1] (unknown), treat as [0,0] (false)
1833+
# Minimized predicate check
18341834
if na[0] in minimized_predicates:
1835+
if na[0] not in world.world:
1836+
# Label not in world — missing = unknown [0,1] = treat as [0,0]
1837+
print(' MINIMIZED (label not in world): treating as [0,0]')
1838+
result = interval.closed(0, 0) in na[1]
1839+
print(' result:', result)
1840+
return result
18351841
world_bnd = world.world[na[0]]
18361842
if world_bnd.lower == 0.0 and world_bnd.upper == 1.0:
18371843
print(' MINIMIZED: world bound [0,1] -> treating as [0,0]')
@@ -1897,8 +1903,14 @@ def is_satisfied_edge(interpretations, comp, na, minimized_predicates):
18971903
print(' world keys:')
18981904
for k in world.world.keys():
18991905
print(' ', k.get_value(), '= [', float_to_str(world.world[k].l), ',', float_to_str(world.world[k].u), ']')
1900-
# Minimized predicate: if world bound is [0,1] (unknown), treat as [0,0] (false)
1906+
# Minimized predicate check
19011907
if na[0] in minimized_predicates:
1908+
if na[0] not in world.world:
1909+
# Label not in world — missing = unknown [0,1] = treat as [0,0]
1910+
print(' MINIMIZED (label not in world): treating as [0,0]')
1911+
result = interval.closed(0, 0) in na[1]
1912+
print(' result:', result)
1913+
return result
19021914
world_bnd = world.world[na[0]]
19031915
if world_bnd.lower == 0.0 and world_bnd.upper == 1.0:
19041916
print(' MINIMIZED: world bound [0,1] -> treating as [0,0]')

0 commit comments

Comments
 (0)