-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: A list of 'ChoiceParameter' is not iterable #2224
Comments
Yes, looking through the ChoiceParameter construction code it looks like there isn't yet a way to pass "sort_values" with a dict, thanks for bringing this to our attention. If I am understanding correctly, you are passing a "ChoiceParameter" object into "parameter_from_json", and line 280 is erroring because ChoiceParameter is not an iterable object. This is expected, as parameter_from_json is meant to convert JSON objects to Parameter objects. |
Thanks for the tips mgrange1998. But I guess my issue was that when I construct a list of "ChoiceParameter" using for loop, like: Instead, if I append dictionaries to "list_parameters=[]", and then pass to ax_client.create_experiment(), it is fine, but then the warning comes: 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. |
Hello again- that makes sense to me. I have a pull request up which will fix your issue by allowing you to specify "sort_values" in the input dictionary #2231 |
Nice. Thank you! |
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 forChoiceParameter
"xxx". Defaulting toTrue
for parameters ofParameterType
FLOAT. To override this behavior (or avoid this warning), specifysort_values
duringChoiceParameter
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.
The text was updated successfully, but these errors were encountered: