-
Notifications
You must be signed in to change notification settings - Fork 272
MRG: refactor for common Python 2/3 code #179
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add six.py module instead of py3k module where possible. Rely on b'' literals in Python 2.6 instead of asbytes
Adapt doctests so they run and don't leave temporary files.
Instead of print statement Use future division by default with new __future__ imports.
using six.py
Python 3 choking on the circular imports
Dipy had later and refactored copy.
For Python 3 compatibility
in favor of "key in dict"
Use six module to import BytesIO and StringIO. Remove unused StringIO import
dft and tests still using old exception syntax
list() round range(), output of map(), zip()
For iteration
Use b'' literal and io module instead.
Avoid spurious failures for b'' rather than ''
to avoid altering dict during iteration over keys, and therefore a Python 3 error.
It seems that there is some difference in the way that numpy outputs min / max values for integers, so that sometimes we were passing np.uint64 values, causing subtle or obvious errors when converting to floats.
The code should be compatible with Pythons 2 and 3
Using u'' which is a syntax error for Python 3 < 3.3
Bizarre errors with byteswapped versions of complex256, apparently only on Python 3.3, with numpy 1.7.0 - but - we'll see. Errors were in `test_arraywriters`, claiming that two complex256 arrays differing only in native, swapped endianness compared unequal. Debugging showed that numpy was finding nans in the byteswapped array, and subtraction results were odd, etc.
dft was relying on integer division - make explicit for Python 3. The Patient Name parameter was not coming back as a string, as dft appeared to expect. Maybe this changed in pydicom; in any case make str() explicit for Patient Name.
Needs pydicom >= 0.9.7. This is already the required version stated in `info.py`
Replace python 2.5 with_statement future imports with standard Python 3 future imports.
Implements the algorithm given in section 7.8.1 of PS 3.5. The manufacturer puts a 'private creator tag' in tag nos 1-xFF to give the section start of their private tag information.
Refactor get_csa_header to use new find_private_section routine. Guard against dictionaries being passed by tests by checking for private section marker before checking full dcm_data for CSA. Add tests for this check.
This file is also a Siemens mosaic file; test we detect this.
Member
Author
|
I think this one is ready to merge now. Any comments? |
Member
Author
|
Will merge tomorrow unless I hear otherwise. |
matthew-brett
added a commit
that referenced
this pull request
Jul 16, 2013
MRG: refactor for common Python 2/3 code Changes necessary to run nibabel code in Python 2 and Python 3 without running 2to3 at install time. Also remove some fancy doctest markup needed for Python < 2.6.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes necessary to run nibabel code in Python 2 and Python 3 without
running 2to3 at install time. Also remove some fancy doctest markup
needed for Python < 2.6.