Changeset 6d6508e in sasmodels for sasmodels/convert.py


Ignore:
Timestamp:
Apr 7, 2016 6:57:33 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
d2fc9a4
Parents:
3707eee
Message:

refactor model_info from dictionary to class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/convert.py

    r8bd7b77 r6d6508e  
    153153def revert_name(model_info): 
    154154    _read_conversion_table() 
    155     oldname, oldpars = CONVERSION_TABLE.get(model_info['id'], [None, {}]) 
     155    oldname, oldpars = CONVERSION_TABLE.get(model_info.id, [None, {}]) 
    156156    return oldname 
    157157 
    158158def _get_old_pars(model_info): 
    159159    _read_conversion_table() 
    160     oldname, oldpars = CONVERSION_TABLE.get(model_info['id'], [None, {}]) 
     160    oldname, oldpars = CONVERSION_TABLE.get(model_info.id, [None, {}]) 
    161161    return oldpars 
    162162 
     
    165165    Convert model from new style parameter names to old style. 
    166166    """ 
    167     if model_info['composition'] is not None: 
    168         composition_type, parts = model_info['composition'] 
     167    if model_info.composition is not None: 
     168        composition_type, parts = model_info.composition 
    169169        if composition_type == 'product': 
    170170            P, S = parts 
     
    180180 
    181181    # Note: update compare.constrain_pars to match 
    182     name = model_info['id'] 
    183     if name in MODELS_WITHOUT_SCALE or model_info['structure_factor']: 
     182    name = model_info.id 
     183    if name in MODELS_WITHOUT_SCALE or model_info.structure_factor: 
    184184        if oldpars.pop('scale', 1.0) != 1.0: 
    185185            warnings.warn("parameter scale not used in sasview %s"%name) 
    186     if name in MODELS_WITHOUT_BACKGROUND or model_info['structure_factor']: 
     186    if name in MODELS_WITHOUT_BACKGROUND or model_info.structure_factor: 
    187187        if oldpars.pop('background', 0.0) != 0.0: 
    188188            warnings.warn("parameter background not used in sasview %s"%name) 
     
    225225    Restrict parameter values to those that will match sasview. 
    226226    """ 
    227     name = model_info['id'] 
     227    name = model_info.id 
    228228    # Note: update convert.revert_model to match 
    229     if name in MODELS_WITHOUT_SCALE or model_info['structure_factor']: 
     229    if name in MODELS_WITHOUT_SCALE or model_info.structure_factor: 
    230230        pars['scale'] = 1 
    231     if name in MODELS_WITHOUT_BACKGROUND or model_info['structure_factor']: 
     231    if name in MODELS_WITHOUT_BACKGROUND or model_info.structure_factor: 
    232232        pars['background'] = 0 
    233233    # sasview multiplies background by structure factor 
Note: See TracChangeset for help on using the changeset viewer.