22 """Python helpers for pybind11 wrapping of Transform classes and subclasses 24 .. _pybind11_transform_classes: 26 Transform Classes and Subclasses 27 -------------------------------- 29 Transforms are instances of 30 lsst::afw::geom::Transform<FromEndpoint, ToEndpoint> 31 and subclasses, such as lsst::afw::geom::SkyWcs. 33 In Python the templated Transform classes have names such as 34 `lsst.afw.geom.TransformSpherePointToPoint2` for 35 `lsst::afw::geom::Transform<SpherePointEndpoint, Point2Endpoint>` 38 from __future__
import absolute_import, division, print_function
40 __all__ = [
"addTransformMethods",
"reduceTransform",
"transformRegistry"]
45 transformRegistry = {}
50 matrix = self._getJacobian(x)
51 matrix.shape = (self.toEndpoint.nAxes,
52 self.fromEndpoint.nAxes)
56 def then(self, next, simplify=True):
57 """Concatenate two transforms 59 The result of A.then(B) is is C(x) = B(A(x)) 61 if self.toEndpoint == next.fromEndpoint:
62 return self._then(next, simplify=simplify)
65 "Cannot concatenate %r and %r: endpoints do not match." 70 """Unpickle a Transform object 82 The unpickled Transform. 84 return cls.readString(state)
88 """Pickle a Transform object 90 This provides the `__reduce__` implementation for a Transform. 92 return unpickleTransform, (type(transform), transform.writeString())
96 """Add pure python methods to the specified Transform class, and register 97 the class in `transformRegistry` 99 All :ref:`_pybind11_transform_classes` must call this function. 103 cls : :ref:`_pybind11_transform_classes` 104 A Transform class or subclass, e.g. 105 `lsst.afw.geom.TransformPoint2ToSpherePoint` 107 global transformRegistry
108 className = cls.__name__
109 if className
in transformRegistry:
110 raise RuntimeError(
"Class %r=%s already registered; cannot register class %s" %
111 (className, transformRegistry[className], cls))
112 transformRegistry[cls.__name__] = cls
113 cls.getJacobian = getJacobian
115 cls.__reduce__ = reduceTransform