[SciPy-Dev] ndimage and from __future__ import division

Stéfan van der Walt stefan at sun.ac.za
Tue Apr 27 10:30:12 EDT 2010


Hi Chris

On 23 April 2010 03:31, Christopher Hanley <chanley at stsci.edu> wrote:
> In preparation for our next release we are preparing to support Python
> 2.6 with __future__ division.  Since I was one of the last STScI folks
> to touch scipy I was tasked with looking into how ndimage would work
> with "from __future__ import division" added.   All of the existing
> tests pass with the exception of 2:

I looked through all the division operators in ndimage, and it seems
Peter consistently used "//" for integer division.  Since the C code
is not influenced, you should be safe.

The only case I wasn't sure about is this line from morphology.py:

    pos = [ni * (structure.shape[ii] / 2) for ii in range(len(shape))]

Since you now get two errors, I suspect the problem might be with the
way the unit tests are constructed (I haven't checked how they used
division).

Regards
Stéfan



More information about the SciPy-Dev mailing list