Changeset 3136 for trunk/

Oct 23, 2017 11:39:16 AM (4 years ago)

make GSAS-II python 3.6 compliant & preserve python 2.7 use;changes:
do from future import division, print_function for all GSAS-II py sources
all menu items revised to be py 2.7/3.6 compliant
all wx.OPEN --> wx.FD_OPEN in file dialogs
all integer divides (typically for image pixel math) made explicit with ; ambiguous ones made floats as appropriate
all print "stuff" --> print (stuff)
all print >> pFile,'stuff' --> pFile.writeCIFtemplate('stuff')
all read file opens made explicit 'r' or 'rb'
all cPickle imports made for py2.7 or 3.6 as cPickle or _pickle; test for '2' platform.version_tuple[0] for py 2.7
define cPickleload to select load(fp) or load(fp,encoding='latin-1') for loading gpx files; provides cross compatibility between py 2.7/3.6 gpx files
make dict.keys() as explicit list(dict.keys()) as needed (NB: possible source of remaining py3.6 bugs)
make zip(a,b) as explicit list(zip(a,b)) as needed (NB: possible source of remaining py3.6 bugs)
select unichr/chr according test for '2' platform.version_tuple[0] for py 2.7 (G2pwdGUI * G2plot) for special characters
select wg.EVT_GRID_CELL_CHANGE (classic) or wg.EVT_GRID_CELL_CHANGED (phoenix) in grid Bind
maxint --> maxsize; used in random number stuff
raise Exception,"stuff" --> raise Exception("stuff")
wx 'classic' sizer.DeleteWindows?() or 'phoenix' sizer.Clear(True)
wx 'classic' SetToolTipString?(text) or 'phoenix' SetToolTip?(wx.ToolTip?(text)); define SetToolTipString?(self,text) to handle the choice in plots
status.SetFields? --> status.SetStatusText?
'classic' AddSimpleTool? or 'phoenix' self.AddTool? for plot toolbar; Bind different as well
define GetItemPydata? as it doesn't exist in wx 'phoenix'
allow python versions 2.7 & 3.6 to run GSAS-II
Bind override commented out - no logging capability (NB: remove all logging code?)
all import ContentsValidator? open filename & test if valid then close; filepointer removed from Reader
binary importers (mostly images) test for 'byte' type & convert as needed to satisfy py 3.6 str/byte rules

1 edited


  • trunk/

    r3068 r3136  
    9 from __future__ import division
     9from __future__ import division, print_function
    1010import numpy as np
    1111import GSASIIpath
    116116        return fmt.format(float(val)).strip()
    117117    except ValueError:
    118         print 'FormatValue Error with val,maxdigits,fmt=',val,maxdigits,fmt
     118        print ('FormatValue Error with val,maxdigits,fmt= %f %d %s'%(val,maxdigits,fmt))
    119119        return str(val)
    169169        return fmt.format(float(val)).strip()
    170170    except ValueError:
    171         print 'FormatValue Error with val,maxdigits, sigfigs, fmt=',val, maxdigits,sigfigs, fmt
     171        print ('FormatValue Error with val,maxdigits, sigfigs, fmt=%f %d %d %s'%(val, maxdigits,sigfigs, fmt))
    172172        return str(val)
    174174if __name__ == '__main__':
    175175    for i in (1.23456789e-129,1.23456789e129,1.23456789e-99,1.23456789e99,-1.23456789e-99,-1.23456789e99):
    176         print FormatSigFigs(i),i
     176        print (FormatSigFigs(i),i)
    177177    for i in (1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000):
    178         print FormatSigFigs(1.23456789e-9*i),1.23456789e-9*i
     178        print (FormatSigFigs(1.23456789e-9*i),1.23456789e-9*i)
    179179    for i in (1,10,100,1000,10000,100000,1000000,10000000,100000000):
    180         print FormatSigFigs(1.23456789e9/i),1.23456789e9/i
     180        print (FormatSigFigs(1.23456789e9/i),1.23456789e9/i)
    182     print FormatSigFigs(200,10,3)
     182    print (FormatSigFigs(200,10,3))
Note: See TracChangeset for help on using the changeset viewer.