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

Python 3 port #50

Merged
merged 13 commits into from
Sep 17, 2017
Merged

Python 3 port #50

merged 13 commits into from
Sep 17, 2017

Conversation

senganal
Copy link
Contributor

@senganal senganal commented Oct 24, 2016

Current status: Tests pass on python 2 and python 3 (except those involving pyside imports)

TODO

  • cleanup any unintended syntax fixes.
  • Test the ui code
  • Fix broken code (missing imports and such ) (tracked in Missing imports #51)

Unfortunately, there seems to be a lot of broken code that is not being caught in the tests.. Not sure how to handle them.. Its prob. best to fix them in a separate PR and keep this focused on just the py2->3 conversion..

indices,
0,
numpy.Inf).astype(
numpy.int))
Copy link
Member

Choose a reason for hiding this comment

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

Nit: stylistically, I'd break this up into two lines with a temporary to fit in the linewidth constraints.

        indices = numpy.clip(indices, 0, numpy.Inf).astype(numpy.int)
        indices = np.atleast_1d(indices)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.. Fixed now..

Copy link
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

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

It's a bit hard to see the Python 3 changes from the PEP8-ing, but other than a few over-enthusiastic changes (presumably by automated tools), it looks fine.

I have not run the code yet.


if defaults is not None:
# If there are keywords, then slice the variable list into
# positional and keyword arguments.
kw_count = len(defaults)
args = args_ordered[:-kw_count]
kw = dict(zip(args_ordered[-kw_count:], defaults))
kw = dict(list(zip(args_ordered[-kw_count:], defaults)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need list here I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


class QuantityTraitHandler ( TraitHandler ):
class QuantityTraitHandler (TraitHandler):
Copy link
Contributor

Choose a reason for hiding this comment

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

Autopep8 misses the extra space here. You may want to do a global search-replace for this sort of thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -1,13 +1,15 @@
""" A Scalar is a Quantity object that limits data to floats.
"""

from __future__ import absolute_import
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed? Similarly in a few other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://www.python.org/dev/peps/pep-0328/#rationale-for-relative-imports

Apparently absolute imports are optional before 2.7. Given that the code works with 2.7 it is prob. not absolutely :) necessary.. but prob. good to keep until we drop support for < 2.7 ? not sure..

@senganal
Copy link
Contributor Author

t's a bit hard to see the Python 3 changes from the PEP8-ing, but other than a few over-enthusiastic changes (presumably by automated tools), it looks fine.

I am also partly to blame.. I thought this is a good opportunity to clean up some of the formatting and such..

@jonathanrocher
Copy link
Contributor

@senganal How do you feel about the status of this PR?

@senganal
Copy link
Contributor Author

@jonathanrocher Thanks for the reminder.. IIRC I had paused on this as i had not tested the traitsui related tests/code but otherwise it should be good to go.. Will do a quick run through and post an update..

@jonathanrocher
Copy link
Contributor

OK. Let me know if I can help...

@senganal
Copy link
Contributor Author

@jonathanrocher All the tests pass now on both py3 and py2 (on OSX).

@jonathanrocher
Copy link
Contributor

jonathanrocher commented Jun 28, 2017

Since there is no CI on this project, I took the time to confirm that on Py2.7 and 3.6 both on OSX. I also passed the test suite on Win-Py2.7. I tried Win-Py3.6 but am running into compiler issues (EDM doesn't seem to give me a recent enough setuptools).

@jonathanrocher
Copy link
Contributor

jonathanrocher commented Jun 28, 2017

OK, I also tested py2.7 and py3.6 on Ubuntu 16.04 and tests are passing there too. HTH.

@senganal
Copy link
Contributor Author

@jonathanrocher Thanks for testing on linux.. I have tested on both OSX and Windows (py2 and py3).

@corranwebster Comments have been addressed. I think this is good to go for now.

@senganal senganal changed the title [WIP] Python 3 port Python 3 port Jun 28, 2017
@JCorson
Copy link
Contributor

JCorson commented Aug 21, 2017

Hi all,

What is current state of the PR? I would like to get use this as a dev dependency in a project to increase Python 3 support.

Let me know if there is anything that I can do to help.

@senganal
Copy link
Contributor Author

@JCorson I think its good to go.. Requires blessing from @corranwebster
It would be good if you can test the PR and provide another datapoint just to be safe..

@JCorson
Copy link
Contributor

JCorson commented Aug 23, 2017

Thanks @senganal. FWIW I have tested on Windows Python 2.7 and 3.6. All tests passing.

@jonathanrocher
Copy link
Contributor

@corranwebster Want to give a final blessing on this?

@corranwebster
Copy link
Contributor

Go for it (this was totally off my radar).

@jonathanrocher
Copy link
Contributor

Already then...

@jonathanrocher jonathanrocher merged commit 974d7e9 into master Sep 17, 2017
@jonathanrocher jonathanrocher deleted the feature/python3_port branch September 17, 2017 03:29
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