Skip to content

Commit

Permalink
Fixing the flake issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
haz committed Nov 18, 2022
1 parent e86e16f commit 1890eb0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 41 deletions.
1 change: 1 addition & 0 deletions pddl/logic/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class Not(UnaryOp):

SYMBOL = "not"


@cache_hash
@functools.total_ordering
class QuantifiedCondition(Formula):
Expand Down
97 changes: 56 additions & 41 deletions pddl/parser/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,55 +126,70 @@ def emptyor_pregd(self, args):
assert_(len(args) == 1)
return args[0]

def gd_not(self, args):
"""Process the 'gd' not rule."""
if not bool(
{Requirements.NEG_PRECONDITION, Requirements.ADL}
& self._extended_requirements
):
# raise PDDLMissingRequirementError(Requirements.NEG_PRECONDITION)
# TODO temporary change; remove
pass
return Not(args[2])

def gd_and(self, args):
"""Process the 'gd_and' rule."""
operands = args[2:-1]
return And(*operands)

def gd_or(self, args):
"""Process the 'gd' or rule."""
if not bool(
{Requirements.DIS_PRECONDITION, Requirements.ADL}
& self._extended_requirements
):
raise PDDLMissingRequirementError(Requirements.DIS_PRECONDITION)
operands = args[2:-1]
return Or(*operands)

def gd_imply(self, args):
"""Process the 'gd' imply rule."""
if not bool(
{Requirements.DIS_PRECONDITION, Requirements.ADL}
& self._extended_requirements
):
raise PDDLMissingRequirementError(Requirements.DIS_PRECONDITION)
return Imply(args[2], args[3])

def gd_quantifiers(self, args):
"""Process the 'gd' quantifiers rule."""
req, cond_class = {
Symbols.FORALL.value: (Requirements.UNIVERSAL_PRECONDITION, ForallCondition),
Symbols.EXISTS.value: (Requirements.EXISTENTIAL_PRECONDITION, ExistsCondition),
}[args[1]]
if not bool(
{req, Requirements.QUANTIFIED_PRECONDITION, Requirements.ADL}
& self._extended_requirements
):
raise PDDLMissingRequirementError(req)
variables = [Variable(name, tags) for name, tags in args[3].items()]
condition = args[5]
return cond_class(cond=condition, variables=variables)

def gd(self, args):
"""Process the 'gd' rule."""
if len(args) == 1:
return args[0]
elif args[1] == Symbols.NOT.value:
if not bool(
{Requirements.NEG_PRECONDITION, Requirements.ADL}
& self._extended_requirements
):
# raise PDDLMissingRequirementError(Requirements.NEG_PRECONDITION)
# TODO temporary change; remove
pass
return Not(args[2])
return self.gd_not(args)
elif args[1] == Symbols.AND.value:
operands = args[2:-1]
return And(*operands)
return self.gd_and(args)
elif args[1] == Symbols.OR.value:
if not bool(
{Requirements.DIS_PRECONDITION, Requirements.ADL}
& self._extended_requirements
):
raise PDDLMissingRequirementError(Requirements.DIS_PRECONDITION)
operands = args[2:-1]
return Or(*operands)
return self.gd_or(args)
elif args[1] == Symbols.IMPLY.value:
if not bool(
{Requirements.DIS_PRECONDITION, Requirements.ADL}
& self._extended_requirements
):
raise PDDLMissingRequirementError(Requirements.DIS_PRECONDITION)
return Imply(args[2], args[3])
elif args[1] == Symbols.FORALL.value:
if not bool(
{Requirements.UNIVERSAL_PRECONDITION, Requirements.QUANTIFIED_PRECONDITION, Requirements.ADL}
& self._extended_requirements
):
raise PDDLMissingRequirementError(Requirements.UNIVERSAL_PRECONDITION)
variables = [Variable(name, tags) for name, tags in args[3].items()]
condition = args[5]
return ForallCondition(cond=condition, variables=variables)
elif args[1] == Symbols.EXISTS.value:
if not bool(
{Requirements.EXISTENTIAL_PRECONDITION, Requirements.QUANTIFIED_PRECONDITION, Requirements.ADL}
& self._extended_requirements
):
raise PDDLMissingRequirementError(Requirements.EXISTENTIAL_PRECONDITION)
variables = [Variable(name, tags) for name, tags in args[3].items()]
condition = args[5]
return ExistsCondition(cond=condition, variables=variables)
return self.gd_imply(args)
elif args[1] in [Symbols.FORALL.value, Symbols.EXISTS.value]:
return self.gd_quantifiers(args)

def emptyor_effect(self, args):
"""Process the 'emptyor_effect' rule."""
Expand Down

0 comments on commit 1890eb0

Please sign in to comment.