-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-7244: Port to Python 3 #15
Changes from 9 commits
d2e800a
ad1ea86
d67fce8
9df143a
4e36b73
0d963d9
bb1f33c
216e9c3
34c5633
5bce9e9
a724d98
eb80468
2f6df39
d36b942
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
from future import standard_library | ||
standard_library.install_aliases() | ||
#!/usr/bin/env python | ||
|
||
import cPickle | ||
import pickle | ||
import os | ||
|
||
for raft in ["0,1", "0,2", "0,3"]: | ||
for sensor in ["0,1", "1,0", "1,1"]: | ||
for snap in [0, 1]: | ||
for channel in ["0,0", "0,1", "1,0", "1,1"]: | ||
dataId = dict(visit=85470982, | ||
raft=raft, sensor=sensor, snap=snap, channel=channel) | ||
raft=raft, sensor=sensor, snap=snap, channel=channel) | ||
loc = "raw-v%(visit)d-E%(snap)03d-r%(raft)s-s%(sensor)s-c%(channel)s.pickle" % dataId | ||
loc = os.path.join("tests", "data", "input", loc) | ||
num = int(raft[0] + raft[2] + sensor[0] + sensor[2] + | ||
channel[0] + channel[2]) * 10 + snap | ||
channel[0] + channel[2]) * 10 + snap | ||
if raft != "0,3" or (snap != 1 and sensor != "0,1"): | ||
with open(loc, "w") as f: | ||
cPickle.dump(num, f) | ||
pickle.dump(num, f) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# we don't have astrometry_net data (yet) so astrom and photo cal are impossible | ||
config.doAstrometry=False | ||
config.doPhotoCal=False | ||
config.doAstrometry = False | ||
config.doPhotoCal = False |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
config.doDark=False | ||
config.doFringe=False | ||
config.doDark = False | ||
config.doFringe = False |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
#!/usr/bin/env python2 | ||
from __future__ import absolute_import, division, print_function | ||
# | ||
# | ||
# LSST Data Management System | ||
# Copyright 2014 LSST Corporation. | ||
# | ||
# | ||
# This product includes software developed by the | ||
# LSST Project (http://www.lsst.org/). | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the LSST License Statement and | ||
# the GNU General Public License along with this program. If not, | ||
# | ||
# You should have received a copy of the LSST License Statement and | ||
# the GNU General Public License along with this program. If not, | ||
# see <http://www.lsstcorp.org/LegalNotices/>. | ||
# | ||
import argparse | ||
import itertools | ||
import time | ||
|
||
import numpy | ||
|
@@ -36,6 +35,7 @@ | |
detectorName = "0" | ||
detectorSerial = "0000011" | ||
|
||
|
||
def getBBoxList(path, detectorName): | ||
"""Read a defects file and return the defects as a list of bounding boxes | ||
""" | ||
|
@@ -55,11 +55,12 @@ def getBBoxList(path, detectorName): | |
return bboxList | ||
raise RuntimeError("Data not found for detector %r" % (detectorName,)) | ||
|
||
|
||
def writeDefectsFile(bboxList, path, detectorSerial, detectorName): | ||
head = pyfits.Header() | ||
head.update('SERIAL', detectorSerial,'Serial of the detector') | ||
head.update('NAME', detectorName,'Name of detector for this defect map') | ||
head.update('CDATE',time.asctime(time.gmtime()),'UTC of creation') | ||
head.update('SERIAL', detectorSerial, 'Serial of the detector') | ||
head.update('NAME', detectorName, 'Name of detector for this defect map') | ||
head.update('CDATE', time.asctime(time.gmtime()), 'UTC of creation') | ||
|
||
x0 = numpy.array([d.getMinX() for d in bboxList]) | ||
y0 = numpy.array([d.getMinY() for d in bboxList]) | ||
|
@@ -71,7 +72,7 @@ def writeDefectsFile(bboxList, path, detectorSerial, detectorName): | |
col3 = pyfits.Column(name='height', format='I', array=numpy.array(height)) | ||
col4 = pyfits.Column(name='width', format='I', array=numpy.array(width)) | ||
cols = pyfits.ColDefs([col1, col2, col3, col4]) | ||
tbhdu = pyfits.new_table(cols, header = head) | ||
tbhdu = pyfits.new_table(cols, header=head) | ||
hdu = pyfits.PrimaryHDU() | ||
thdulist = pyfits.HDUList([hdu, tbhdu]) | ||
thdulist.writeto(DefectsPath) | ||
|
@@ -94,6 +95,6 @@ def writeDefectsFile(bboxList, path, detectorSerial, detectorName): | |
|
||
test2BBoxList = getBBoxList(DefectsPath, detectorName) | ||
assert len(bboxList) == len(test2BBoxList) | ||
for boxA, boxB in itertools.izip(bboxList, test2BBoxList): | ||
for boxA, boxB in zip(bboxList, test2BBoxList): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be worth adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why futurize didn't do that automatically. I think it's a tiny list, so it may not matter, but I'll add it |
||
assert boxA == boxB | ||
print("verified that defects file %r round trips correctly" % (DefectsPath,)) | ||
print("verified that defects file %r round trips correctly" % (DefectsPath,)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import pkgutil, lsstimport | ||
import pkgutil | ||
import lsstimport | ||
__path__ = pkgutil.extend_path(__path__, __name__) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import pkgutil, lsstimport | ||
import pkgutil | ||
import lsstimport | ||
__path__ = pkgutil.extend_path(__path__, __name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry that this pickle file should be opened in "wb" mode. I'm guessing the test never tries to read from the dumped pickle file. Do we have any check to see if we can read this dumped file back again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. This is an obsolete file. I deleted it.