nipy/nibabel — pull request #240 by matthew-brett (2014-05-22 00:50:45+00:00)
Title: MRG: add tests; error bounds for rescaling to 0

The buildbots on SPARC were giving errors for the nan2zero fill tests.

http://nipy.bic.berkeley.edu/builders/nibabel-py2.7-wheezy-sparc/builds/5/steps/shell_6/logs/stdio

This was because there was some floating point error in calculating the integer
value in the output corresponding to zero in the input.

The second commit here puts some bounds on the error and checks that the
nan2zero value in the output is within these bounds.

I also refactored the `_write_data` private routine to deal with some silliness
in reshaping, and to prevent a possible route to overwriting the input data.

I believe the code using `_write_data` never takes that route because the route
required `post_clips` to be None when `nan_fill` is not None, and this can't
happen with current logic in the `array_to_file`, but, just in case.