Skip to content

Commit

Permalink
Issue deprecation warning for lsst.geom forwards
Browse files Browse the repository at this point in the history
Only warns on classes and not constants.
  • Loading branch information
timj committed Jul 23, 2019
1 parent 7ce6275 commit 5d1ad82
Show file tree
Hide file tree
Showing 2 changed files with 193 additions and 32 deletions.
136 changes: 136 additions & 0 deletions python/lsst/afw/geom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,145 @@
"""Application Framework geometry code including Point, Extent, and ellipses
"""

from lsst.utils import deprecate_pybind11

# for backwards compatibility make lsst.geom public symbols available in lsst.afw.geom
from lsst.geom import *

# But we deprecate the usages of these aliases
# Constants (like geom.PI) and units (geom.arcseconds) can not be wrapped
# by deprecate_pybind11.
AffineTransform = deprecate_pybind11(AffineTransform,
reason="Replaced by lsst.geom.AffineTransform (will be removed before the release of v20.0)",
category=FutureWarning)
Angle = deprecate_pybind11(Angle,
reason="Replaced by lsst.geom.Angle (will be removed before the release of v20.0)",
category=FutureWarning)
AngleUnit = deprecate_pybind11(AngleUnit,
reason="Replaced by lsst.geom.AngleUnit (will be removed before the release of v20.0)",
category=FutureWarning)
Box2D = deprecate_pybind11(Box2D,
reason="Replaced by lsst.geom.Box2D (will be removed before the release of v20.0)",
category=FutureWarning)
Box2I = deprecate_pybind11(Box2I,
reason="Replaced by lsst.geom.Box2I (will be removed before the release of v20.0)",
category=FutureWarning)
BoxD = deprecate_pybind11(BoxD,
reason="Replaced by lsst.geom.BoxD (will be removed before the release of v20.0)",
category=FutureWarning)
BoxI = deprecate_pybind11(BoxI,
reason="Replaced by lsst.geom.BoxI (will be removed before the release of v20.0)",
category=FutureWarning)

CoordinateExpr = deprecate_pybind11(CoordinateExpr,
reason="Replaced by lsst.geom.CoordinateExpr (will be removed before the release of v20.0)",
category=FutureWarning)
CoordinateExpr2 = deprecate_pybind11(CoordinateExpr2,
reason="Replaced by lsst.geom.CoordinateExpr2 (will be removed before the release of v20.0)",
category=FutureWarning)
CoordinateExpr3 = deprecate_pybind11(CoordinateExpr3,
reason="Replaced by lsst.geom.CoordinateExpr3 (will be removed before the release of v20.0)",
category=FutureWarning)
Extent = deprecate_pybind11(Extent,
reason="Replaced by lsst.geom.Extent (will be removed before the release of v20.0)",
category=FutureWarning)
Extent2D = deprecate_pybind11(Extent2D,
reason="Replaced by lsst.geom.Extent2D (will be removed before the release of v20.0)",
category=FutureWarning)
Extent2I = deprecate_pybind11(Extent2I,
reason="Replaced by lsst.geom.Extent2I (will be removed before the release of v20.0)",
category=FutureWarning)
Extent3D = deprecate_pybind11(Extent3D,
reason="Replaced by lsst.geom.Extent3D (will be removed before the release of v20.0)",
category=FutureWarning)
Extent3I = deprecate_pybind11(Extent3I,
reason="Replaced by lsst.geom.Extent3I (will be removed before the release of v20.0)",
category=FutureWarning)
ExtentBase2D = deprecate_pybind11(ExtentBase2D,
reason="Replaced by lsst.geom.ExtentBase2D (will be removed before the release of v20.0)",
category=FutureWarning)
ExtentBase2I = deprecate_pybind11(ExtentBase2I,
reason="Replaced by lsst.geom.ExtentBase2I (will be removed before the release of v20.0)",
category=FutureWarning)
ExtentBase3D = deprecate_pybind11(ExtentBase3D,
reason="Replaced by lsst.geom.ExtentBase3D (will be removed before the release of v20.0)",
category=FutureWarning)
ExtentBase3I = deprecate_pybind11(ExtentBase3I, reason="Replaced by lsst.geom.ExtentBase3I (will be removed before the release of v20.0)",
category=FutureWarning)
ExtentD = deprecate_pybind11(ExtentD,
reason="Replaced by lsst.geom.ExtentD (will be removed before the release of v20.0)",
category=FutureWarning)
ExtentI = deprecate_pybind11(ExtentI,
reason="Replaced by lsst.geom.ExtentI (will be removed before the release of v20.0)",
category=FutureWarning)
LinearTransform = deprecate_pybind11(LinearTransform,
reason="Replaced by lsst.geom.LinearTransform (will be removed before the release of v20.0)",
category=FutureWarning)
Point = deprecate_pybind11(Point,
reason="Replaced by lsst.geom.Point (will be removed before the release of v20.0)",
category=FutureWarning)
Point2D = deprecate_pybind11(Point2D,
reason="Replaced by lsst.geom.Point2D (will be removed before the release of v20.0)",
category=FutureWarning)
Point2I = deprecate_pybind11(Point2I,
reason="Replaced by lsst.geom.Point2I (will be removed before the release of v20.0)",
category=FutureWarning)
Point3D = deprecate_pybind11(Point3D,
reason="Replaced by lsst.geom.Point3D (will be removed before the release of v20.0)",
category=FutureWarning)
Point3I = deprecate_pybind11(Point3I,
reason="Replaced by lsst.geom.Point3I (will be removed before the release of v20.0)",
category=FutureWarning)
PointBase2D = deprecate_pybind11(PointBase2D,
reason="Replaced by lsst.geom.PointBase2D (will be removed before the release of v20.0)",
category=FutureWarning)
PointBase2I = deprecate_pybind11(PointBase2I,
reason="Replaced by lsst.geom.PointBase2I (will be removed before the release of v20.0)",
category=FutureWarning)
PointBase3D = deprecate_pybind11(PointBase3D, reason="Replaced by lsst.geom.PointBase3D (will be removed before the release of v20.0)",
category=FutureWarning)
PointBase3I = deprecate_pybind11(PointBase3I,
reason="Replaced by lsst.geom.PointBase3I (will be removed before the release of v20.0)",
category=FutureWarning)
PointD = deprecate_pybind11(PointD,
reason="Replaced by lsst.geom.PointD (will be removed before the release of v20.0)",
category=FutureWarning)
PointI = deprecate_pybind11(PointI,
reason="Replaced by lsst.geom.PointI (will be removed before the release of v20.0)",
category=FutureWarning)
SpherePoint = deprecate_pybind11(SpherePoint,
reason="Replaced by lsst.geom.SpherePoint (will be removed before the release of v20.0)",
category=FutureWarning)
arcsecToRad = deprecate_pybind11(arcsecToRad,
reason="Replaced by lsst.geom.arcsecToRad (will be removed before the release of v20.0)",
category=FutureWarning)
averageSpherePoint = deprecate_pybind11(averageSpherePoint,
reason="Replaced by lsst.geom.averageSpherePoint (will be removed before the release of v20.0)",
category=FutureWarning)
degToRad = deprecate_pybind11(degToRad,
reason="Replaced by lsst.geom.degToRad (will be removed before the release of v20.0)",
category=FutureWarning)
isAngle = deprecate_pybind11(isAngle,
reason="Replaced by lsst.geom.isAngle (will be removed before the release of v20.0)",
category=FutureWarning)
makeAffineTransformFromTriple = deprecate_pybind11(makeAffineTransformFromTriple,
reason="Replaced by lsst.geom.makeAffineTransformFromTriple (will be removed before the release of v20.0)",
category=FutureWarning)
masToRad = deprecate_pybind11(masToRad,
reason="Replaced by lsst.geom.masToRad (will be removed before the release of v20.0)",
category=FutureWarning)
radToArcsec = deprecate_pybind11(radToArcsec,
reason="Replaced by lsst.geom.radToArcsec (will be removed before the release of v20.0)",
category=FutureWarning)
radToDeg = deprecate_pybind11(radToDeg,
reason="Replaced by lsst.geom.radToDeg (will be removed before the release of v20.0)",
category=FutureWarning)
radToMas = deprecate_pybind11(radToMas,
reason="Replaced by lsst.geom.radToMas (will be removed before the release of v20.0)",
category=FutureWarning)

del deprecate_pybind11

from .ellipses import Ellipse, Quadrupole
from .polygon import *
from .span import *
Expand Down
89 changes: 57 additions & 32 deletions tests/test_geomAliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
class GeomAliasesTestCase(lsst.utils.tests.TestCase):

def testAngleAliases(self):
self.assertIs(afwGeom.Angle, lsst.geom.Angle)
self.assertIs(afwGeom.AngleUnit, lsst.geom.AngleUnit)
with self.assertWarns(FutureWarning):
self.assertEqual(afwGeom.Angle(1), lsst.geom.Angle(1))

self.assertIs(afwGeom.radians, lsst.geom.radians)
self.assertIs(afwGeom.degrees, lsst.geom.degrees)
Expand All @@ -46,40 +46,65 @@ def testAngleAliases(self):
self.assertIs(afwGeom.INVSQRTPI, lsst.geom.INVSQRTPI)
self.assertIs(afwGeom.ROOT2, lsst.geom.ROOT2)

self.assertIs(afwGeom.degToRad, lsst.geom.degToRad)
self.assertIs(afwGeom.radToDeg, lsst.geom.radToDeg)
self.assertIs(afwGeom.radToArcsec, lsst.geom.radToArcsec)
self.assertIs(afwGeom.radToMas, lsst.geom.radToMas)
self.assertIs(afwGeom.arcsecToRad, lsst.geom.arcsecToRad)
self.assertIs(afwGeom.masToRad, lsst.geom.masToRad)
with self.assertWarns(FutureWarning):
self.assertEqual(afwGeom.degToRad(1), lsst.geom.degToRad(1))
with self.assertWarns(FutureWarning):
self.assertEqual(afwGeom.radToDeg(1), lsst.geom.radToDeg(1))
with self.assertWarns(FutureWarning):
self.assertEqual(afwGeom.radToArcsec(1), lsst.geom.radToArcsec(1))
with self.assertWarns(FutureWarning):
self.assertEqual(afwGeom.radToMas(1), lsst.geom.radToMas(1))
with self.assertWarns(FutureWarning):
self.assertEqual(afwGeom.arcsecToRad(1), lsst.geom.arcsecToRad(1))
with self.assertWarns(FutureWarning):
self.assertEqual(afwGeom.masToRad(1), lsst.geom.masToRad(1))

def testCoordAliases(self):
self.assertIs(afwGeom.ExtentI, lsst.geom.ExtentI)
self.assertIs(afwGeom.Extent2I, lsst.geom.Extent2I)
self.assertIs(afwGeom.Extent3I, lsst.geom.Extent3I)

self.assertIs(afwGeom.ExtentD, lsst.geom.ExtentD)
self.assertIs(afwGeom.Extent2D, lsst.geom.Extent2D)
self.assertIs(afwGeom.Extent3D, lsst.geom.Extent3D)

self.assertIs(afwGeom.PointI, lsst.geom.PointI)
self.assertIs(afwGeom.Point2I, lsst.geom.Point2I)
self.assertIs(afwGeom.Point3I, lsst.geom.Point3I)

self.assertIs(afwGeom.PointD, lsst.geom.PointD)
self.assertIs(afwGeom.Point2D, lsst.geom.Point2D)
self.assertIs(afwGeom.Point3D, lsst.geom.Point3D)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.ExtentI(), lsst.geom.ExtentI)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.Extent2I(), lsst.geom.Extent2I)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.Extent3I(), lsst.geom.Extent3I)

with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.ExtentD(), lsst.geom.ExtentD)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.Extent2D(), lsst.geom.Extent2D)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.Extent3D(), lsst.geom.Extent3D)

with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.PointI(), lsst.geom.PointI)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.Point2I(), lsst.geom.Point2I)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.Point3I(), lsst.geom.Point3I)

with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.PointD(), lsst.geom.PointD)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.Point2D(), lsst.geom.Point2D)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.Point3D(), lsst.geom.Point3D)

def testOtherAliases(self):
self.assertIs(afwGeom.BoxI, lsst.geom.BoxI)
self.assertIs(afwGeom.BoxI, lsst.geom.Box2I)
self.assertIs(afwGeom.BoxD, lsst.geom.BoxD)
self.assertIs(afwGeom.BoxD, lsst.geom.Box2D)

self.assertIs(afwGeom.SpherePoint, lsst.geom.SpherePoint)

self.assertIs(afwGeom.AffineTransform, lsst.geom.AffineTransform)
self.assertIs(afwGeom.LinearTransform, lsst.geom.LinearTransform)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.BoxI(), lsst.geom.BoxI)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.BoxI(), lsst.geom.Box2I)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.BoxD(), lsst.geom.BoxD)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.BoxD(), lsst.geom.Box2D)

with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.SpherePoint(), lsst.geom.SpherePoint)

with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.AffineTransform(), lsst.geom.AffineTransform)
with self.assertWarns(FutureWarning):
self.assertIsInstance(afwGeom.LinearTransform(), lsst.geom.LinearTransform)


class MemoryTester(lsst.utils.tests.MemoryTestCase):
Expand Down

0 comments on commit 5d1ad82

Please sign in to comment.