Changeset 4759


Ignore:
Timestamp:
Jan 10, 2021 5:12:01 PM (8 months ago)
Author:
toby
Message:

wx4.1 & mpl3.3 fixes

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • install/g2full/g2postinstall.sh.template

    r4749 r4759  
    2727fi
    2828echo "GSAS-II installer, version **Version** completed"
    29 echo "*** Viewing GSAS-II app in Finder; you may wish to drag it to the dock.***"
     29#MACOnly# echo "*** Viewing GSAS-II app in Finder; you may wish to drag it to the dock.***"
  • install/setversion.py

    r4749 r4759  
    8080    out = out.replace('**wxversion**',wxversion)
    8181    out = out.replace('**mplversion**',mplversion)
     82    if sys.platform == "darwin": out.replace('#MACOnly#','')
    8283    print('Creating',fil)
    8384    fp = open(fil,'w')
  • trunk/GSASIIdataGUI.py

    r4724 r4759  
    85788578        but.Bind(wx.EVT_BUTTON,onEditSimRange)
    85798579        mainSizer.Add(simSizer)
    8580         mainSizer.Add(but,0,WACV)
     8580        mainSizer.Add(but,0)
    85818581    if 'Nobs' in data[0]:
    85828582        mainSizer.Add(wx.StaticText(G2frame.dataWindow,-1,
  • trunk/GSASIImath_new.py

    r4699 r4759  
    22#GSASIImath - major mathematics routines
    33########### SVN repository information ###################
    4 # $Date: 2020-12-12 13:30:31 -0600 (Sat, 12 Dec 2020) $
     4# $Date: 2021-01-04 10:41:46 -0600 (Mon, 04 Jan 2021) $
    55# $Author: vondreele $
    6 # $Revision: 4671 $
     6# $Revision: 4709 $
    77# $URL: https://subversion.xray.aps.anl.gov/pyGSAS/trunk/GSASIImath.py $
    8 # $Id: GSASIImath.py 4671 2020-12-12 19:30:31Z vondreele $
     8# $Id: GSASIImath.py 4709 2021-01-04 16:41:46Z vondreele $
    99########### SVN repository information ###################
    1010'''
     
    2424import copy
    2525import GSASIIpath
    26 GSASIIpath.SetVersionNumber("$Revision: 4671 $")
     26GSASIIpath.SetVersionNumber("$Revision: 4709 $")
    2727import GSASIIElem as G2el
    2828import GSASIIlattice as G2lat
     
    102102    s = np.where(s>cutoff,1./s,0.)
    103103    nzero = s.shape[0]-np.count_nonzero(s)
    104 #    res = np.dot(np.transpose(vt), np.multiply(s[:, np.newaxis], np.transpose(u)))
    105104    res = np.dot(vt.T,s[:,nxs]*u.T)
    106105    return res,nzero
     
    125124        out.append(np.delete(v,bad))
    126125    return out
    127 
    128        
    129126       
    130127def setHcorr(info,Amat,xtol,problem=False):
     
    233230            G2fil.G2Print('ouch #1 dropping singularities for variable(s) #{}'.format(
    234231                psing), mode='warn')
    235             Amat, indices, Xvec, Yvec, Adiag = dropTerms(psing,
    236                                         Amat, indices, Xvec, Yvec, Adiag)
     232            Amat, indices, Xvec, Yvec, Adiag = dropTerms(psing,Amat, indices, Xvec, Yvec, Adiag)
    237233        Anorm = np.outer(Adiag,Adiag)        # normalize matrix & vector
    238234        Yvec /= Adiag
     
    253249                    psing = [np.argmin(d)]
    254250                G2fil.G2Print('ouch #2 bad SVD inversion; dropping terms for for variable(s) #{}'.
    255                                   format(psing), mode='warn')
    256                 Amat, indices, Xvec, Yvec, Adiag = dropTerms(psing,
    257                                         Amat, indices, Xvec, Yvec, Adiag)
     251                    format(psing), mode='warn')
     252                Amat, indices, Xvec, Yvec, Adiag = dropTerms(psing,Amat, indices, Xvec, Yvec, Adiag)
    258253                if loops < maxdrop: continue # try again, same lam but fewer vars
    259254                G2fil.G2Print('giving up with ouch #2', mode='error')
     
    269264                    psing = [np.argmin(d)]
    270265                G2fil.G2Print('{} SVD Zeros: dropping terms for for variable(s) #{}'.
    271                                   format(Nzeros,psing), mode='warn')
    272                 Amat, indices, Xvec, Yvec, Adiag = dropTerms(psing,
    273                                         Amat, indices, Xvec, Yvec, Adiag)
     266                    format(Nzeros,psing), mode='warn')
     267                Amat, indices, Xvec, Yvec, Adiag = dropTerms(psing,Amat, indices, Xvec, Yvec, Adiag)
    274268                Amatlam = Amat*(1.+np.eye(Amat.shape[0])*lam)
    275269                Ainv,nz = pinv(Amatlam,xtol)    #do Moore-Penrose inversion (via SVD)
    276270                if nz > 0: G2fil.G2Print('Note: there are {} new SVD Zeros after drop'.format(nz),
    277                                              mode='warn')
     271                    mode='warn')
    278272            Xvec = np.inner(Ainv,Yvec)/Adiag      #solve for LS terms
    279273            XvecAll[indices] = Xvec         # expand
     
    285279                loops += 1
    286280                d = np.abs(np.diag(nl.qr(Amatlam)[1]))
    287                 G2fil.G2Print('ouch #3 unable to evaluate objective function;',
    288                                       mode='error')
     281                G2fil.G2Print('ouch #3 unable to evaluate objective function;',mode='error')
    289282                info = {'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'SVD0':Nzeros}
    290283                info['psing'] = [i for i in range(n) if i not in indices]
     
    310303                if Print:
    311304                    G2fil.G2Print(('divergence: chi^2 %.5g on %d obs. (%d SVD zeros)\n'+
    312                                     '\tincreasing Marquardt lambda to %.1e')%(chisq1,Nobs,Nzeros,lam))
     305                        '\tincreasing Marquardt lambda to %.1e')%(chisq1,Nobs,Nzeros,lam))
    313306                if lam > 10.:
    314307                    G2fil.G2Print('ouch #4 stuck: chisq-new %.4g > chisq0 %.4g with lambda %.1g'%
    315                                   (chisq1,chisq0,lam), mode='warn')
     308                        (chisq1,chisq0,lam), mode='warn')
    316309                    try:         # report highly correlated parameters from full Hessian, if we can
    317310                        info = {'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,
     
    369362        Bmat,Nzeros = setHcorr(info,Amat,xtol,problem=False)
    370363        info.update({'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'SVD0':Nzeros,'psing':psing_prev,
    371                          'Converged':ifConverged, 'DelChi2':deltaChi2, 'Xvec':XvecAll, 'chisq0':chisq00})
     364            'Converged':ifConverged, 'DelChi2':deltaChi2, 'Xvec':XvecAll, 'chisq0':chisq00})
    372365        return [x0,Bmat,info]
    373366    except nl.LinAlgError:
     
    403396        if Print:
    404397            G2fil.G2Print('Found %d SVD zeros w/o Lambda. '+
    405                               'Likely problem with variable(s) #%s'%
    406                               (Nzeros,psing), mode='warn')
     398                'Likely problem with variable(s) #%s'%(Nzeros,psing), mode='warn')
    407399        Amat, indices, Yvec = dropTerms(psing, Amat, indices, Yvec)
    408400    # expand Bmat by filling with zeros if columns have been dropped
     
    412404        Bmat = np.insert(np.insert(Bmat,ins,0,1),ins,0,0)
    413405    info.update({'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'SVD0':Nzeros,
    414                          'Converged':ifConverged, 'DelChi2':deltaChi2, 'Xvec':XvecAll, 'chisq0':chisq00})
     406        'Converged':ifConverged, 'DelChi2':deltaChi2, 'Xvec':XvecAll, 'chisq0':chisq00})
    415407    info['psing'] = [i for i in range(n) if i not in indices]
    416408    return [x0,Bmat,info]
     
    492484            Ainv,Nzeros = pinv(Amat,xtol)    #do Moore-Penrose inversion (via SVD)
    493485        except nl.LinAlgError:
    494             G2fil.G2Print('ouch #1 bad SVD inversion; change parameterization', mode='error')
     486            G2fil.G2Print('ouch #1 bad SVD inversion; change parameterization', mode='warn')
    495487            psing = list(np.where(np.abs(np.diag(nl.qr(Amat)[1])) < 1.e-14)[0])
    496488            return [x0,None,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':0.,'psing':psing,'SVD0':-1}]
     
    518510    Amat = Amat/Anorm       
    519511    try:
    520         Bmat,Nzeros = pinv(Amat,xtol)    #Moore-Penrose inversion (via SVD) & count of zeros
    521         G2fil.G2Print('Found %d SVD zeros'%(Nzeros), mode='warn')
     512        Bmat,Nzero = pinv(Amat,xtol)    #Moore-Penrose inversion (via SVD) & count of zeros
     513        G2fil.G2Print('Found %d SVD zeros'%(Nzero), mode='warn')
     514#        Bmat = nl.inv(Amatlam); Nzeros = 0
    522515        Bmat = Bmat/Anorm
    523516        return [x0,Bmat,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':0.,'psing':[],
    524             'SVD0':Nzeros,'Converged': ifConverged, 'DelChi2':deltaChi2,
     517            'SVD0':Nzero,'Converged': ifConverged, 'DelChi2':deltaChi2,
    525518                             'chisq0':chisq00}]
    526519    except nl.LinAlgError:
     
    528521        psing = []
    529522        if maxcyc:
    530             psing = list(np.where(np.abs(np.diag(nl.qr(Amat)[1])) < 1.e-14)[0])
     523            psing = list(np.where(np.diag(nl.qr(Amat)[1]) < 1.e-14)[0])
    531524        return [x0,None,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':0.,'psing':psing,'SVD0':-1,
    532525                             'chisq0':chisq00}]
  • trunk/GSASIIphsGUI.py

    r4719 r4759  
    89918991        topSizer = wx.BoxSizer(wx.HORIZONTAL)
    89928992        topSizer.Add(wx.StaticText(drawOptions,label=' Drawing controls:'),0,WACV)
    8993         # add help button to bring up help web page - at right sede of window
    8994         topSizer.Add((-1,-1),1,WACV|wx.EXPAND)
     8993        # add help button to bring up help web page - at right side of window
     8994        topSizer.Add((-1,-1),1,wx.EXPAND)
    89958995        topSizer.Add(G2G.HelpButton(drawOptions,helpIndex=G2frame.dataWindow.helpKey))
    8996         mainSizer.Add(topSizer,0,WACV|wx.EXPAND)
     8996        mainSizer.Add(topSizer,0,wx.EXPAND)
    89978997        mainSizer.Add(SlopSizer(),0)
    89988998        G2G.HorizontalLine(mainSizer,drawOptions)
     
    93099309            0,WACV)
    93109310        # add help button to bring up help web page - at right sede of window
    9311         titleSizer.Add((-1,-1),1,WACV|wx.EXPAND)
     9311        titleSizer.Add((-1,-1),1,wx.EXPAND)
    93129312        titleSizer.Add(G2G.HelpButton(Texture,helpIndex=G2frame.dataWindow.helpKey))
    93139313        mainSizer.Add(titleSizer,0,wx.EXPAND)
     
    1151911519            topSizer.Add(wx.StaticText(G2frame.MCSA,label='MC/SA models:'),0,WACV)
    1152011520            # add help button to bring up help web page - at right sede of window
    11521             topSizer.Add((-1,-1),1,WACV|wx.EXPAND)
     11521            topSizer.Add((-1,-1),1,wx.EXPAND)
    1152211522            topSizer.Add(G2G.HelpButton(G2frame.MCSA,helpIndex=G2frame.dataWindow.helpKey))
    11523             mainSizer.Add(topSizer,0,WACV|wx.EXPAND)
     11523            mainSizer.Add(topSizer,0,wx.EXPAND)
    1152411524            mainSizer.Add((5,5),0)
    1152511525            rbNames = []
  • trunk/GSASIIplot.py

    r4752 r4759  
    1081510815    #GSASIIpath.IPyBreak()
    1081610816    for txt in legend.get_texts():
    10817         if mplv[0] >= 3 and mplv[1] >= 3:
     10817        try: # as of MPL 3.3.2 this has not changed
     10818            txt.set_picker(4)
     10819        except AttributeError:
    1081810820            txt.set_pickradius(4)
    10819         else:
    10820             txt.set_picker(4)
    1082110821    if new:
    1082210822        legend.figure.canvas.mpl_connect('pick_event',onLegendPick)
  • trunk/GSASIIpwdGUI.py

    r4697 r4759  
    17031703    topSizer = wx.BoxSizer(wx.HORIZONTAL)
    17041704    topSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Background used in refinement'),0,WACV)
    1705     # add help button to bring up help web page - at right sede of window
    1706     topSizer.Add((-1,-1),1,WACV|wx.EXPAND)
     1705    # add help button to bring up help web page - at right side of window
     1706    topSizer.Add((-1,-1),1,wx.EXPAND)
    17071707    topSizer.Add(G2G.HelpButton(G2frame.dataWindow,helpIndex=G2frame.dataWindow.helpKey))
    1708     mainSizer.Add(topSizer,0,WACV|wx.EXPAND)
     1708    mainSizer.Add(topSizer,0,wx.EXPAND)
    17091709    mainSizer.Add(BackSizer())
    17101710    mainSizer.Add((0,5),0)
     
    17911791        topSizer = wx.BoxSizer(wx.HORIZONTAL)
    17921792        topSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Data used in refinement'),0,WACV)
    1793         # add help button to bring up help web page - at right sede of window
    1794         topSizer.Add((-1,-1),1,WACV|wx.EXPAND)
     1793        # add help button to bring up help web page - at right side of window
     1794        topSizer.Add((-1,-1),1,wx.EXPAND)
    17951795        topSizer.Add(G2G.HelpButton(G2frame.dataWindow,helpIndex=G2frame.dataWindow.helpKey))
    1796         mainSizer.Add(topSizer,0,WACV|wx.EXPAND)
     1796        mainSizer.Add(topSizer,0,wx.EXPAND)
    17971797        mainSizer.Add((5,5))
    17981798        mainSizer.Add(LimitSizer())
     
    22032203        text = ' Histogram Type: %s  Bank: %d'%(insVal['Type'],insVal['Bank'])
    22042204        subSizer.Add(wx.StaticText(G2frame.dataWindow,-1,text),0,WACV)
    2205         # add help button to bring up help web page - at right sede of window
    2206         subSizer.Add((-1,-1),1,WACV|wx.EXPAND)
     2205        # add help button to bring up help web page - at right side of window
     2206        subSizer.Add((-1,-1),1,wx.EXPAND)
    22072207        subSizer.Add(G2G.HelpButton(G2frame.dataWindow,helpIndex=G2frame.dataWindow.helpKey))
    2208         mainSizer.Add(subSizer,0,WACV|wx.EXPAND)
     2208        mainSizer.Add(subSizer,0,wx.EXPAND)
    22092209#        mainSizer.Add(subSizer)
    22102210        labelLst[:],elemKeysLst[:],dspLst[:],refFlgElem[:] = [],[],[],[]
     
    29422942    topSizer = wx.BoxSizer(wx.HORIZONTAL)
    29432943    topSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Sample and Experimental Parameters'))
    2944     # add help button to bring up help web page - at right sede of window
    2945     topSizer.Add((-1,-1),1,WACV|wx.EXPAND)
     2944    # add help button to bring up help web page - at right side of window
     2945    topSizer.Add((-1,-1),1,wx.EXPAND)
    29462946    topSizer.Add(G2G.HelpButton(G2frame.dataWindow,helpIndex=G2frame.dataWindow.helpKey))
    2947     mainSizer.Add(topSizer,0,WACV|wx.EXPAND)
     2947    mainSizer.Add(topSizer,0,wx.EXPAND)
    29482948    nameSizer = wx.BoxSizer(wx.HORIZONTAL)
    29492949    nameSizer.Add(wx.StaticText(G2frame.dataWindow,wx.ID_ANY,' Instrument Name '),0,WACV)
     
    29532953    nameSizer.Add(instNameVal)
    29542954    instNameVal.Bind(wx.EVT_CHAR,OnNameVal)
    2955     mainSizer.Add(nameSizer,0,WACV)
     2955    mainSizer.Add(nameSizer,0)
    29562956    mainSizer.Add((5,5),0)
    29572957    labelLst.append('Instrument Name')
     
    29722972                    onChoice=OnHistoChange)
    29732973        nameSizer.Add(histoType)
    2974         mainSizer.Add(nameSizer,0,WACV)
     2974        mainSizer.Add(nameSizer,0)
    29752975        mainSizer.Add((5,5),0)
    29762976
     
    29812981        if 'list' in str(type(data[key])):
    29822982            parmRef = G2G.G2CheckBox(G2frame.dataWindow,' '+lbl,data[key],1)
    2983             parmSizer.Add(parmRef,0,WACV|wx.EXPAND)
     2983            parmSizer.Add(parmRef,0,wx.EXPAND)
    29842984            parmVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data[key],0,
    29852985                nDig=nDig,typeHint=float,OnLeave=AfterChange)
     
    29882988        else:
    29892989            parmSizer.Add(wx.StaticText(G2frame.dataWindow,label=' '+lbl),
    2990                 0,WACV|wx.EXPAND)
     2990                0,wx.EXPAND)
    29912991            parmVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data,key,
    29922992                typeHint=float,OnLeave=AfterChange)
     
    44144414    topSizer = wx.BoxSizer(wx.HORIZONTAL)
    44154415    topSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label=' Indexing controls: '),0,WACV)
    4416     # add help button to bring up help web page - at right sede of window
    4417     topSizer.Add((-1,-1),1,WACV|wx.EXPAND)
     4416    # add help button to bring up help web page - at right side of window
     4417    topSizer.Add((-1,-1),1,wx.EXPAND)
    44184418    topSizer.Add(G2G.HelpButton(G2frame.dataWindow,helpIndex=G2frame.dataWindow.helpKey))
    4419     mainSizer.Add(topSizer,0,WACV|wx.EXPAND)
     4419    mainSizer.Add(topSizer,0,wx.EXPAND)
    44204420    mainSizer.Add((5,5),0)
    44214421    littleSizer = wx.FlexGridSizer(0,5,5,5)
     
    44364436    mainSizer.Add((5,5),0)
    44374437    mainSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Select Bravais Lattices for indexing: '),
    4438         0,WACV)
     4438        0)
    44394439    mainSizer.Add((5,5),0)
    44404440    littleSizer = wx.FlexGridSizer(0,5,5,5)
     
    44564456    hklShow.Bind(wx.EVT_BUTTON,OnHklShow)
    44574457    littleSizer.Add(hklShow,0,WACV)   
    4458     littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=' cell step ',style=wx.ALIGN_RIGHT),0,WACV|wx.ALIGN_RIGHT)
     4458    littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=' cell step ',style=wx.ALIGN_RIGHT),0,WACV)
    44594459    shiftChoices = [ '0.01%','0.05%','0.1%','0.5%', '1.0%','2.5%','5.0%']
    44604460    shiftSel = wx.Choice(G2frame.dataWindow,choices=shiftChoices)
     
    62686268    elif 'Particle' in data['Current']:
    62696269        G2frame.dataWindow.SasSeqFit.Enable(True)
    6270         mainSizer.Add(PartSizer(),1,wx.ALIGN_LEFT|wx.EXPAND)
     6270        mainSizer.Add(PartSizer(),1,wx.EXPAND)
    62716271    elif 'Pair' in data['Current']:
    62726272        G2frame.dataWindow.SasSeqFit.Enable(False)
    6273         mainSizer.Add(PairSizer(),1,wx.ALIGN_LEFT|wx.EXPAND)
     6273        mainSizer.Add(PairSizer(),1,wx.EXPAND)
    62746274    elif 'Shape' in data['Current']:
    62756275        G2frame.dataWindow.SasSeqFit.Enable(False)
    6276         mainSizer.Add(ShapesSizer(),1,wx.ALIGN_LEFT|wx.EXPAND)
     6276        mainSizer.Add(ShapesSizer(),1,wx.EXPAND)
    62776277    G2G.HorizontalLine(mainSizer,G2frame.dataWindow)   
    62786278    backSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    72217221            typeHint=float,OnLeave=AfterChangeNoRefresh)
    72227222        bkBox.Add(backVal,0,WACV)   
    7223         sfgSizer.Add(bkBox,0,wx.ALIGN_LEFT|wx.EXPAND)
     7223        sfgSizer.Add(bkBox,0,wx.EXPAND)
    72247224
    72257225        if 'XC' in inst['Type'][0]:
     
    72337233                typeHint=float,OnLeave=AfterChangeNoRefresh)
    72347234            sqBox.Add(rulandWdt,0,WACV)   
    7235             sfgSizer.Add(sqBox,0,wx.ALIGN_LEFT|wx.EXPAND)
     7235            sfgSizer.Add(sqBox,0,wx.EXPAND)
    72367236       
    72377237        sqBox = wx.BoxSizer(wx.HORIZONTAL)
  • trunk/GSASIIrestrGUI.py

    r4697 r4759  
    19171917        btn = wx.Button(GeneralRestr, wx.ID_ANY,"Add restraint")
    19181918        btn.Bind(wx.EVT_BUTTON,OnAddRestraint)
    1919         hSizer.Add(btn,0,wx.ALIGN_CENTER|wx.EXPAND|wx.ALL)
     1919        hSizer.Add(btn,0,wx.EXPAND|wx.ALL)
    19201920        mainSizer.Add(hSizer,0)
    19211921        mainSizer.Add((5,5),0)
  • trunk/exports/G2export_CIF.py

    r4661 r4759  
    29392939                fbox.Add(txt,(i+2,0))
    29402940            line = wx.StaticLine(self,wx.ID_ANY, size=(-1,3), style=wx.LI_HORIZONTAL)
    2941             vbox.Add(line, 0, wx.EXPAND|wx.ALIGN_CENTER|wx.ALL, 10)
     2941            vbox.Add(line, 0, wx.EXPAND|wx.ALL, 10)
    29422942
    29432943        # post the non-looped CIF items
Note: See TracChangeset for help on using the changeset viewer.