Changeset 3061


Ignore:
Timestamp:
Sep 9, 2017 3:35:36 PM (4 years ago)
Author:
toby
Message:

sort variable names

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r3057 r3061  
    392392                l2 = max(l2,len(i2))
    393393            fmt = "{:"+str(l1)+"s} {:"+str(l2)+"s} {:s}"
    394             atchoice = [fmt.format(*i1) for i1 in choices]
     394            atchoice = G2obj.SortVariables([fmt.format(*i1) for i1 in choices])
    395395            dlg = G2G.G2MultiChoiceDialog(
    396396                G2frame,legend,
     
    605605        page = G2frame.Page
    606606        vartype,varList,constrDictEnt = PageSelection(page)
     607        varList = G2obj.SortVariables(varList)
    607608        if vartype is None: return
    608609        title1 = "Hold "+vartype+" variable"
     
    718719        else:
    719720            omitVars = []
    720         varList = [i for i in varList if i not in omitVars]
     721        varList = G2obj.SortVariables([i for i in varList if i not in omitVars])
    721722        varListlbl = [fmt.format(i,*G2obj.VarDescr(i)) for i in varList]
    722723        dlg = G2G.G2SingleChoiceDialog(G2frame,'Select 1st variable:',
     
    729730            FrstVarb = varList[sel]
    730731            VarObj = G2obj.G2VarObj(FrstVarb)
    731             moreVarb = FindEquivVarb(FrstVarb,[i for i in varList if i not in omitVars])
     732            moreVarb = G2obj.SortVariables(
     733                FindEquivVarb(FrstVarb,[i for i in varList if i not in omitVars]))
    732734            newcons = SelectVarbs(page,VarObj,moreVarb,title2+FrstVarb,constType)
    733735            if len(newcons) > 0:
  • trunk/GSASIIobj.py

    r3041 r3061  
    16191619        return dic.get(key,'?')
    16201620
     1621def SortVariables(varlist):
     1622    '''Sorts variable names in a sensible manner
     1623    '''
     1624    def cvnnums(var):
     1625        v = []
     1626        for i in var.split(':'):
     1627            try:
     1628                v.append(int(i))
     1629            except:
     1630                v.append(i)
     1631        return v
     1632    return sorted(varlist,key=cvnnums)
     1633
    16211634class G2VarObj(object):
    16221635    '''Defines a GSAS-II variable either using the phase/atom/histogram
Note: See TracChangeset for help on using the changeset viewer.