Changeset 2876


Ignore:
Timestamp:
Jun 25, 2017 9:51:06 PM (4 years ago)
Author:
toby
Message:

allow variables to change during seq. ref.; fix error w/unused phases

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2875 r2876  
    39483948        sigwtFrList = []
    39493949        for i,name in enumerate(histNames):
     3950            if name not in Phases[phase]['Histograms']:
     3951                wtFrList.append(None)
     3952                sigwtFrList.append(0.0)
     3953                continue
    39503954            wtFrSum = 0.
    39513955            for phase1 in Phases:
     3956                if name not in Phases[phase1]['Histograms']: continue
    39523957                wtFrSum += Phases[phase1]['Histograms'][name]['Scale'][0]*Phases[phase1]['General']['Mass']
    39533958            var = str(Phases[phase]['pId'])+':'+str(i)+':Scale'
  • trunk/GSASIImapvars.py

    r2874 r2876  
    538538    global dependentParmList,arrayList,invarrayList,indParmList,consNum
    539539    msg = ''
     540    shortmsg = ''
    540541
    541542    # process fixed (held) variables
     
    625626            #if unused > 0:# and unused != len(VarKeys(constrDict[rel])):
    626627            if unused > 0 and unused != len(VarKeys(constrDict[rel])):
    627                 msg += "\nSome (but not all) variables in constraint are not defined:\n\t"
    628                 msg += _FormatConstraint(constrDict[rel],fixedList[rel])
    629                 msg += '\nNot used: ' + notused + '\n'
     628                #msg += "\nSome (but not all) variables in constraint are not defined:\n\t"
     629                #msg += _FormatConstraint(constrDict[rel],fixedList[rel])
     630                #msg += '\nNot used: ' + notused + '\n'
     631                shortmsg += notused+" not used in constraint "+_FormatConstraint(constrDict[rel],fixedList[rel])
    630632            elif varied > 0 and varied != len(VarKeys(constrDict[rel])):
    631                 msg += "\nNot all variables refined in constraint:\n\t"
    632                 msg += _FormatConstraint(constrDict[rel],fixedList[rel])
    633                 msg += '\nNot refined: ' + notvaried + '\n'
     633                #msg += "\nNot all variables refined in constraint:\n\t"
     634                #msg += _FormatConstraint(constrDict[rel],fixedList[rel])
     635                #msg += '\nNot refined: ' + notvaried + '\n'
     636                shortmsg += notvaried+" not varied in constraint "+_FormatConstraint(constrDict[rel],fixedList[rel])
    634637    # if there were errors found, go no farther
    635     if msg and SeqHist is not None:
    636         print ' *** Sequential refinement: ignoring constraint definition(s): ***'
    637         print msg
     638    if shortmsg and SeqHist is not None:
     639        if msg:
     640            print ' *** ERROR in constraint definitions! ***'
     641            print msg
     642            raise Exception
     643        print '*** Sequential refinement: ignoring constraint definition(s): ***'
     644        print shortmsg
    638645        msg = ''
    639     elif msg:
     646    elif shortmsg:
     647        msg += shortmsg
     648    if msg:
    640649        print ' *** ERROR in constraint definitions! ***'
    641650        print msg
  • trunk/GSASIIstrMain.py

    r2874 r2876  
    304304    NewparmDict = {}
    305305    for ihst,histogram in enumerate(histNames):
    306         print('Refining with '+str(histogram))
     306        print('\nRefining with '+str(histogram))
    307307        ifPrint = False
    308308        if dlg:
     
    343343        parmDict.update(histDict)
    344344        if Controls['Copy2Next']:
    345             parmDict.update(NewparmDict)
     345            #parmDict.update(NewparmDict) # don't use in case extra entries would cause a problem
     346            for parm in NewparmDict:
     347                if parm in parmDict:
     348                    parmDict[parm] = NewparmDict[parm]
    346349        G2stIO.GetFprime(calcControls,Histo)
    347350        # do constraint processing
     
    381384        if newVaryList != firstVaryList and Controls['Copy2Next']:
    382385            # variable lists are expected to match between sequential refinements when Copy2Next is on
    383             print '**** ERROR - variable list for this histogram does not match previous'
    384             print '     Copy of variables is not possible'
    385             print '\ncurrent histogram',histogram,'has',len(newVaryList),'variables'
     386            #print '**** ERROR - variable list for this histogram does not match previous'
     387            #print '     Copy of variables is not possible'
     388            #print '\ncurrent histogram',histogram,'has',len(newVaryList),'variables'
    386389            combined = list(set(firstVaryList+newVaryList))
    387390            c = [var for var in combined if var not in newVaryList]
    388391            p = [var for var in combined if var not in firstVaryList]
    389             line = 'Variables in previous but not in current: '
    390             if c:
    391                 for var in c:
    392                     if len(line) > 100:
    393                         print line
    394                         line = '    '
    395                     line += var + ', '
    396             else:
    397                 line += 'none'
    398             print line
    399             print '\nPrevious refinement has',len(firstVaryList),'variables'
    400             line = 'Variables in current but not in previous: '
    401             if p:
    402                 for var in p:
    403                     if len(line) > 100:
    404                         print line
    405                         line = '    '
    406                     line += var + ', '
    407             else:
    408                 line += 'none'
    409             print line
    410             return False,line
     392            print('*** Variables change ***')
     393            for typ,vars in [('Removed',c),('Added',p)]:
     394                line = '  '+typ+': '
     395                if vars:
     396                    for var in vars:
     397                        if len(line) > 70:
     398                            print(line)
     399                            line = '    '
     400                        line += var + ', '
     401                else:
     402                        line += 'none, '
     403                print(line[:-2])
     404            firstVaryList = newVaryList
    411405       
    412406        ifPrint = False
Note: See TracChangeset for help on using the changeset viewer.