Changeset 3468


Ignore:
Timestamp:
Jul 12, 2018 10:30:56 AM (3 years ago)
Author:
vondreele
Message:

define new function FindAllCons? to replace bits of identical code that found all constrained variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r3467 r3468  
    510510            dlg.Destroy()
    511511        return []
    512 
     512   
     513    def FindAllCons(data):
     514        ''' Find all constraints
     515        '''
     516        allcons = []
     517        for key in data:
     518            if key.startswith('_'): continue
     519            allcons += data[key]
     520        return allcons
     521       
    513522    def CheckConstraints(constraintSet):
    514523        '''Check for errors in a set of constraints. Constraints based on symmetry (etc.)
     
    535544        :returns: True if constraint should be added
    536545        '''
    537         allcons1 = []
    538         for key in data:
    539             if key.startswith('_'): continue
    540             allcons1 += data[key]
     546       
     547        allcons1 = FindAllCons(data)
    541548        allcons = allcons1[:]
    542549        allcons += newcons
     
    566573        :returns: True if the edit should be retained
    567574        '''
    568         allcons = []
    569         for key in data:
    570             if key.startswith('_'): continue
    571             allcons += data[key]
     575        allcons = FindAllCons(data)
    572576        if not len(allcons): return True
    573577        errmsg,warnmsg = CheckConstraints(allcons)
     
    10021006        Id,name = Indx[Obj.GetId()]
    10031007        del data[name][Id]
    1004         allcons = []
    1005         for key in data:
    1006             if key.startswith('_'): continue
    1007             allcons += data[key]
     1008        allcons = FindAllCons(data)
    10081009        if not len(allcons): return
    10091010        errmsg,warnmsg = CheckConstraints(allcons)
     
    11801181    G2frame.constr.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, OnPageChanged)
    11811182    # validate all the constrants -- should not see any errors here normally
    1182     allcons = []
    1183     for key in data:
    1184         if key.startswith('_'): continue
    1185         allcons += data[key]
     1183    allcons = FindAllCons(data)
    11861184    if not len(allcons): return
    11871185    errmsg,warnmsg = CheckConstraints(allcons)
Note: See TracChangeset for help on using the changeset viewer.