Repository navigation
we lack a real 'addParamGroup' implementation. #149
Copy link
Copy link
Open
Labels
iceboxissue will not be addressed for the foreseeable future (unless requested by users)issue will not be addressed for the foreseeable future (unless requested by users)
Description
Activity
https://stackoverflow.com/questions/73156982/allow-positional-arguments-for-basemodel-pydantic something like the solutions discussed in this Stack Overflow page would allow users to do e.g.
from RAT.models import Parameter my_params = [ Parameter('param 1', 0, 1, 2), Parameter('param 2', 0, 2, 4, True, 'gaussian', 0, 1), # etc... ] problem.parameters.extend(my_params)
which isn't quite the same as an
addParamGroup(you still have to typeParameterbefore each one) but would avoid us having to write & maintain a whole set of wrapper methods- Thanks for your productive suggestion Alex..…________________________________ From: Alex H. Room ***@***.***> Sent: Monday, April 28, 2025 11:17 AM To: RascalSoftware/python-RAT ***@***.***> Cc: Hughes, Arwel (STFC,RAL,ISIS) ***@***.***>; Author ***@***.***> Subject: Re: [RascalSoftware/python-RAT] we lack a real 'addParamGroup' implementation. (Issue #149) [https://avatars.githubusercontent.com/u/69592136?s=20&v=4]alexhroom left a comment (RascalSoftware/python-RAT#149)<#149 (comment)> https://stackoverflow.com/questions/73156982/allow-positional-arguments-for-basemodel-pydantic something like the solutions discussed would allow users to do e.g. from RAT.models import Parameter my_params = [ Parameter('param 1', 0, 1, 2), Parameter('param 2', 0, 2, 4), # etc... ] problem.parameters.extend(my_params) which isn't quite the same as an addParamGroup (you still have to type Parameter before each one) but would avoid us having to write & maintain a whole set of wrapper methods — Reply to this email directly, view it on GitHub<#149 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGMNVXWWWLNKKMBM7URBBKL23X55BAVCNFSM6AAAAAB3WVUD4CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMZUG42DAMJYGA>. You are receiving this because you authored the thread.Message ID: ***@***.***>
- addediceboxissue will not be addressed for the foreseeable future (unless requested by users)issue will not be addressed for the foreseeable future (unless requested by users)
on Apr 29, 2026
Metadata
Metadata
Assignees
Labels
iceboxissue will not be addressed for the foreseeable future (unless requested by users)issue will not be addressed for the foreseeable future (unless requested by users)
The 'append' method of adding a group of parameters, as described in the manual, is very clunky and not what we need.
For example, in the tutorial we have an example which adds three parameters like this:
pGroup = [RAT.models.Parameter(name='Layer thick', min=10, value=20, max=30, fit=True),
RAT.models.Parameter(name='Layer SLD', min=1e-6, value=3e-6, max=5e-6, fit=True),
RAT.models.Parameter(name='Layer rough', min=5, value=7, max=10, fit=True)]
problem.parameters.extend(pGroup)
This is a lot of typing!
In fact, all the relevant information from that can be summarised in a simple list:
In [4]: myParams = [['Layer thick',10,20,30,True], ['Layer SLD', 1e-6, 3e-6, 5e-6, True], ['Layer rough',5,7,10,True]]
In [5]: print(myParams)
[['Layer thick', 10, 20, 30, True], ['Layer SLD', 1e-06, 3e-06, 5e-06, True], ['Layer rough', 5, 7, 10, True]]
The addParamGroup option should accept a simple list like this, and then do the Rat.models.Parameter... stuff under the hood for the user. This method would then be in alignment with the Matlab one, where a simple cell array is used to define the parameter block.
A