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-15105: Style guide fixes #138
Conversation
timj
commented
Jul 13, 2018
- Enable flake8 and travis
@PaulPrice this checking has uncovered a seeming bug:
Looking at |
python/lsst/obs/subaru/ccdTesting.py
Outdated
@@ -1002,7 +986,7 @@ def grads(exp): | |||
plt.clf() | |||
for a in ccd: | |||
ima = im[a.getRawDataBBox()].getArray() | |||
I = np.mean(ima, 1)/np.median(ima) | |||
I = np.mean(ima, 1)/np.median(ima) # noqa E741 |
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.
@PaulPrice not sure if you would rather rename this variable to fix the warning or keep the noqa.
And matplotlib is imported but not declared in the table file, and |
showNdataFwhm=args.showNdataFwhm, showNdataEll=args.showNdataEll, | ||
minNdata=args.minNdata, maxNdata=args.maxNdata, | ||
verbose=args.verbose) | ||
plot = main(dataDir, visit, title, args.outputTxtFile, |
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.
This one was causing trouble because plt
was clashing with the plt
that was imported from matplotlib
.
Let's jettison ccdTesting.py. OK, @RobertLuptonTheGood ? |
OK. But there's potentially useful stuff in there, so I'd like to see any files removed from obs_subaru put onto a branch (called something like HSCcommissioningTools) before deleting them
|
@RobertLuptonTheGood |
I've discussed this on Slack and the plan is to remove the file and be explicit in the commit message. I'm having trouble pushing this change to the branch at the moment. |
@PaulPrice I've made the changes, and added a few more cleanups? Can you take a look or should I ask @r-owen ? |
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.
A very nice update. I found a few minor issues and have a few questions for things that are probably right but new to me.
bin.src/genDefectRegistry.py
Outdated
@@ -67,11 +65,12 @@ def __init__(self, path, version, validStart, validEnd=None): | |||
# Defects files for a CCD are valid from the date they are registered until the next date. | |||
# This means that any defects file should carry ALL the defects that are present at that time. | |||
for ccd, rowList in rowsPerCcd.items(): | |||
rowList.sort(key=lambda row: row.validStart) # ISO-8601 will sort just fine without conversion from str | |||
# ISO-8601 will sort just fine without conversion from srt |
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.
type: "srt" -> "str"
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 have no idea how I transposed those letters.
bin.src/makeGeom.py
Outdated
@@ -236,7 +234,7 @@ def printElectronics(buff, ccdId, ccdname, xidx, yidx, infoA, infoB): | |||
|
|||
# 0th layer is pure metadata | |||
for ccd in range(1, len(ptr)): | |||
#for ccd in [1, 28]: | |||
# for ccd in [1, 28]: |
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.
Consider deleting commented-out code. This looks even safer to remove than the bit earlier.
bin.src/makeGeom.py
Outdated
#buff.write(' name: "R:0,0 S:%d,%d CFHTid:%d %s" \n' % (xidx, yidx, ccdId, ccdname)) | ||
#buff.write(' serial: -1 \n') | ||
# buff.write(' name: "R:0,0 S:%d,%d CFHTid:%d %s" \n' % (xidx, yidx, ccdId, ccdname)) | ||
# buff.write(' serial: -1 \n') |
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.
Consider deleting commented-out code. I can see why you kept it -- better safe than sorry, especially as it's not your package. @PaulPrice what do you think?
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.
This didn't look like code I wanted to mess with so I fixed the warning only.
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 think this file is left over from the cameraGeom transition half a lifetime ago, and it looks like it contains CFHT-specific stuff (?!). Suggest we simply dump it all.
config/*.py ALL | ||
suprimecam/* ALL | ||
hsc/* ALL | ||
bin/* ALL |
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.
Is the ALL
necessary? I have not seen it used before.
Also, why ignore everything in bin
? I would expect all the python code to be from bin.src
and to pass.
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.
Testing bin/
and bin.src/
doesn't add anything so I thought it was quicker to ignore them. The ALL
might not be necessary, I didn't think it was until last week when a package I was working on with @SimonKrughoff required it. I'll take another look.
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 have experimented. See also https://pypi.org/project/pytest-flake8/
Specifying a file in the flake8-ignore
section without any parameter does nothing. You need the ALL
to prevent pytest from looking at the file at all. flake8 does respect the exclude line in the section above though. So without the ALL pytest sends the file to flake8 and flake8 returns a PASS because it was told to excliude the file. If you specify ALL
then pytest never sends the file to flake8 so it doesn't even look like a test. ALL
is therefore the correct approach.
@@ -1,2 +0,0 @@ | |||
@LSST BUILD@ && | |||
build_lsst @PRODUCT@ @VERSION@ @REPOVERSION@ |
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.
Why is this file going away?
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.
There was a conversation on Slack last week where we all came to the conclusion that nothing uses these files and they are unused cruft in the system that confuse people.
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.
That is correct.
@@ -14,24 +14,22 @@ | |||
# You should have received a copy of the GNU General Public License | |||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
|
|||
#---------------------------------------------------------------------------- | |||
# ---------------------------------------------------------------------------- |
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 know this is picky and feel free to ignore it, but consider getting rid of the line?
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.
Yes. Sorry. I should have removed it.
I have made the requested changes. I'll wait until tomorrow before merging in case @PaulPrice has a comment. |
Just FYI, @PaulPrice is away through Wednesday. |
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.
Looks good, thanks!
bin.src/makeGeom.py
Outdated
#buff.write(' name: "R:0,0 S:%d,%d CFHTid:%d %s" \n' % (xidx, yidx, ccdId, ccdname)) | ||
#buff.write(' serial: -1 \n') | ||
# buff.write(' name: "R:0,0 S:%d,%d CFHTid:%d %s" \n' % (xidx, yidx, ccdId, ccdname)) | ||
# buff.write(' serial: -1 \n') |
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 think this file is left over from the cameraGeom transition half a lifetime ago, and it looks like it contains CFHT-specific stuff (?!). Suggest we simply dump it all.
@@ -12,8 +12,6 @@ | |||
108 110 |
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 don't know what this script does. Suggest dumping it.
@@ -1,2 +0,0 @@ | |||
@LSST BUILD@ && | |||
build_lsst @PRODUCT@ @VERSION@ @REPOVERSION@ |
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.
That is correct.