-
Notifications
You must be signed in to change notification settings - Fork 21
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
Tickets/dm 7221 #85
Tickets/dm 7221 #85
Changes from all commits
5d172cf
02c503d
1c62bd3
0187454
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python | ||
from __future__ import absolute_import, division | ||
|
||
# | ||
# LSST Data Management System | ||
# Copyright 2016 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, | ||
# see <http://www.lsstcorp.org/LegalNotices/>. | ||
# | ||
|
||
import unittest | ||
|
||
import numpy | ||
import astropy.io.fits | ||
import lsst.utils.tests | ||
import lsst.afw.geom | ||
import lsst.afw.table | ||
|
||
|
||
class TableIoTestCase(lsst.utils.tests.TestCase): | ||
|
||
def testAngleUnitWriting(self): | ||
"""Test that Angle columns have TUNIT set appropriately, | ||
as per DM-7221. | ||
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. Yay helpful test docstrings! 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. Thanks! I'd like to think mine are usually okay, but I have to admit that I was thinking of the conversation we had at the hack session last week when I included the ticket number. |
||
""" | ||
schema = lsst.afw.table.Schema() | ||
key = schema.addField("a", type="Angle", doc="angle field") | ||
outCat = lsst.afw.table.BaseCatalog(schema) | ||
outCat.addNew().set(key, 1.0*lsst.afw.geom.degrees) | ||
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. Nice: make it degrees, but ensure it gets output as radians. Good test. |
||
with lsst.utils.tests.getTempFilePath(".fits") as tmpFile: | ||
outCat.writeFits(tmpFile) | ||
inFits = astropy.io.fits.open(tmpFile) | ||
self.assertEqual(inFits[1].header["TTYPE1"], "a") | ||
self.assertEqual(inFits[1].header["TUNIT1"], "rad") | ||
|
||
|
||
class MemoryTester(lsst.utils.tests.MemoryTestCase): | ||
pass | ||
|
||
|
||
def setup_module(module): | ||
lsst.utils.tests.init() | ||
|
||
|
||
if __name__ == "__main__": | ||
lsst.utils.tests.init() | ||
unittest.main() |
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.
Maybe just a short comment here saying that this is checking that there's exactly one of each? It's mostly clear from the code and function docstring, but it took me a bit to realize that's what this meant.
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.
Oh, and would this code have failed before you made the fix?
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'll add the comment. I'm pretty certain this test would have failed before the fix, but I didn't actually do it in that order.