예제 #1
0
    def testConstructors(self):
        #test 2-d
        e1 = geom.Point2I(1, 2)
        e2 = geom.Point2I(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point2D(1.2, 3.4)
        e2 = geom.Point2D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point2I(1, 3)
        e2 = geom.Point2D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        #test 3-d
        e1 = geom.Point3I(1, 2, 3)
        e2 = geom.Point3I(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point3D(1.2, 3.4, 5.6)
        e2 = geom.Point3D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point3I(1, 2, 3)
        e2 = geom.Point3D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        #test rounding to integral coordinates
        e1 = geom.Point2D(1.2, 3.4)
        e2 = geom.Point2I(e1)
        self.assertClose(tuple([math.floor(v + 0.5) for v in e1]), tuple(e2))

        e1 = geom.Point3D(1.2, 3.4, 5.6)
        e2 = geom.Point3I(e1)
        self.assertClose(tuple([math.floor(v + 0.5) for v in e1]), tuple(e2))
예제 #2
0
    def testCoordAliases(self):
        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)
예제 #3
0
 def setUp(self):
     x, y, z = 1, 1, 1
     self.data = afwGeom.Point3I(x, y, z)
예제 #4
0
    def testConstructors(self):
        #test extent from extent 2-d
        e1 = geom.Extent2I(1, 2)
        e2 = geom.Extent2I(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Extent2D(1.2, 3.4)
        e2 = geom.Extent2D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Extent2I(1, 2)
        e2 = geom.Extent2D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        #test extent from extent 3-d
        e1 = geom.Extent3I(1, 2, 3)
        e2 = geom.Extent3I(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Extent3D(1.2, 3.4, 5.6)
        e2 = geom.Extent3D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Extent3I(1, 2, 3)
        e2 = geom.Extent3D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        #test extent from point 2-d
        e1 = geom.Point2I(1, 2)
        e2 = geom.Extent2I(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point2D(1.2, 3.4)
        e2 = geom.Extent2D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point2I(1, 2)
        e2 = geom.Extent2D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        #test extent from point 3-d
        e1 = geom.Point3I(1, 2, 3)
        e2 = geom.Extent3I(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point3D(1.2, 3.4, 5.6)
        e2 = geom.Extent3D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point3I(1, 2, 3)
        e2 = geom.Extent3D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        #test invalid constructors
        try:
            e1 = geom.Extent2D(1.2, 3.4)
            e2 = geom.Extent2I(e1)
        except:
            pass
        else:
            self.fail("Should not allow conversion Extent2D to Extent2I")
        try:
            e1 = geom.Extent3D(1.2, 3.4, 5.6)
            e2 = geom.Extent3I(e1)
        except:
            pass
        else:
            self.fail("Should not allow conversion Extent3D to Extent3I")

        try:
            e1 = geom.Point2D(1.2, 3.4)
            e2 = geom.Extent2I(e1)
        except:
            pass
        else:
            self.fail("Should not allow conversion Point2D to Extent 2I")
        try:
            e1 = geom.Point3D(1.2, 3.4, 5.6)
            e2 = geom.Extent3I(e1)
        except:
            pass
        else:
            self.fail("Should not allow conversion Point3D to Extent3I")
예제 #5
0
    def testConstructors(self):
        # test extent from extent 2-d
        e1 = geom.Extent2I(1, 2)
        e2 = geom.Extent2I(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Extent2D(1.2, 3.4)
        e2 = geom.Extent2D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Extent2I(1, 2)
        e2 = geom.Extent2D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        # test extent from extent 3-d
        e1 = geom.Extent3I(1, 2, 3)
        e2 = geom.Extent3I(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Extent3D(1.2, 3.4, 5.6)
        e2 = geom.Extent3D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Extent3I(1, 2, 3)
        e2 = geom.Extent3D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        # test extent from point 2-d
        e1 = geom.Point2I(1, 2)
        e2 = geom.Extent2I(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Point2D(1.2, 3.4)
        e2 = geom.Extent2D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Point2I(1, 2)
        e2 = geom.Extent2D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        # test extent from point 3-d
        e1 = geom.Point3I(1, 2, 3)
        e2 = geom.Extent3I(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Point3D(1.2, 3.4, 5.6)
        e2 = geom.Extent3D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Point3I(1, 2, 3)
        e2 = geom.Extent3D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        # test invalid constructors
        e1 = geom.Extent2D(1.2, 3.4)
        with self.assertRaises(TypeError):
            e2 = geom.Extent2I(e1)

        e1 = geom.Extent3D(1.2, 3.4, 5.6)
        with self.assertRaises(TypeError):
            e2 = geom.Extent3I(e1)

        e1 = geom.Point2D(1.2, 3.4)
        with self.assertRaises(TypeError):
            e2 = geom.Extent2I(e1)

        e1 = geom.Point3D(1.2, 3.4, 5.6)
        with self.assertRaises(TypeError):
            e2 = geom.Extent3I(e1)