Skip to content

Commit

Permalink
python3ize
Browse files Browse the repository at this point in the history
  • Loading branch information
csayres committed Aug 12, 2019
1 parent 6bea722 commit b3dd645
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
26 changes: 13 additions & 13 deletions python/fitPlugPlateMeas/fitData.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import with_statement

"""Fit plug plate measurements
History:
Expand Down Expand Up @@ -109,7 +109,7 @@ def __init__(self, model, measPos, nomPos, doRaise=False, maxFuncEval=5000):
initialCoeffs,
maxfev = maxFuncEval,
)
if status not in range(5):
if status not in list(range(5)):
if doRaise:
raise RuntimeError("fit failed")
else:
Expand Down Expand Up @@ -319,7 +319,7 @@ def arrayRMS(arr):


if __name__ == "__main__":
print "Test TransRotScaleModel"
print("Test TransRotScaleModel")
trsModel = TransRotScaleModel()
xyPosList = []
for xPos in (0.0, 1.0): # -1.5, 0.0, 0.5):
Expand All @@ -340,7 +340,7 @@ def arrayRMS(arr):
):
outPos = trsModel.applyOne(inPos)
if not numpy.allclose(outPos, desOutPos):
print "Apply failed on coeffs=%s, inPos=%s, desOutPos=%s outPos=%s" % (trsModel.getCoeffs(), inPos, desOutPos, outPos)
print("Apply failed on coeffs=%s, inPos=%s, desOutPos=%s outPos=%s" % (trsModel.getCoeffs(), inPos, desOutPos, outPos))

for trans in ((0.0, 0.0), (-0.5, 0.3), (0.0, 0.0), (11.9, -35.4)):
for rot in (90.0, -180.0, -179.0, -90.0, -45.0, 0.0, 45.0, 180.0):
Expand All @@ -349,12 +349,12 @@ def arrayRMS(arr):
cnvPosArr = trsModel.apply(xyPosArr)
invPosArr = trsModel.apply(cnvPosArr, doInverse=True)
if not numpy.allclose(xyPosArr, invPosArr):
print "Round trip failed for trans=%s, rot=%s, scale=%s" % (trans, rot, scale)
print "xyPosArr=", xyPosArr
print "cnvPosArr=", cnvPosArr
print "invPosArr=", invPosArr
print("Round trip failed for trans=%s, rot=%s, scale=%s" % (trans, rot, scale))
print("xyPosArr=", xyPosArr)
print("cnvPosArr=", cnvPosArr)
print("invPosArr=", invPosArr)

print "Test QuadrupoleModel"
print("Test QuadrupoleModel")
qpModel = QuadrupoleModel()
xyPosList = []
for xPos in (0.0, 1.0): # -1.5, 0.0, 0.5):
Expand All @@ -370,7 +370,7 @@ def arrayRMS(arr):
cnvPosArr = qpModel.apply(xyPosArr)
invPosArr = qpModel.apply(cnvPosArr, doInverse=True)
if not numpy.allclose(xyPosArr, invPosArr):
print "Round trip failed for qpMag=%s, qpAngle=%s" % (qpMag, qpAngle)
print "xyPosArr=", xyPosArr
print "cnvPosArr=", cnvPosArr
print "invPosArr=", invPosArr
print("Round trip failed for qpMag=%s, qpAngle=%s" % (qpMag, qpAngle))
print("xyPosArr=", xyPosArr)
print("cnvPosArr=", cnvPosArr)
print("invPosArr=", invPosArr)
10 changes: 5 additions & 5 deletions python/fitPlugPlateMeas/fitPlugPlateMeasWdg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import with_statement

"""Fit plug plate measurements
History:
Expand All @@ -22,7 +22,7 @@
"""
import os.path
#import re
import Tkinter
import tkinter
import numpy
#import scipy.optimize
import matplotlib
Expand All @@ -36,9 +36,9 @@

__all__ = ["FitPlugPlateMeasWdg"]

class GraphWdg(Tkinter.Frame):
class GraphWdg(tkinter.Frame):
def __init__(self, master):
Tkinter.Frame.__init__(self, master)
tkinter.Frame.__init__(self, master)

# dictionary of fileName: posErrArr
self.dataDict = dict()
Expand Down Expand Up @@ -210,7 +210,7 @@ def processFileList(self, filePathList):

self.logWdg.addMsg("quadrupole fit for %5d plates: %65s %8.2f %8.2f %8.4f" % \
(self.numSavedPlates, "", quadrupoleMag * 1.0e6, quadrupoleAng, quadrupoleResidRadRMS))
except Exception, e:
except Exception as e:
self.logWdg.addMsg("Failed to fit quadrupole for cumulative data: %s" % (RO.StringUtil.strFromException(e,)), severity=RO.Constants.sevError)


Expand Down

0 comments on commit b3dd645

Please sign in to comment.