Skip to content

Commit

Permalink
Standardize python imports
Browse files Browse the repository at this point in the history
Use standard `from __future__ import...`
If `__all__ = [...]` exists then put it after `from __future__...`
If `__all__ = [...]` does not exist, add it.
Import numpy as np.
Remove #! lines
  • Loading branch information
r-owen committed Apr 17, 2017
1 parent 57f3578 commit eeb9614
Show file tree
Hide file tree
Showing 25 changed files with 74 additions and 60 deletions.
4 changes: 2 additions & 2 deletions python/lsst/meas/astrom/approximateWcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#
from __future__ import absolute_import, division, print_function

__all__ = ["approximateWcs"]

from builtins import range
from builtins import object
import numpy as np
Expand All @@ -32,8 +34,6 @@
from lsst.meas.astrom.sip import makeCreateWcsWithSip
from lsst.afw.image.basicUtils import assertWcsAlmostEqualOverBBox

__all__ = ["approximateWcs"]


class _MockTestCase(object):
"""A fake unit test case class that will enable us to call
Expand Down
3 changes: 3 additions & 0 deletions python/lsst/meas/astrom/astrometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

__all__ = ["AstrometryConfig", "AstrometryTask"]

from builtins import range

import lsst.pex.config as pexConfig
Expand Down
9 changes: 7 additions & 2 deletions python/lsst/meas/astrom/catalogStarSelector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from builtins import input
from builtins import object
#
# LSST Data Management System
# Copyright 2008, 2009, 2010 LSST Corporation.
Expand All @@ -21,6 +19,13 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

__all__ = ["CatalogStarSelectorConfig", "CatalogStarSelectorTask"]

from builtins import input
from builtins import object

from lsst.afw.table import SourceCatalog
from lsst.meas.algorithms import BaseStarSelectorTask, starSelectorRegistry
from lsst.pipe.base import Struct
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/meas/astrom/createMatchMetadata.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import absolute_import, division, print_function

__all__ = ["MatchMetadata", "createMatchMetadata"]

from lsst.daf.base import PropertyList
from lsst.afw.geom import Box2D
from lsst.afw.image.utils import getDistortedWcs

__all__ = ["MatchMetadata", "createMatchMetadata"]


class MatchMetadata(PropertyList):
"""Metadata required for unpersisting a match list"""
Expand Down
4 changes: 3 additions & 1 deletion python/lsst/meas/astrom/denormalizeMatches.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import lsst.afw.table
from __future__ import absolute_import, division, print_function

__all__ = ["denormalizeMatches"]

import lsst.afw.table


def denormalizeMatches(matches, matchMeta=None):
"""Generate a denormalized Catalog of matches
Expand Down
5 changes: 2 additions & 3 deletions python/lsst/meas/astrom/directMatch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import absolute_import, division, print_function

__all__ = ["DirectMatchConfig", "DirectMatchTask"]

from lsst.pex.config import Config, Field, ConfigurableField
from lsst.pipe.base import Task, Struct
from .createMatchMetadata import MatchMetadata
Expand All @@ -9,9 +11,6 @@
from lsst.afw.geom import arcseconds


__all__ = ["DirectMatchConfig", "DirectMatchTask"]


class DirectMatchConfig(Config):
"""Configuration for DirectMatchTask"""
refObjLoader = ConfigurableField(target=LoadIndexedReferenceObjectsTask, doc="Load reference objects")
Expand Down
5 changes: 3 additions & 2 deletions python/lsst/meas/astrom/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

__all__ = ["displayAstrometry", "plotAstrometry"]

from builtins import zip
import math

Expand All @@ -29,8 +32,6 @@
from lsst.afw.image import ExposureF
from lsst.afw.table import Point2DKey

__all__ = ["displayAstrometry", "plotAstrometry"]


def displayAstrometry(refCat=None, sourceCat=None, distortedCentroidKey=None, bbox=None, exposure=None,
matches=None, frame=1, title="", pause=True):
Expand Down
5 changes: 3 additions & 2 deletions python/lsst/meas/astrom/fitTanSipWcs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from __future__ import absolute_import, division, print_function

__all__ = ["FitTanSipWcsTask", "FitTanSipWcsConfig"]

from builtins import zip
from builtins import range

Expand All @@ -13,8 +16,6 @@
from .setMatchDistance import setMatchDistance
from .sip import makeCreateWcsWithSip

__all__ = ["FitTanSipWcsTask", "FitTanSipWcsConfig"]


class FitTanSipWcsConfig(pexConfig.Config):
order = pexConfig.RangeField(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from __future__ import absolute_import, division, print_function

__all__ = ["matchOptimisticB", "MatchOptimisticBTask", "MatchOptimisticBConfig", "SourceInfo"]

from builtins import range
from builtins import object
import math
Expand All @@ -13,8 +16,6 @@
from ..setMatchDistance import setMatchDistance
from . import matchOptimisticB, MatchOptimisticBControl

__all__ = ["matchOptimisticB", "MatchOptimisticBTask", "MatchOptimisticBConfig", "SourceInfo"]


class MatchOptimisticBConfig(pexConfig.Config):
"""Configuration for MatchOptimisticBTask
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/meas/astrom/ref_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#
from __future__ import absolute_import, division, print_function

__all__ = ['RefMatchConfig', 'RefMatchTask']

from lsst.afw.image.utils import getDistortedWcs
import lsst.afw.geom as afwGeom
import lsst.afw.math as afwMath
Expand All @@ -31,8 +33,6 @@
from . import makeMatchStatistics
from .createMatchMetadata import createMatchMetadata

__all__ = ['RefMatchConfig', 'RefMatchTask']


class RefMatchConfig(pexConfig.Config):
matcher = pexConfig.ConfigurableField(
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/meas/astrom/setMatchDistance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import, division, print_function
#
# LSST Data Management System
# Copyright 2008, 2009, 2010 LSST Corporation.
Expand All @@ -20,11 +19,12 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#

import lsst.afw.table as afwTable
from __future__ import absolute_import, division, print_function

__all__ = ["setMatchDistance"]

import lsst.afw.table as afwTable


def setMatchDistance(matches):
"""Set the distance field of the matches in a match list to the distance in radians on the sky
Expand Down
7 changes: 5 additions & 2 deletions python/lsst/meas/astrom/sip/cleanBadPoints.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import
from builtins import range
#
# LSST Data Management System
# Copyright 2008, 2009, 2010 LSST Corporation.
Expand All @@ -21,6 +19,11 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

__all__ = ["clean"]

from builtins import range

import numpy as np

Expand Down
10 changes: 8 additions & 2 deletions python/lsst/meas/astrom/sip/genDistortedImage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function
from builtins import range
#
# LSST Data Management System
# Copyright 2008, 2009, 2010 LSST Corporation.
Expand All @@ -21,6 +19,14 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

__all__ = ["noDistort", "linearXDistort", "quadraticDistortX",
"cubicDistortX", "manyTermX", "crossTerms1",
"crossTerms2", "crossTerms3", "quadraticDistort",
"T2DistortX", "T2DistortX"]

from builtins import range

import math

Expand Down
2 changes: 2 additions & 0 deletions python/lsst/meas/astrom/sip/sourceMatchStatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

__all__ = ["sourceMatchStatistics"]

import numpy as np

Expand Down
6 changes: 5 additions & 1 deletion python/lsst/meas/astrom/verifyWcs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from builtins import range
#
# LSST Data Management System
# Copyright 2008, 2009, 2010 LSST Corporation.
Expand All @@ -20,6 +19,11 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

__all__ = ["checkMatches"]

from builtins import range

import numpy as np

Expand Down
2 changes: 2 additions & 0 deletions tests/testDenormalizeMatches.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import absolute_import, division, print_function

import sys
import unittest

Expand Down
12 changes: 6 additions & 6 deletions tests/testDirectMatch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function

#
Expand Down Expand Up @@ -26,7 +25,8 @@
import os
import sys
import unittest
import numpy

import numpy as np

import lsst.utils.tests
import lsst.meas.astrom
Expand All @@ -42,7 +42,7 @@ class DirectMatchTestCase(lsst.utils.tests.TestCase):
"""Tests for lsst.meas.astrom.DirectMatchTask"""

def setUp(self):
numpy.random.seed(12345)
np.random.seed(12345)
self.butler = Butler(RefCatDir)
refObjLoader = LoadIndexedReferenceObjectsTask(butler=self.butler)
center = lsst.afw.coord.IcrsCoord(215.5*lsst.afw.geom.degrees, 53.0*lsst.afw.geom.degrees)
Expand Down Expand Up @@ -81,9 +81,9 @@ def testWithNoise(self):
offset = (0.1*lsst.afw.geom.arcseconds).asRadians()
num = len(references)
ra, dec = references["coord_ra"], references["coord_dec"]
cosDec = numpy.cos(dec.mean())
ra += offset/cosDec*numpy.random.uniform(-1.0, 1.0, num)
dec += offset*numpy.random.uniform(-1.0, 1.0, num)
cosDec = np.cos(dec.mean())
ra += offset/cosDec*np.random.uniform(-1.0, 1.0, num)
dec += offset*np.random.uniform(-1.0, 1.0, num)
self.checkMatching(references)


Expand Down
4 changes: 1 addition & 3 deletions tests/testFitTanSipWcsTask.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

# LSST Data Management System
# Copyright 2008, 2009, 2010 LSST Corporation.
#
Expand Down Expand Up @@ -31,7 +29,7 @@
# both the testing class and the implementation class allowing test
# discovery to only run tests found in the subclasses.

from __future__ import print_function
from __future__ import absolute_import, division, print_function
from builtins import range
from builtins import object
import math
Expand Down
6 changes: 3 additions & 3 deletions tests/testJoinMatchListWithCatalog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from builtins import range
#!/usr/bin/env python
#
# LSST Data Management System
#
Expand All @@ -22,6 +20,9 @@
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

from builtins import range
import os
import unittest

Expand Down Expand Up @@ -55,7 +56,6 @@ def setUp(self):
mi.assign(smallExposure.getMaskedImage(), smallExposure.getBBox())

logLevel = Log.INFO
#logLevel = Log.DEBUG
refCatDir = os.path.join(testDir, "data", "sdssrefcat")
butler = Butler(refCatDir)
refObjLoader = LoadIndexedReferenceObjectsTask(butler=butler)
Expand Down
5 changes: 1 addition & 4 deletions tests/testLsf1d.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

#
# LSST Data Management System
# Copyright 2008, 2009, 2010 LSST Corporation.
Expand All @@ -21,8 +19,7 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#

from __future__ import print_function
from __future__ import absolute_import, division, print_function
from builtins import range
import unittest

Expand Down
5 changes: 1 addition & 4 deletions tests/testLsf2d.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

#
# LSST Data Management System
# Copyright 2008, 2009, 2010 LSST Corporation.
Expand All @@ -21,8 +19,7 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#

from __future__ import print_function
from __future__ import absolute_import, division, print_function
from builtins import range
import unittest

Expand Down
5 changes: 2 additions & 3 deletions tests/testMakeMatchStatistics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function
from builtins import zip
#
# LSST Data Management System
# Copyright 2015 LSST Corporation.
Expand All @@ -22,6 +19,8 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function
from builtins import zip
import unittest
import math

Expand Down
5 changes: 2 additions & 3 deletions tests/testMatchOptimisticB.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function

#
# LSST Data Management System
# Copyright 2008, 2009, 2010 LSST Corporation.
Expand All @@ -22,6 +19,8 @@
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
from __future__ import absolute_import, division, print_function

import math
import os
import unittest
Expand Down

0 comments on commit eeb9614

Please sign in to comment.