Skip to content
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

Merged
merged 11 commits into from Jul 19, 2018
Merged

DM-15105: Style guide fixes #138

merged 11 commits into from Jul 19, 2018

Conversation

timj
Copy link
Member

@timj timj commented Jul 13, 2018

  • Enable flake8 and travis

@timj timj requested a review from PaulPrice July 13, 2018 20:05
@timj
Copy link
Member Author

timj commented Jul 13, 2018

@PaulPrice this checking has uncovered a seeming bug:

./python/lsst/obs/subaru/ccdTesting.py:2844:92: F821 undefined name 'median'
./python/lsst/obs/subaru/ccdTesting.py:2847:14: F821 undefined name 'medianFilterImage'

Looking at arcturus.py it seems there is an undisclosed dependency on lsst.analysis and that is where medianFilterImage should be coming from. I don't see setupRequired(analysis) in the table file. median does not seem to be defined anywhere so I'm not sure how you want me to fix this.

@@ -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
Copy link
Member Author

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.

@timj
Copy link
Member Author

timj commented Jul 13, 2018

And matplotlib is imported but not declared in the table file, and import lsst.afw.display.ds9 as ds9 is being used.

showNdataFwhm=args.showNdataFwhm, showNdataEll=args.showNdataEll,
minNdata=args.minNdata, maxNdata=args.maxNdata,
verbose=args.verbose)
plot = main(dataDir, visit, title, args.outputTxtFile,
Copy link
Member Author

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.

@PaulPrice
Copy link
Contributor

Let's jettison ccdTesting.py. OK, @RobertLuptonTheGood ?

@RobertLuptonTheGood
Copy link
Member

RobertLuptonTheGood commented Jul 14, 2018 via email

@timj
Copy link
Member Author

timj commented Jul 16, 2018

@RobertLuptonTheGood ccdTesting.py is broken. See my comment above. If you want to suggest a fix for the medians I'm happy to integrate it. I can comment out the entire function if you prefer? Putting it on a non-standard branch seems like a bad plan to me.

@timj
Copy link
Member Author

timj commented Jul 16, 2018

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.

@timj
Copy link
Member Author

timj commented Jul 16, 2018

@PaulPrice I've made the changes, and added a few more cleanups? Can you take a look or should I ask @r-owen ?

@timj timj requested a review from r-owen July 16, 2018 21:36
Copy link
Contributor

@r-owen r-owen left a 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.

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type: "srt" -> "str"

Copy link
Member Author

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.

@@ -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]:
Copy link
Contributor

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.

#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')
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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@
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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/>.

#----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
Copy link
Contributor

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?

Copy link
Member Author

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.

@timj
Copy link
Member Author

timj commented Jul 16, 2018

I have made the requested changes. I'll wait until tomorrow before merging in case @PaulPrice has a comment.

@laurenam
Copy link
Contributor

Just FYI, @PaulPrice is away through Wednesday.

Copy link
Contributor

@PaulPrice PaulPrice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

#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')
Copy link
Contributor

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
Copy link
Contributor

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@
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct.

@timj timj merged commit 0953bf4 into master Jul 19, 2018
@ktlim ktlim deleted the tickets/DM-15105 branch August 25, 2018 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants