DesignSpace.get_current_value does not use the order of the passed variable names
Summary
When as_dict=False
, DesignSpace.get_current_value
does not preserve the order of the given variable names and returns something wrong.
Gemseo version
develop
Platform info
windows
Environment info
venv / py39
Steps to reproduce
from gemseo.algos.design_space import DesignSpace
design_space = DesignSpace()
design_space.add_variable("x", value=0.0)
design_space.add_variable("y", value=1.0)
print(design_space.get_current_value(as_dict=False))
# [0., 1.]
print(design_space.get_current_value(as_dict=False, variable_names=["x", "y"]))
# [0., 1.]
print(design_space.get_current_value(as_dict=False, variable_names=["y", "x"]))
# [0., 1.] instead of [1., 0.]
What is the current bug behavior?
design_space.get_current_value
does not preserve the order of the variable names passed with variable_names
.
What is the expected correct behavior?
design_space.get_current_value
must preserve the order of the variable names passed with variable_names
.
Possible fixes
Replace if variable_names is None or set(variable_names) == set(self.variables_names):
by if variable_names is None or list(variable_names) == self.variables_names: