Skip to content

Commit

Permalink
Merge pull request #241 from upb-lea/hotfix-env-init
Browse files Browse the repository at this point in the history
Dont raise exception on dict input
  • Loading branch information
XyDrKRulof authored May 23, 2024
2 parents 4ee85c4 + 7d75912 commit 68a0e10
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/gym_electric_motor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
import numpy as np


# This hacky function stays for now because, all envs use it and refectoring would be a pain TODO: fix this
def initialize(base_class, arg, default_class, default_args):
if arg is None:
return default_class(**default_args)
if isinstance(arg, type):
raise Exception("Need init")
raise Exception("Need initialization value")
elif isinstance(arg, base_class):
return arg
elif isinstance(arg, str):
raise Exception
elif isinstance(arg, dict):
raise Exception
elif type(arg) is str:
raise Exception("Deprecated in version 2.0")
elif type(arg) is dict:
default_args.update(arg)
return default_class(**default_args)

Expand Down

0 comments on commit 68a0e10

Please sign in to comment.