Changeset 86e8e66 in sasmodels


Ignore:
Timestamp:
Dec 20, 2016 12:08:41 PM (7 years ago)
Author:
krzywon
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
0795293
Parents:
54fb5d8
Message:

Changed conversion table keys to tuples to enforce proper ordering when version ≥ 10. Changed load old models to only check for 3.1.2 models.

Location:
sasmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/conversion_table.py

    r298621b r86e8e66  
    2828 
    2929CONVERSION_TABLE = { 
    30     "4.0.1" : {}, 
    31     "3.1.2" : { 
     30    (4,0,1) : {}, 
     31    (3,1,2) : { 
    3232    "adsorbed_layer": [ 
    3333        "Core2ndMomentModel", 
  • sasmodels/convert.py

    r54fb5d8 r86e8e66  
    9292 
    9393 
    94 def _get_translation_table(model_info, version='3.1.2'): 
     94def _get_translation_table(model_info, version=(3,1,2)): 
    9595    _, translation = CONVERSION_TABLE.get(version).get(model_info.id, [None, {}]) 
    9696    translation = translation.copy() 
     
    145145    return newpars 
    146146 
    147 def _conversion_target(model_name, version='3.1.2'): 
     147def _conversion_target(model_name, version=(3,1,2)): 
    148148    """ 
    149149    Find the sasmodel name which translates into the sasview name. 
     
    159159    return None 
    160160 
    161 def _hand_convert(name, oldpars, version='3.1.2'): 
    162     if version == '3.1.2': 
     161def _hand_convert(name, oldpars, version=(3,1,2)): 
     162    if version == (3,1,2): 
    163163        oldpars = _hand_convert_3_1_2_to_4_1(name, oldpars) 
    164164    return oldpars 
     
    316316        newpars = _hand_convert(newname, newpars, version) 
    317317        newpars = _convert_pars(newpars, translation) 
    318         if not model_info.structure_factor: 
     318        # TODO: Still not convinced this is the best check 
     319        if not model_info.structure_factor and version == (3,1,2): 
    319320            newpars = _rescale_sld(model_info, newpars, 1e6) 
    320321        newpars.setdefault('scale', 1.0) 
  • sasmodels/sasview_model.py

    r01ecc31 r86e8e66  
    5757    import sas.models 
    5858    from sasmodels.conversion_table import CONVERSION_TABLE 
    59     for version, _ in sorted(CONVERSION_TABLE.iteritems()): 
    60         for new_name, conversion in CONVERSION_TABLE.get(version).items(): 
    61             # CoreShellEllipsoidModel => core_shell_ellipsoid:1 
    62             new_name = new_name.split(':')[0] 
    63             old_name = conversion[0] 
    64             module_attrs = {old_name: find_model(new_name)} 
    65             ConstructedModule = type(old_name, (), module_attrs) 
    66             old_path = 'sas.models.' + old_name 
    67             setattr(sas.models, old_path, ConstructedModule) 
    68             sys.modules[old_path] = ConstructedModule 
     59    for new_name, conversion in CONVERSION_TABLE.get((3,1,2)).items(): 
     60        # CoreShellEllipsoidModel => core_shell_ellipsoid:1 
     61        new_name = new_name.split(':')[0] 
     62        old_name = conversion[0] 
     63        module_attrs = {old_name: find_model(new_name)} 
     64        ConstructedModule = type(old_name, (), module_attrs) 
     65        old_path = 'sas.models.' + old_name 
     66        setattr(sas.models, old_path, ConstructedModule) 
     67        sys.modules[old_path] = ConstructedModule 
    6968 
    7069 
Note: See TracChangeset for help on using the changeset viewer.