Refactor parameter setup to return structured configs#2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| %% Set up the parameter | ||
| rng(k) | ||
| set_parameter; | ||
| disp('Parameter is set') | ||
|
|
||
| chart_fileName = [datapath,'chart',num2str(k),'.mat']; | ||
| chart_part_fileName = [datapath,'chart_part',num2str(k),'.mat']; | ||
| TranM_fileName = [datapath,'TranM',num2str(k),'.mat']; | ||
| diary_fileName = [datapath,'diary',num2str(k),'.txt']; | ||
| rng(k) | ||
| params = set_parameter; | ||
| disp('Parameter is set') | ||
|
|
There was a problem hiding this comment.
Invoke set_parameter instead of capturing function handle
The Halfmoon driver assigns params = set_parameter; even though set_parameter now returns the configuration struct. In MATLAB omitting the parentheses yields a function handle, so the next line params.paths.chart = … will throw because function handles do not have fields. Call set_parameter() (the same applies to the later call in the x==2 branch) so that params holds the struct.
Useful? React with 👍 / 👎.
| %% Set up the parameter | ||
|
|
||
| rng(k) | ||
| set_parameter; | ||
| disp('Parameter is set') | ||
| rng(k) | ||
| params = set_parameter; | ||
| disp('Parameter is set') |
There was a problem hiding this comment.
Call set_parameter() when initialising Peanut params
set_parameter was converted into a function that returns the parameter struct, but the Peanut driver still does params = set_parameter; in both execution branches. This leaves params as a function handle, so any subsequent property access (e.g. params.paths.chart) will fail at runtime. The call should use set_parameter() to obtain the struct before updating fields.
Useful? React with 👍 / 👎.
Summary
set_parameterscript into a function that returns a structuredparamsconfigurationparamsstruct instead of relying on implicit workspace variablesparamsobject layout in the README for easier discoveryTesting
https://chatgpt.com/codex/tasks/task_e_690be8f3f0ac83309955c18966ecda5b