Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
beckydvn committed Aug 3, 2023
1 parent 367ce16 commit bd3c76a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
14 changes: 7 additions & 7 deletions plan4dial/for_generating/parsers/json_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def configure_assignments(known: Union[bool, str]) -> str:
str: The Hovor assignment equivalent to the "known" parameter provided.
"""
return (
("found" if known else "didnt-find") if type(known) == bool else "maybe-found"
("found" if known else "didnt-find") if type(known) is bool else "maybe-found"
)


Expand All @@ -98,7 +98,7 @@ def _configure_certainty(known: Union[bool, str]) -> str:
Returns:
str: The Hovor certainty equivalent to the "known" parameter provided.
"""
return ("Known" if known else "Unknown") if type(known) == bool else "Uncertain"
return ("Known" if known else "Unknown") if type(known) is bool else "Uncertain"


@config(auto_simplify=True)
Expand All @@ -117,7 +117,7 @@ def _convert_to_formula(condition: Dict) -> Union[And, Or]:
formula_terms = []
# if we get passed a list, update formula_terms by the conversion of each element
# in the list
if type(condition) == list:
if type(condition) is list:
formula_terms.extend(
[
formula
Expand Down Expand Up @@ -188,7 +188,7 @@ def _configure_value_setter(loaded_yaml: Dict, ctx_var: str) -> None:
# possible values the context variable can be set to
var_options = (
list(ctx_var_cfg["options"].keys())
if type(ctx_var_cfg["options"]) == dict
if type(ctx_var_cfg["options"]) is dict
else ctx_var_cfg["options"]
)
# create flag context variables that represent the given ctx_var being set to all
Expand Down Expand Up @@ -541,7 +541,7 @@ def _add_value_setters(loaded_yaml: Dict) -> None:
for cond, cond_cfg in act_cfg["condition"].items():
if "value" in cond_cfg:
option = cond_cfg["value"]
if type(option) == str:
if type(option) is str:
if option not in loaded_yaml["context_variables"][cond]["options"]:
raise AssertionError(
f'Cannot specify the value "{option}" for the context \
Expand Down Expand Up @@ -639,7 +639,7 @@ def _convert_actions(loaded_yaml: Dict) -> None:
if cond_config_key == "known":
json_config_cond.append(
([cond, "Known"] if cond_config_val else [cond, "Unknown"])
if type(cond_config_val) == bool
if type(cond_config_val) is bool
else [cond, "Uncertain"]
)
elif cond_config_key == "value":
Expand Down Expand Up @@ -697,7 +697,7 @@ def _convert_actions(loaded_yaml: Dict) -> None:
processed[act]["intents"] = {}
for intent in intents:
# don't consider null intents
if type(intent) == str:
if type(intent) is str:
if intent in loaded_yaml["intents"]:
processed[act]["intents"][intent] = loaded_yaml["intents"][
intent
Expand Down
2 changes: 1 addition & 1 deletion plan4dial/for_generating/parsers/parse_for_rasa.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def make_nlu_file(loaded_yaml: Dict) -> Dict:
]
# if the options have variations, make intent examples of the
# variations, using the original option as the true val
if type(ctx_var["options"]) == dict:
if type(ctx_var["options"]) is dict:
for option, option_var in ctx_var["options"].items():
variations[variable].extend(
_create_intent_example(v, variable, true_value=option)
Expand Down
22 changes: 13 additions & 9 deletions plan4dial/for_generating/parsers/pddl_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _return_flag_value_fluent(
str: The fluent version of a flag or fflag context variable depending on the
setting supplied.
"""
if type(value) == bool:
if type(value) is bool:
return f"({v_name})" if value else f"(not ({v_name}))"
elif is_fflag:
return f"(maybe__{v_name})"
Expand Down Expand Up @@ -74,7 +74,7 @@ def _return_certainty_fluents(v_name: str, is_fflag: bool, certainty: str) -> Li
elif certainty == "Uncertain":
known = "maybe"

if type(known) == bool:
if type(known) is bool:
# only include "maybe"s if the known type is fflag
return (
(
Expand Down Expand Up @@ -169,7 +169,7 @@ def get_precond_fluents(
cond_key_fflag = _get_is_fflag(context_variables, cond_key)
# update precond depending on the type of condition value
if cond_val is not None:
if type(cond_val) == bool:
if type(cond_val) is bool:
precond.add(
_return_flag_value_fluent(cond_key, cond_key_fflag, cond_val)
)
Expand Down Expand Up @@ -237,8 +237,10 @@ def _action_to_pddl(context_variables: Dict, act: str, act_config: Dict) -> str:
outer_brackets=False,
)
# convert the effects
effects = f"\n{TAB * 2}:effect\n{TAB * 3}(labeled-oneof " + \
act_config['effect']['global-outcome-name']
effects = (
f"\n{TAB * 2}:effect\n{TAB * 3}(labeled-oneof "
+ act_config["effect"]["global-outcome-name"]
)
# iterate through all the outcomes
for out_config in act_config["effect"]["outcomes"]:
if "updates" in out_config:
Expand Down Expand Up @@ -294,7 +296,7 @@ def get_init_fluents(context_variables: Dict) -> Tuple[Set[str], Set[str]]:
# if this variable has a known setting
if "known" in var_config:
known_status = var_config["known"]["init"]
if type(known_status) == bool:
if type(known_status) is bool:
# if known is True, add this to the partial satate
if known_status:
init_true.add(f"(know__{var})")
Expand All @@ -309,7 +311,7 @@ def get_init_fluents(context_variables: Dict) -> Tuple[Set[str], Set[str]]:
# similarly add the context variables that are flag/fflag types
if var_config["type"] in ["flag", "fflag"]:
status = var_config["config"]
if type(status) == bool:
if type(status) is bool:
if status:
init_true.add(f"({var})")
else:
Expand Down Expand Up @@ -362,8 +364,10 @@ def parse_to_pddl(loaded_yaml: Dict) -> Tuple[str, str]:
name_wrap=":predicates",
)
actions = _actions_to_pddl(loaded_yaml)
domain = f"(define\n{TAB}(domain {loaded_yaml['name']})\n{TAB}(:requirements " + \
f":strips)\n{TAB}(:types )\n{TAB}(:constants ){predicates}\n{actions}\n)"
domain = (
f"(define\n{TAB}(domain {loaded_yaml['name']})\n{TAB}(:requirements "
+ f":strips)\n{TAB}(:types )\n{TAB}(:constants ){predicates}\n{actions}\n)"
)
problem_def = f"(define\n{TAB}(problem {loaded_yaml['name']}-problem)\n{TAB} \
(:domain {loaded_yaml['name']})\n{TAB}(:objects )"
init = _fluents_to_pddl(
Expand Down

0 comments on commit bd3c76a

Please sign in to comment.