Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
0822cd8
PY3: support print function in PY2
pavoljuhas Sep 25, 2019
15bbfa6
PY3: use fast cPickle module for Python 2
pavoljuhas Sep 25, 2019
e337d56
PY3: fix RawConfigParser import for PY2
pavoljuhas Sep 25, 2019
0cc295a
PY3: use six.StringIO for PY2/PY3 compatibility
pavoljuhas Sep 26, 2019
03fecd3
MNT: drop obsolete test code
pavoljuhas Sep 26, 2019
984df64
MNT: add todo-list of sources for 2to3 conversion
pavoljuhas Sep 26, 2019
ae9f498
PY3: 2to3 conversion of applications/pdfgui.py
pavoljuhas Sep 26, 2019
cefbaec
PY3: 2to3 check of control/calculation.py
pavoljuhas Sep 26, 2019
7dd95d0
PY3: 2to3 check of control/constraint.py
pavoljuhas Sep 26, 2019
8e67f19
PY3: 2to3 check of control/fitdataset.py
pavoljuhas Sep 26, 2019
28cb664
PY3: 2to3 check of control/fitstructure.py
pavoljuhas Sep 26, 2019
4e1e555
PY3: 2to3 check of control/fitting.py
pavoljuhas Sep 26, 2019
ef77eba
PY3: 2to3 check of control/organizer.py
pavoljuhas Sep 26, 2019
42b9c9d
PY3: 2to3 check of control/parameter.py
pavoljuhas Sep 26, 2019
4466b13
PY3: 2to3 check of control/pdfdataset.py
pavoljuhas Sep 26, 2019
ce15162
PY3: 2to3 check of control/pdfguicontrol.py
pavoljuhas Sep 26, 2019
d7f6d7e
PY3: 2to3 check of control/pdfguimacros.py
pavoljuhas Sep 26, 2019
8474e98
PY3: 2to3 check of control/pdflist.py
pavoljuhas Sep 26, 2019
c365b24
PY3: 2to3 check of control/pdfstructure.py
pavoljuhas Sep 26, 2019
e3f5757
PY3: 2to3 check of control/plotter.py
pavoljuhas Sep 26, 2019
453e9ab
PY3: 2to3 check of control/structureviewer.py
pavoljuhas Sep 26, 2019
a85ccc1
PY3: 2to3 check of gui/bondlengthdialog.py
pavoljuhas Sep 26, 2019
c2c3799
PY3: 2to3 check of gui/debugoptions.py
pavoljuhas Sep 26, 2019
1fd2756
PY3: 2to3 check of gui/dopingseriespanel.py
pavoljuhas Sep 26, 2019
1082ece
PY3: use six.moves.urllib for PY2/PY3 compatibility
pavoljuhas Sep 26, 2019
3b02236
PY3: 2to3 check of gui/errorwrapper.py
pavoljuhas Sep 26, 2019
0c75ae5
PY3: 2to3 check of gui/extendedplotframe.py
pavoljuhas Sep 26, 2019
93f0105
PY3: 2to3 check of gui/fittree.py
pavoljuhas Sep 26, 2019
9d613be
PY3: 2to3 check of gui/mainframe.py
pavoljuhas Sep 26, 2019
41fde5c
PY3: 2to3 check of gui/parameterspanel.py
pavoljuhas Sep 26, 2019
3a9a48a
PY3: 2to3 check of gui/phaseconfigurepanel.py
pavoljuhas Sep 26, 2019
19e4fc7
PY3: 2to3 check of gui/phaseconstraintspanel.py
pavoljuhas Sep 26, 2019
2801e1f
PY3: 2to3 check of gui/phasepanelutils.py
pavoljuhas Sep 26, 2019
ccf2aca
PY3: 2to3 check of gui/phasepanelutils.py
pavoljuhas Sep 26, 2019
e28d327
PY3: 2to3 check of gui/temperatureseriespanel.py
pavoljuhas Sep 26, 2019
8320f88
PY3: 2to3 check of gui/tooltips.py
pavoljuhas Sep 26, 2019
d08c0bc
PY3: 2to3 check of tests/testfitstructure.py
pavoljuhas Sep 26, 2019
2d902b2
PY3: 2to3 check of utils.py
pavoljuhas Sep 26, 2019
8ccf410
MNT: note completion of all 2to3 checks
pavoljuhas Sep 26, 2019
7743cd3
REL: add `six` to run dependencies
pavoljuhas Sep 26, 2019
0fa1444
REL: declare support for Python 3.7, 3.6, 3.5
pavoljuhas Sep 26, 2019
4e4baa9
CI: add travis tests for Python 3.5, 3.6, 3.7
pavoljuhas Sep 26, 2019
822e6c6
BLD: build conda for all supported Python versions
pavoljuhas Sep 26, 2019
c5f5af1
TST: use PY3 compatible imports in testdeps
pavoljuhas Sep 26, 2019
1f6ccb2
MNT: fix invalid escape sequences
pavoljuhas Sep 26, 2019
5dc3242
CI: stop using old conda packages
pavoljuhas Sep 26, 2019
a03d4c5
PY3: replace builtin `file()` --> `open()`
pavoljuhas Sep 26, 2019
41d8b0f
MNT: make sure to close any open files
pavoljuhas Sep 26, 2019
da5c13b
BUG: fix staticmethod in CtrlUnpickler class
pavoljuhas Sep 26, 2019
4d1451a
PY3: adjust QuotedConfigParser for Python 3
pavoljuhas Sep 26, 2019
5dfb4a3
PY3: remove unnecessary conversion to ASCII bytes
pavoljuhas Sep 26, 2019
0ceaaa0
PY3: convert text read from project zip to unicode
pavoljuhas Sep 26, 2019
a5a9f46
MNT: make sure string data are saved as unicode
pavoljuhas Sep 26, 2019
533b6e7
MNT: rename `bytes` variable to non-builtin name
pavoljuhas Sep 26, 2019
87ecea5
MNT: use `utf-8` as a standard encoding name
pavoljuhas Sep 26, 2019
121ea63
PY3: fix crashing `quote_plain`, `unquote_plain`
pavoljuhas Sep 30, 2019
3c92f1e
PY3: add `pickle_loads` with common interface
pavoljuhas Sep 30, 2019
e316562
PY3: unpickle FitDataSet with latin1 encoding
pavoljuhas Sep 30, 2019
a0c745e
ENH: write pickles with protocol 2
pavoljuhas Sep 30, 2019
0f363be
MNT: use safeCPickleDumps for all dumps
pavoljuhas Sep 30, 2019
e47cdd7
ENH: use 'encoding=latin1' default in pickle_loads
pavoljuhas Sep 30, 2019
60c62ef
ENH: replace pickle.loads with pickle_loads
pavoljuhas Sep 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PY3: 2to3 check of control/fitstructure.py
  • Loading branch information
pavoljuhas committed Sep 26, 2019
commit 28cb664ad4c59c1e12ed0f1e89e907d1f8e70eae
1 change: 0 additions & 1 deletion TODO-2to3.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
src/diffpy/pdfgui/control/fitstructure.py
src/diffpy/pdfgui/control/fitting.py
src/diffpy/pdfgui/control/organizer.py
src/diffpy/pdfgui/control/parameter.py
Expand Down
43 changes: 19 additions & 24 deletions src/diffpy/pdfgui/control/fitstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ def findParameters(self):
returns dictionary of indices and Parameter instances
"""
foundpars = {}
for var, con in self.constraints.iteritems():
for var, con in self.constraints.items():
con.guess(self.initial.getvar(var))
for pidx, pguess in con.parguess.iteritems():
for pidx, pguess in con.parguess.items():
# skip if already found
if pidx in foundpars:
continue
Expand All @@ -201,13 +201,13 @@ def applyParameters(self, parameters):
"""
# convert values to floats
parvalues = { }
for pidx, par in parameters.iteritems():
for pidx, par in parameters.items():
if isinstance(par, Parameter):
parvalues[pidx] = par.initialValue()
else:
parvalues[pidx] = float(par)
# evaluate constraints
for var, con in self.constraints.iteritems():
for var, con in self.constraints.items():
self.initial.setvar(var, con.evalFormula(parvalues))
return

Expand Down Expand Up @@ -237,7 +237,7 @@ def _popAtomConstraints(self):
rv = {}
# atom variable pattern
avpat = re.compile(r'^([xyz]|occ|u11|u22|u33|u12|u13|u23)\((\d+)\)')
for var in self.constraints.keys():
for var in list(self.constraints.keys()):
m = avpat.match(var)
if not m: continue
barevar = m.group(1)
Expand All @@ -258,7 +258,7 @@ def _restoreAtomConstraints(self, acd):
# there are some constraints for atom a
siteindex = i + 1
cnts = acd[a]
for barevar, con in cnts.iteritems():
for barevar, con in cnts.items():
var = barevar + "(%i)" % siteindex
self.constraints[var] = con
return
Expand Down Expand Up @@ -287,9 +287,7 @@ def deleteAtoms(self, indices):
"""
acd = self._popAtomConstraints()
# get unique, reverse sorted indices
ruindices = dict.fromkeys(indices).keys()
ruindices.sort()
ruindices.reverse()
ruindices = sorted(set(indices), reverse=True)
for i in ruindices:
self.initial.pop(i)
self._restoreAtomConstraints(acd)
Expand Down Expand Up @@ -325,7 +323,7 @@ def expandSuperCell(self, mno):
if a not in acd: continue
# add empty constraint dictionary for duplicate atom
acd[adup] = {}
for barevar, con in acd[a].iteritems():
for barevar, con in acd[a].items():
formula = con.formula
if barevar in ("x", "y", "z"):
symidx = "xyz".index(barevar)
Expand Down Expand Up @@ -427,9 +425,7 @@ def expandAsymmetricUnit(self, spacegroup, indices, sgoffset=[0,0,0]):
from diffpy.structure.symmetryutilities import ExpandAsymmetricUnit
acd = self._popAtomConstraints()
# get unique, reverse sorted indices
ruindices = dict.fromkeys(indices).keys()
ruindices.sort()
ruindices.reverse()
ruindices = sorted(set(indices), reverse=True)
coreatoms = [self.initial[i] for i in ruindices]
corepos = [a.xyz for a in coreatoms]
coreUijs = [a.U for a in coreatoms]
Expand Down Expand Up @@ -481,12 +477,11 @@ def applySymmetryConstraints(self, spacegroup, indices, posflag, Uijflag,
from diffpy.structure.symmetryutilities import SymmetryConstraints
# get unique sorted indices
tobeconstrained = dict.fromkeys(indices)
uindices = tobeconstrained.keys()
uindices.sort()
uindices = sorted(tobeconstrained.keys())
# remove old constraints
pospat = re.compile(r'^([xyz])\((\d+)\)')
Uijpat = re.compile(r'^(u11|u22|u33|u12|u13|u23)\((\d+)\)')
for var in self.constraints.keys():
for var in list(self.constraints.keys()):
mpos = posflag and pospat.match(var)
mUij = Uijflag and Uijpat.match(var)
if mpos and (int(mpos.group(2)) - 1) in tobeconstrained:
Expand Down Expand Up @@ -531,7 +526,7 @@ def applySymmetryConstraints(self, spacegroup, indices, posflag, Uijflag,
self.constraints[var] = Constraint(formula)
# update parameter values in parent Fitting
self.owner.updateParameters()
for pidx, pvalue in newparvalues.iteritems():
for pidx, pvalue in newparvalues.items():
parobj = self.owner.parameters[pidx]
parobj.setInitial(pvalue)
# and finally remember this space group
Expand Down Expand Up @@ -637,7 +632,7 @@ def getSelectedIndices(self, s):
Return a list of integers.
Raise ControlValueError for invalid selection string format.
'''
s1 = filter(lambda c: not c.isspace(), s)
s1 = ''.join(c for c in s if not c.isspace())
words = s1.split(',')
indices = set()
for w in words:
Expand Down Expand Up @@ -752,11 +747,11 @@ def load(self, z, subpath):
rootDict = z.fileTree[subs[0]][subs[1]][subs[2]][subs[3]]
self.initial.readStr(z.read(subpath+'initial'), 'pdffit')
# refined
if rootDict.has_key('refined'):
if 'refined' in rootDict:
self.refined = PDFStructure(self.name)
self.refined.readStr(z.read(subpath+'refined'), 'pdffit')
# constraints
if rootDict.has_key('constraints'):
if 'constraints' in rootDict:
self.constraints = CtrlUnpickler.loads(z.read(subpath+'constraints'))
translate = { 'gamma' : 'delta1',
'delta' : 'delta2',
Expand All @@ -765,15 +760,15 @@ def load(self, z, subpath):
if old in self.constraints:
self.constraints[new] = self.constraints.pop(old)
# selected_pairs
if rootDict.has_key("selected_pairs"):
if "selected_pairs" in rootDict:
self.selected_pairs = z.read(subpath+'selected_pairs')
# sgoffset
if rootDict.has_key("sgoffset"):
if "sgoffset" in rootDict:
sgoffsetstr = z.read(subpath+'sgoffset')
sgoffset = [float(w) for w in sgoffsetstr.split()]
self.initial.pdffit['sgoffset'] = sgoffset
# custom_spacegroup
if rootDict.has_key("custom_spacegroup"):
if "custom_spacegroup" in rootDict:
bytes = z.read(subpath+'custom_spacegroup')
self.custom_spacegroup = CtrlUnpickler.loads(bytes)
return
Expand Down Expand Up @@ -806,7 +801,7 @@ def getYNames(self):

returns a name str list
"""
return self.constraints.keys()
return list(self.constraints.keys())

def getXNames(self):
"""get names of data item which can be plotted as x
Expand Down