Skip to content

we lack a real 'addParamGroup' implementation. #149

Description

@arwelHughes

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

Activity

  1. alexhroom commented on Apr 28, 2025

    @alexhroom
    Collaborator

    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 type Parameter before each one) but would avoid us having to write & maintain a whole set of wrapper methods

  2. arwelHughes commented on Apr 28, 2025

    @arwelHughes
    Author
  3. added
    iceboxissue will not be addressed for the foreseeable future (unless requested by users)
    on Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    iceboxissue will not be addressed for the foreseeable future (unless requested by users)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions