Skip to content
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

[RTR] Solving a critical issue of codeclimate #788

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions bioptim/interfaces/solver_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,23 +858,26 @@ def set_maximum_iterations(self, num: int):

def as_dict(self, solver):
options = {}
for key in self.__annotations__.keys():
if (
key == "_acados_dir"
or key == "_cost_type"
or key == "_constr_type"
or key == "_has_tolerance_changed"
or key == "_only_first_options_has_changed"
or key == "type"
or key == "_c_compile"
or key == "_c_generated_code_path"
or key == "_acados_model_name"
):
continue
if key[0] == "_":
options[key[1:]] = self.__getattribute__(key)
else:
options[key] = self.__getattribute__(key)
keys_to_skip = {
"_acados_dir",
"_cost_type",
"_constr_type",
"_has_tolerance_changed",
"_only_first_options_has_changed",
"type",
"_c_compile",
"_c_generated_code_path",
"_acados_model_name",
}

# Select the set of relevant keys before entering the loop
relevant_keys = set(self.__annotations__.keys()) - keys_to_skip

# Iterate only over relevant keys
for key in relevant_keys:
option_key = key[1:] if key[0] == "_" else key
options[option_key] = getattr(self, key)

return options

@property
Expand Down
Loading