Changeset a21d889 in sasmodels


Ignore:
Timestamp:
Apr 5, 2018 12:36:38 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
34f2857
Parents:
05df1de
Message:

allow math on magnetic parameters in sascomp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    rd86f0fc ra21d889  
    13291329 
    13301330    # Evaluate preset parameter expressions 
     1331    # Note: need to replace ':' with '_' in parameter names and expressions 
     1332    # in order to support math on magnetic parameters. 
    13311333    context = MATH.copy() 
    13321334    context['np'] = np 
    1333     context.update(pars) 
     1335    context.update((k.replace(':', '_'), v) for k, v in pars.items()) 
    13341336    context.update((k, v) for k, v in presets.items() if isinstance(v, float)) 
     1337    #for k,v in sorted(context.items()): print(k, v) 
    13351338    for k, v in presets.items(): 
    13361339        if not isinstance(v, float) and not k.endswith('_type'): 
    1337             presets[k] = eval(v, context) 
     1340            presets[k] = eval(v.replace(':', '_'), context) 
    13381341    context.update(presets) 
    1339     context.update((k, v) for k, v in presets2.items() if isinstance(v, float)) 
     1342    context.update((k.replace(':', '_'), v) for k, v in presets2.items() if isinstance(v, float)) 
    13401343    for k, v in presets2.items(): 
    13411344        if not isinstance(v, float) and not k.endswith('_type'): 
    1342             presets2[k] = eval(v, context) 
     1345            presets2[k] = eval(v.replace(':', '_'), context) 
    13431346 
    13441347    # update parameters with presets 
Note: See TracChangeset for help on using the changeset viewer.