Skip to content

Commit

Permalink
copy dicts when doing validation
Browse files Browse the repository at this point in the history
  • Loading branch information
roussel-ryan committed Nov 4, 2024
1 parent e78b407 commit 5fb8603
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions xopt/generators/bayesian/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from copy import deepcopy
from typing import List

import numpy as np
Expand Down Expand Up @@ -206,16 +207,19 @@ def validate_turbo_controller_base(value, available_controller_types, info):
f"{available_controller_types.keys()}"
)
elif isinstance(value, dict):
value_copy = deepcopy(value)
# create turbo controller from dict input
if "name" not in value:
raise ValueError("turbo input dict needs to have a `name` attribute")
name = value.pop("name")
name = value_copy.pop("name")
if name in available_controller_types:
# pop unnecessary elements
for ele in ["dim"]:
value.pop(ele, None)
value_copy.pop(ele, None)

value = available_controller_types[name](vocs=info.data["vocs"], **value)
value = available_controller_types[name](
vocs=info.data["vocs"], **value_copy
)
else:
raise ValueError(
f"{value} not found, available values are "
Expand Down

0 comments on commit 5fb8603

Please sign in to comment.