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

Simplify defaults() #2

Open
amyheather opened this issue Jan 22, 2025 · 1 comment
Open

Simplify defaults() #2

amyheather opened this issue Jan 22, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@amyheather
Copy link
Member

amyheather commented Jan 22, 2025

Defaults is an R6 class. This is because it facilitates incorporating a check that any changes to the list are only to existing names in the list keys, and not new names. This avoids an error where it is assumed the parameter was updated, but it actually wasn't, as the key was incorrect.

This works well and has no functional issues - but it does feel quite complicated - in particular, how it is used (with helper functions get_param() and defaults() in an attempt to simplify that - or potentially adding more complication?). However, it becomes redundant once that parameter list gets extracted from the object - to avoid that issue currently, I would need to input the environment to the model function (whereas I currently extract the list and input that to the function).

An alternative solution would for defaults to just be a function returning a list, and that the check on the keys is performed as part of the validation rules within model(). The downside of this approach is that it is not being checked at the point at which defaults is being modified. The positive is that it would be much simpler.

@amyheather amyheather added the enhancement New feature or request label Jan 22, 2025
@amyheather
Copy link
Member Author

Move extraction of list to within model() in commit d79697b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant