Changeset 5108


Ignore:
Timestamp:
Dec 6, 2021 7:55:56 AM (2 years ago)
Author:
vondreele
Message:

Add tests to transformation matrix in TransformDialog?; returns None if bad.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r5106 r5108  
    414414
    415415        def OnTest(event):
     416            if not self.TestMat():
     417                return
    416418            if self.Mtrans:
    417419                self.newCell = G2lat.TransformCell(self.oldCell[:6],self.Trans.T)
     
    590592        self.Fit()
    591593       
     594    def TestMat(self):
     595        VC = nl.det(self.Trans)
     596        if VC < 0.:
     597            wx.MessageBox('Warning - left handed transformation',caption='Transformation matrix check',
     598                style=wx.ICON_EXCLAMATION)
     599            return True
     600        try:
     601            nl.inv(self.Trans)
     602        except nl.LinAlgError:
     603            wx.MessageBox('ERROR - bad transformation matrix',caption='Transformation matrix check',
     604                style=wx.ICON_ERROR)
     605            return False
     606        return True
     607       
    592608    def GetSelection(self):
    593609        self.Phase['General']['SGData'] = self.SGData
     
    596612        else:
    597613            self.Phase['General']['Name'] += ' %s'%(self.Common)
     614        if not self.TestMat():
     615            return None
    598616        if self.Mtrans:
    599617            self.Phase['General']['Cell'][1:] = G2lat.TransformCell(self.oldCell[:6],self.Trans.T)           
     
    28262844            try:
    28272845                if dlg.ShowModal() == wx.ID_OK:
    2828                     newPhase,Trans,Uvec,Vvec,ifMag,ifConstr,Common = dlg.GetSelection()
     2846                    result = dlg.GetSelection()
     2847                    if result is None:
     2848                        return
     2849                    newPhase,Trans,Uvec,Vvec,ifMag,ifConstr,Common = result
    28292850                    newPhase['ranId'] = ran.randint(0,sys.maxsize)
    28302851                    SGData = newPhase['General']['SGData']
Note: See TracChangeset for help on using the changeset viewer.