Skip to content

g3_fit: Always return a parameter table, regardless of model type#45

Merged
willbutler42 merged 2 commits intomainfrom
g3_fit-params-format
Aug 21, 2025
Merged

g3_fit: Always return a parameter table, regardless of model type#45
willbutler42 merged 2 commits intomainfrom
g3_fit-params-format

Conversation

@lentinj
Copy link
Collaborator

@lentinj lentinj commented Aug 21, 2025

Both gadgetplots & g3_fit_inner() assume the parameters are in table format, not list. But depending which path the model goes through g3_fit(), it may return a list.

Add tests to ensure we always send a data.frame downstream. Note that the R model is fine with a data.frame params now, and once I'm feeling brave enough will switch it's parameter template to be a table, removing the old list template entirely.

report_detail is also a historical artifact that needs tidying up, but one thing at a time. It defaults to 1 anyway, and we automatically turn reporting off when optimising. But it's also being a flag to show that g3a_report_detail() has been added to the model, which isn't easy to check otherwise.

Both gadgetplots & g3_fit_inner() assume the parameters are in table
format, not list. But depending which path the model goes through
g3_fit(), it may return a list.

Add tests to ensure we always send a data.frame downstream.
@MikkoVihtakari
Copy link
Collaborator

I'll let you merge this...The output of g3_fit() previously also had attributes which are used in the html documents to fetch data on model iteration process: https://github.com/gadget-framework/gadgetplots/blob/18f46a37c2b718228d301b9d8a35d8480d2d074c/inst/nea_ghl.Rmd#L3

These attributes seem to have disappeared in the version I used. Not sure whether they'll reappear after merging this pull request.

@lentinj
Copy link
Collaborator Author

lentinj commented Aug 21, 2025

These attributes seem to have disappeared in the version I used

It's a related problem. Looks like summary is added by g3_optim, but g3_fit may rebuild your model / parameter table, in which case they get lost.

They should be fixed by this (admittedly as an unintended side-effect) as the returned parameter table isn't recreated any more. I'll give it a try & see.

This also fixed this problem, but make sure it stays that way.
@lentinj
Copy link
Collaborator Author

lentinj commented Aug 21, 2025

@willbutler42 any objections to this? In retrospect banning g3_fit from accepting list params might be over-eager, but I'm pretty sure it doesn't work anyway.

@willbutler42
Copy link
Collaborator

No objections!

@willbutler42 willbutler42 merged commit 9c037ca into main Aug 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants