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-7152: Port to python 3 #83

Merged
merged 33 commits into from Aug 16, 2016
Merged

DM-7152: Port to python 3 #83

merged 33 commits into from Aug 16, 2016

Conversation

timj
Copy link
Member

@timj timj commented Aug 7, 2016

Includes some code cleanup. Not working yet.

Python 2.7 supports both and Python 3 does not support PyString.
@timj timj force-pushed the tickets/DM-7152 branch 9 times, most recently from ee8b9ad to 8837fc7 Compare August 13, 2016 01:46
@@ -176,10 +179,10 @@ def run():
)
destExposure.setWcs(destWcs)
dTime, nIter, goodPix = timeWarp(destExposure, srcExposure, warpingControl)
print "%4d %5d %8.1f %6.1f, %6.1f %7.1f %10s %8d %6.2f" % (
print("%4d %5d %8.1f %6.1f, %6.1f %7.1f %10s %8d %6.2f" % (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not using new style print formatting?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to format is not required by the Python 3 migration. In fact, use of format at all is highly contentious. I always use format in new code as I grew up with Python 3.

timj and others added 25 commits August 16, 2016 07:49
This was needed as there were some tab/space inconsistencies and
Python 3 does not like that.
These routines are not portable to python 3. Replace with
a simple regex substitution.
e.message is not supported on python3.
If lsst.display is not loadable you get a SystemError on Python3
when trying to do an import relative to it. You do not get
ImportError. Trap for both errors.

Also check that _impl attribute exists before using it. Sometimes
the close() method can be called without the object completing
initialization.
…ytes

Uses the SWIG helper function to handle python versions.
In modern python next method is named __next__. Without this
change classes can not act as iterators. Keep next around
for compatibility.
Put long ahead of int in the aliases dict so that in python3
int is mapped to I. It may be that we should keep it as L and
change the test. On Python 3 long does not exist and int is a long.
Now that future division is enabled it is important that these
divisions still return integers.
and map it to String as it behaves exactly like a string.
This does not work on Python 3:

    try:
        throw
    except as e:
        pass

    print(e)

as the "e" is not in scope outside of the exception. The exception
needs to be copied to another variable.

Do not specify a root package if we know we are trying an absolute
import.
Sometimes the object can die before it has been initialized.
This should ensure we get bytes objects in both Python 2
and Python 3. Returns PyObject None instead of void to propagate errors.
@timj
Copy link
Member Author

timj commented Aug 16, 2016

@pschella @TallJimbo Everything is read to merge except testCameraGeom has a random failure in testTransformDet because Python 3 returns dict keys in a random order and sometimes the first 3 returned are not suitable. I've asked @r-owen for comment as he wrote the test. Once we have that under control we can merge to master.

testCameraGeom's testTransformDet method only tested a subset
of detectors, and depending on which subset it tested
(which depended on the order in which dict keys were returned)
the test could fail. Fixed by testing all detectors.
@timj timj merged commit e4e5617 into master Aug 16, 2016
@ktlim ktlim deleted the tickets/DM-7152 branch August 25, 2018 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants