Ax icon indicating copy to clipboard operation
Ax copied to clipboard

Error: A list of 'ChoiceParameter' is not iterable

Open Runyu-Zhang opened this issue 4 months ago • 4 comments

While creating a list of choice parameters using dictionary: parameters_list = [dict(name = parameter, type = "choice", values = [x,...] ) for parameter in all_parameters ] it has warning UserWarning: sort_values is not specified for ChoiceParameter "xxx". Defaulting to True for parameters of ParameterType FLOAT. To override this behavior (or avoid this warning), specify sort_values during ChoiceParameter construction.

So if I want to avoid those warnings by creating my parameters using ChoiceParameter:

from ax import ChoiceParameter, ParameterType

[ChoiceParameter(name = parameter, parameter_type = ParameterType.FLOAT, values =[x,...], is_ordered = True, sort_values = False) for parameter in all_parameters] it becomes an error experiment = self.make_experiment( File "/ax/lib/python3.9/site-packages/ax/service/utils/instantiation.py", line 908, in make_experiment search_space=cls.make_search_space(parameters, parameter_constraints), File "/ax/lib/python3.9/site-packages/ax/service/utils/instantiation.py", line 687, in make_search_space typed_parameters = [cls.parameter_from_json(p) for p in parameters] File "/ax/lib/python3.9/site-packages/ax/service/utils/instantiation.py", line 687, in typed_parameters = [cls.parameter_from_json(p) for p in parameters] File "/ax/lib/python3.9/site-packages/ax/service/utils/instantiation.py", line 280, in parameter_from_json if "parameter_type" in representation: TypeError: argument of type 'ChoiceParameter' is not iterable

Although it's not critical, still better to have a way to pass "sort_values" through dict(), or having ChoiceParameter() iterable.

Runyu-Zhang avatar Feb 27 '24 20:02 Runyu-Zhang