Skip to content

Conversation

@matthew-brett
Copy link
Member

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.

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.
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()
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.
@matthew-brett
Copy link
Member Author

I think this one is ready to merge now. Any comments?

@matthew-brett
Copy link
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.
@matthew-brett matthew-brett merged commit 632dc2c into nipy:master Jul 16, 2013
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.

1 participant