Skip to content

control order in which fit parameters appear in gui (Trac #348) #483

@RichardHeenan

Description

@RichardHeenan

Suspect that the current “almost alphabetical” order for most but not all models is an “accident” due to python dictionaries.

\models\c_extension\python_wrapper\WrapperGenerator.py, ~line 328, routine write_c_wrapper produces a python type dictionary by:

for par in self.params: param_str += "
PyDict_SetItemString(self->params,"%s",Py_BuildValue("d",%10.12f));\n" % \ (par, self.params[par])

The main parameter dictionary may then have the polydispersity parameters added on to it. Alas python dictionaries are assembled in random order due to use of hash tables.

When a model is loaded “param_list” is acquired via

\sas\models\BaseModel.py, ~line 125.

def getParamList(self):
    param_list = self.params.keys()
    return param_list

[Note that many other places have similar routines for other parts of sasview.]

Would it be possible to use an ordered dictionary, in order to keep parameter in a particular order, such as the order in which the default values appear.

Paul Kinsell warns that there will be consequences for the way he passes parameters to fitting routines.

Migrated from http://trac.sasview.org/ticket/348

{
    "status": "closed",
    "changetime": "2016-03-20T11:46:32",
    "_ts": "2016-03-20 11:46:32.824365+00:00",
    "description": "\nSuspect that the current \u201calmost alphabetical\u201d order for most but not all models is an \u201caccident\u201d due to python dictionaries.\n\n\\models\\c_extension\\python_wrapper\\WrapperGenerator.py, ~line 328, routine write_c_wrapper produces a python type dictionary  by:\n\n for par in self.params: param_str += \"        \nPyDict_SetItemString(self->params,\\\"%s\\\",Py_BuildValue(\\\"d\\\",%10.12f));\\n\" % \\      (par, self.params[par])\n\nThe main parameter dictionary may then have the polydispersity parameters added on to it. Alas python dictionaries are assembled in random order due to use of hash tables.\n\nWhen a model is loaded \u201cparam_list\u201d is acquired via \n\n\\sas\\models\\BaseModel.py, ~line 125.\n\n    def getParamList(self):\n        param_list = self.params.keys()\n        return param_list\n\n[Note that many other places have similar routines for other parts of sasview.]\n\nWould it be possible to use an ordered dictionary, in order to keep parameter in a particular order, such as the order in which the default values appear.\n\nPaul Kinsell warns that there will be consequences for the way he passes parameters to fitting routines.\n",
    "reporter": "richardh",
    "cc": "",
    "resolution": "fixed",
    "workpackage": "SasView GUI Enhancements",
    "time": "2015-02-18T15:33:05",
    "component": "SasView",
    "summary": "control order in which fit parameters appear in gui",
    "priority": "blocker",
    "keywords": "",
    "milestone": "SasView 4.0.0",
    "owner": "richardh",
    "type": "enhancement"
}

Metadata

Metadata

Assignees

Labels

BlockerPrevents a different issue from being resolvedEnhancementFeature requests and/or general improvements

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions