Skip to content

Commit

Permalink
🔀 Merge branch 'adds_default' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rickstaa committed Mar 26, 2021
2 parents d3fa49d + 195b332 commit 51cad2a
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions simzoo/common/disturber.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def periodic_disturbance(time):
# See https://rickstaa.github.io/bayesian-learning-control/control/robustness_eval.html
# for more information.
DISTURBER_CFG = {
# Disturbance type when no type has been given
"default_type": "step_disturbance",
# Disturbance applied to environment variables
"env_disturbance": {
"description": "Lacl mRNA decay rate disturbance",
Expand Down Expand Up @@ -580,6 +582,27 @@ def init_disturber(
self._disturber_cfg = DISTURBER_CFG

# Validate disturbance type and/or variant input arguments
if disturbance_type is None:
if "default_type" in self._disturber_cfg.keys():
print(
colorize(
(
"INFO: No disturbance type given default type '{}' ".format(
self._disturber_cfg["default_type"]
)
+ "used instead."
),
"green",
bold=True,
)
)
disturbance_type = self._disturber_cfg["default_type"]
else:
raise TypeError(
"init_disturber(): is missing one required positional "
"argument: 'disturbance_type'.",
"disturbance_type",
)
disturbance_type = (
disturbance_type.lower() + "_disturbance"
if "_disturbance" not in disturbance_type.lower()
Expand All @@ -601,8 +624,8 @@ def init_disturber(
print(
colorize(
(
"INFO: No disturbance variant given default variant ("
+ "{}) used instead.".format(
"INFO: No disturbance variant given default variant '"
+ "{}' used instead.".format(
self._disturber_cfg[disturbance_type][
"default_variant"
]
Expand All @@ -621,7 +644,8 @@ def init_disturber(
"argument: 'disturbance_variant'. This argument is required "
f"for disturbance type {disturbance_type}. Please specify a "
f"valid disturbance variant "
f"{list(self._disturber_cfg[disturbance_type].keys())}."
f"{list(self._disturber_cfg[disturbance_type].keys())}.",
"disturbance_variant",
)
else:
disturbance_variant = disturbance_variant.lower()
Expand Down

0 comments on commit 51cad2a

Please sign in to comment.