Changeset 3340 for trunk/testDeriv.py


Ignore:
Timestamp:
Apr 11, 2018 1:32:49 PM (4 years ago)
Author:
vondreele
Message:

make testDeriv py3 compatible
fix problem with Reload draw atoms - mag moments
add |Mag| to lst output of magnetic moments
correct errors in mag moment structure factor & derivatives

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/testDeriv.py

    r3232 r3340  
    2222
    2323import sys
    24 import cPickle
    25 import cProfile,pstats,StringIO
     24import platform
     25if '2' in platform.python_version_tuple()[0]:
     26    import cPickle
     27    import StringIO
     28else:
     29    import _pickle as cPickle
     30    import io as StringIO
     31import cProfile,pstats
    2632import wx
    2733import numpy as np
     
    5359        self.testDerivMenu = wx.MenuBar()
    5460        self.File = wx.Menu(title='')
    55         self.File.Append(help='Open testDeriv.dat', id=wxID_FILEOPEN,
    56              kind=wx.ITEM_NORMAL,text='Open testDeriv.dat file')
    57         self.File.Append(help='Make derivative plots',id=wxID_MAKEPLOTS,
    58             kind=wx.ITEM_NORMAL,text='Make plots')
    59         self.File.Append(help='Exit from testDeriv', id=wxID_FILEEXIT, kind=wx.ITEM_NORMAL,
    60             text='Exit')
     61        self.File.Append(wxID_FILEOPEN,'Open testDeriv.dat file','Open testDeriv.dat')
     62        self.File.Append(wxID_MAKEPLOTS,'Make plots','Make derivative plots')
     63        self.File.Append(wxID_FILEEXIT,'Exit','Exit from testDeriv')
    6164        self.Bind(wx.EVT_MENU, self.OnTestRead, id=wxID_FILEOPEN)
    6265        self.Bind(wx.EVT_MENU,self.OnMakePlots,id=wxID_MAKEPLOTS)
     
    9396                testFile = dlg.GetPath()
    9497                file = open(testFile,'rb')
    95                 self.values = cPickle.load(file)
    96                 self.HistoPhases = cPickle.load(file)
    97                 (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file)
    98                 self.parmDict = cPickle.load(file)
    99                 self.varylist = cPickle.load(file)
    100                 self.calcControls = cPickle.load(file)
    101                 self.pawleyLookup = cPickle.load(file)
     98                if '2' in platform.python_version_tuple()[0]:
     99                    self.values = cPickle.load(file)
     100                    self.HistoPhases = cPickle.load(file)
     101                    (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file)
     102                    self.parmDict = cPickle.load(file)
     103                    self.varylist = cPickle.load(file)
     104                    self.calcControls = cPickle.load(file)
     105                    self.pawleyLookup = cPickle.load(file)
     106                else:
     107                    self.values = cPickle.load(file,encoding='Latin-1')
     108                    self.HistoPhases = cPickle.load(file,encoding='Latin-1')
     109                    (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file,encoding='Latin-1')
     110                    self.parmDict = cPickle.load(file,encoding='Latin-1')
     111                    self.varylist = cPickle.load(file,encoding='Latin-1')
     112                    self.calcControls = cPickle.load(file,encoding='Latin-1')
     113                    self.pawleyLookup = cPickle.load(file,encoding='Latin-1')
    102114                self.use = [False for i in range(len(self.varylist+self.depVarList))]
    103115                self.delt = [max(abs(self.parmDict[name])*0.0001,1e-6) for name in self.varylist+self.depVarList]
Note: See TracChangeset for help on using the changeset viewer.