Skip to content
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

DM-10292: The FrameSet returned by Transform.getFrameSet can change the contained FrameSet in Python #221

Merged
merged 1 commit into from
Apr 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion python/lsst/afw/geom/transform/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ void declareTransform(py::module &mod, std::string const &fromName, std::string
cls.def("hasInverse", &Class::hasInverse);

cls.def("getFromEndpoint", &Class::getFromEndpoint);
cls.def("getFrameSet", &Class::getFrameSet);
// Return a copy of the contained FrameSet in order to assure changing the returned FrameSet
// will not affect the contained FrameSet (since Python ignores constness)
cls.def("getFrameSet", [](Class const &self) {
return self.getFrameSet()->copy();
});
cls.def("getToEndpoint", &Class::getToEndpoint);

cls.def("tranForward", (ToArray (Class::*)(FromArray const &) const) & Class::tranForward, "array"_a);
Expand Down
13 changes: 13 additions & 0 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,19 @@ def testTransforms(self):
self.checkOf(fromName, midName, toName)
self.checkOfChaining()

def testFrameSetIndependence(self):
"""Test that the FrameSet returned by getFrameSet is independent of the contained FrameSet
"""
baseFrame = makeGoodFrame("Generic", 2)
currFrame = makeGoodFrame("Generic", 2)
initialFrameSet = makeFrameSet(baseFrame, currFrame)
initialIdent = "Initial Ident"
initialFrameSet.setIdent(initialIdent)
transform = afwGeom.TransformGenericToGeneric(initialFrameSet)
extractedFrameSet = transform.getFrameSet()
extractedFrameSet.setIdent("Extracted Ident")
self.assertEqual(initialIdent, transform.getFrameSet().getIdent())


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