Ignore:
Timestamp:
May 4, 2018 5:57:13 PM (3 years ago)
Author:
toby
Message:

constraint fixes: implement wild-card equivalences, fix use of all for phase selection in atom vars; prevent use of Edit Constr menu items for sym-generated equivalences

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImapvars.py

    r3136 r3371  
    242242paramPrefix = "::constr"
    243243consNum = 0 # number of the next constraint to be created
     244
     245class ConstraintException(Exception):
     246    '''Defines an Exception that is used when an exception is raised processing constraints
     247    '''
     248    pass
    244249
    245250def InitVars():
     
    575580        if multarr is None: # true only if an equivalence
    576581            zeromult = False
    577             for mv in mapvars:
     582            for i,mv in enumerate(mapvars):
     583                if mv.split(':')[1] == '*' and SeqHist is not None:
     584                    # convert wildcard var to reference current histogram; save translation in table
     585                    sv = mv.split(':')
     586                    sv[1] = str(SeqHist)
     587                    mv = translateTable[mv] = ':'.join(sv)
     588                    mapvars[i] = mv
    578589                #s = ''
    579590                varied = 0
     
    589600                    #msg += "\nCannot equivalence to variable "+str(mv)+". Not defined in this refinement"
    590601                    #continue
    591             for v,m in zip(varlist,invmultarr):
     602            for i,(v,m) in enumerate(zip(varlist,invmultarr)):
     603                if v.split(':')[1] == '*' and SeqHist is not None:
     604                    # convert wildcard var to reference current histogram; save translation in table
     605                    sv = v.split(':')
     606                    sv[1] = str(SeqHist)
     607                    varlist[i] = v = translateTable[v] = ':'.join(sv)
    592608                if parmDict is not None and v not in parmDict:
    593609                    print ("Dropping equivalence for dep. variable "+str(v)+". Not defined in this refinement")
     
    661677            print (' *** ERROR in constraint definitions! ***')
    662678            print (msg)
    663             raise Exception
     679            raise ConstraintException
    664680        print ('*** Sequential refinement: ignoring constraint definition(s): ***')
    665681        print (shortmsg)
     
    670686        print (' *** ERROR in constraint definitions! ***')
    671687        print (msg)
    672         raise Exception
     688        raise ConstraintException
    673689               
    674690    # now process each group and create the relations that are needed to form
     
    762778        print (msg)
    763779        print (VarRemapShow(varyList))
    764         raise Exception
     780        raise ConstraintException
    765781    # setup dictionary containing the fixed values
    766782    global fixedDict
     
    821837    arrayList.append(None)
    822838    invarrayList.append(np.array(multlist))
    823     indParmList.append(tuple((independentVar,)))
     839    indParmList.append(list((independentVar,)))
    824840    dependentParmList.append(mapList)
    825841    symGenList.append(symGen)
     
    11621178            a[j] -= proj(a[i],a[j])
    11631179        if np.allclose(np.linalg.norm(a[j]),0.0):
    1164             raise Exception("Singular input to GramSchmidtOrtho")
     1180            raise ConstraintException("Singular input to GramSchmidtOrtho")
    11651181        a[j] /= np.linalg.norm(a[j])
    11661182    return a
     
    11971213            return
    11981214    else:
    1199         raise Exception('Singular input')
     1215        raise ConstraintException('Singular input')
    12001216
    12011217def _RowEchelon(m,arr,collist):
Note: See TracChangeset for help on using the changeset viewer.