Skip to content

Commit 3c57774

Browse files
committed
⬆️ Initial upgrade to Python 2/3
1 parent e25f446 commit 3c57774

19 files changed

+294
-233
lines changed

python/Centroid.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from __future__ import division, absolute_import, print_function
1+
from __future__ import division, absolute_import, print_function, unicode_literals
2+
23
"""Measure centroids.
34
45
Note: as with all PyGuide routines, the coordinate system origin
@@ -131,7 +132,7 @@ def _fmtList(alist):
131132
_MaxIter = 40 # max # of iterations
132133
_MinPixForStats = 20 # minimum # of pixels needed to measure med and std dev
133134

134-
class CentroidData:
135+
class CentroidData(object):
135136
"""Centroid data, including the following fields:
136137
137138
flags; check before paying attention to the remaining data:

python/Constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from __future__ import division, absolute_import, print_function
2+
from __future__ import unicode_literals
3+
24
"""Constants and parameters
35
46
History:
@@ -36,7 +38,7 @@
3638
NaN = float("nan")
3739

3840
# Misc
39-
class CCDInfo:
41+
class CCDInfo(object):
4042
"""Info about the CCD
4143
4244
- bias ccd bias (ADU)

python/FakeData.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
from __future__ import division, absolute_import, print_function
1+
from __future__ import absolute_import, division, print_function, unicode_literals
2+
3+
import numpy
4+
import numpy.random
5+
6+
from . import ImUtil
7+
8+
29
"""Generates fake ccd data
310
411
History:
@@ -12,12 +19,10 @@
1219
2005-05-16 ROwen Modified addNoise to take ccdInfo instead of 3 args.
1320
2009-11-20 ROwen Modified to use numpy.
1421
"""
22+
1523
__all__ = ["fakeStar", "addNoise"]
1624

17-
import numpy
18-
import numpy.random
1925

20-
from . import ImUtil
2126

2227
_MaxValUInt16 = 2**16 - 1
2328

python/FindStars.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from __future__ import division, absolute_import, print_function
2+
from __future__ import unicode_literals
3+
24
"""Find Stars.
35
46
Note: as with all PyGuide routines, the coordinate system origin

python/ImUtil.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from __future__ import division, absolute_import, print_function
2+
from __future__ import unicode_literals
3+
4+
25
"""Image processing utilities.
36
47
History:
@@ -65,7 +68,7 @@ def getQuartile(sortedData, qnum):
6568
return ((sortedData[ind0] * ratios[0]) + (sortedData[ind0+1] * ratios[1])) / (ratios[0] + ratios[1])
6669

6770

68-
class ImStats:
71+
class ImStats(object):
6972
"""Information about an image
7073
(including the settings use to obtain that info).
7174
@@ -166,7 +169,7 @@ def skyStats(
166169
)
167170

168171

169-
class SubFrame:
172+
class SubFrame(object):
170173
"""Create a subframe and provide useful utility methods.
171174
172175
Inputs:

python/StarShape.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
from __future__ import division, absolute_import, print_function
2+
from __future__ import unicode_literals
3+
4+
5+
26
"""StarShape
37
48
Fit a a star to a symmetrical double gaussian.
@@ -102,7 +106,7 @@
102106
# minimum radius
103107
_MinRad = 3.0
104108

105-
class StarShapeData:
109+
class StarShapeData(object):
106110
"""Guide star fit data
107111
108112
Attributes:

python/Version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
from __future__ import unicode_literals
12
__version__ = "2.3.0"

python/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
some of the subtleties.
2727
"""
2828
from __future__ import absolute_import
29+
from __future__ import unicode_literals
2930
from .Version import __version__
3031
from .Constants import *
3132
from .Centroid import *

releaseNewVersion.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
To use:
55
./releaseNewVersion.py
66
"""
7+
from __future__ import print_function
8+
from __future__ import unicode_literals
9+
710
from __future__ import with_statement
811
import os
912
import re
@@ -18,7 +21,7 @@
1821
import Version # noqa must come after modifying sys.path
1922

2023
queryStr = "Version from %s.Version = %s; is this OK? (y/[n]) " % (PkgName, Version.__version__,)
21-
versOK = raw_input(queryStr)
24+
versOK = input(queryStr)
2225
if not versOK.lower() == "y":
2326
sys.exit(0)
2427

@@ -29,24 +32,24 @@
2932
if versMatch:
3033
histVersStr = versMatch.groups()[0]
3134
if histVersStr == Version.__version__:
32-
print "Version in VersionHistory.html matches"
35+
print("Version in VersionHistory.html matches")
3336
break
3437
else:
35-
print "Error: version in VersionHistory.html = %s != %s" % (histVersStr, Version.__version__)
38+
print("Error: version in VersionHistory.html = %s != %s" % (histVersStr, Version.__version__))
3639
sys.exit(0)
3740

38-
print "Status of git repository:"
41+
print("Status of git repository:")
3942

4043
subprocess.call(["git", "status"])
4144

42-
versOK = raw_input("Is the git repository up to date? (y/[n]) ")
45+
versOK = input("Is the git repository up to date? (y/[n]) ")
4346
if not versOK.lower() == "y":
4447
sys.exit(0)
4548

46-
print "Git repository OK"
49+
print("Git repository OK")
4750

4851
if UploadToPyPI:
49-
print "Uploading to PyPI"
52+
print("Uploading to PyPI")
5053
status = subprocess.call(["python", "setup.py", "sdist", "upload"])
5154
if status != 0:
52-
print "Build and upload failed!"
55+
print("Build and upload failed!")

scripts/doPyGuide.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
2009-11-20 ROwen Modified to use numpy.
4141
Stop setting NUMERIX.
4242
"""
43+
from __future__ import unicode_literals
4344
import sys
4445
import pyfits
4546
import PyGuide
@@ -341,7 +342,7 @@ def showDef():
341342
globalDict = globals()
342343
for paramName in FindParamNames:
343344
print("%s = %s" % (paramName, globalDict[paramName]))
344-
print
345+
print()
345346

346347
def help():
347348
print("""The following variables are available:

0 commit comments

Comments
 (0)