Skip to content

Commit

Permalink
Merge pull request #377 from effigies/candidate2.0.2
Browse files Browse the repository at this point in the history
REL: Bugfix release 2.0.2
  • Loading branch information
effigies committed Nov 23, 2015
2 parents 1287aaf + 1eca265 commit 8522d9d
Show file tree
Hide file tree
Showing 38 changed files with 558 additions and 1,516 deletions.
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ Basile Pinsard <[email protected]> bpinsard <[email protected]>
Nguyen, Ly <[email protected]> lxn2 <[email protected]>
Ben Cipollini <[email protected]> Ben Cipollini <[email protected]>
Chris Markiewicz <[email protected]> Christopher J. Markiewicz <[email protected]>
Chris Markiewicz <[email protected]> Christopher J. Markiewicz <[email protected]>
Chris Markiewicz <[email protected]> Chris Johnson <[email protected]>
39 changes: 36 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ env:
global:
- DEPENDS="numpy scipy matplotlib h5py"
- PYDICOM=1
- INSTALL_TYPE="setup"
python:
- 2.6
- 3.2
- 3.3
- 3.4
- 3.5
matrix:
include:
- python: 2.7
Expand All @@ -26,20 +28,37 @@ matrix:
- python: 2.7
env:
- DEPENDS="numpy==1.5.1 pydicom==0.9.7"
# pydicom 1.0 (currently unreleased)
- python: 2.7
env:
- PYDICOM="v1.0"
# Documentation doctests
- python: 2.7
env:
- DOC_DOC_TEST=1
- python: 2.7
env:
- INSTALL_TYPE=sdist
- python: 2.7
env:
- INSTALL_TYPE=wheel
- python: 2.7
env:
- INSTALL_TYPE=requirements
before_install:
- source tools/travis_tools.sh
- virtualenv --python=python venv
- source venv/bin/activate
- python --version # just to check
- pip install nose # always
- pip install --no-index -f http://travis-wheels.scikit-image.org $DEPENDS
- pip install -U pip # upgrade to latest pip to find 3.5 wheels
- retry pip install nose # always
- wheelhouse_pip_install $DEPENDS
# pydicom <= 0.9.8 doesn't install on python 3
- if [ "${TRAVIS_PYTHON_VERSION:0:1}" == "2" ]; then
if [ "$PYDICOM" == "1" ]; then
pip install pydicom;
elif [ "$PYDICOM" == "v1.0" ]; then
pip install git+https://github.com/darcymason/pydicom.git@43f278444d5cb2e4648135d3edcd430c363c6975;
fi
fi
- if [ "${COVERAGE}" == "1" ]; then
Expand All @@ -51,7 +70,21 @@ before_install:
fi
# command to install dependencies
install:
- python setup.py install
- |
if [ "$INSTALL_TYPE" == "setup" ]; then
python setup.py install
elif [ "$INSTALL_TYPE" == "sdist" ]; then
python setup_egg.py egg_info # check egg_info while we're here
python setup_egg.py sdist
wheelhouse_pip_install dist/*.tar.gz
elif [ "$INSTALL_TYPE" == "wheel" ]; then
pip install wheel
python setup_egg.py bdist_wheel
wheelhouse_pip_install dist/*.whl
elif [ "$INSTALL_TYPE" == "requirements" ]; then
wheelhouse_pip_install -r requirements.txt
python setup.py install
fi
# Point to nibabel data directory
- export NIBABEL_DATA_DIR="$PWD/nibabel-data"
# command to run tests, e.g. python setup.py test
Expand Down
19 changes: 19 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ and Stephan Gerhard (SG).

References like "pr/298" refer to github pull request numbers.

* 2.0.2 (Monday 23 November 2015)

* Fix for integer overflow on large images (pr/325) (MB);
* Fix for Freesurfer nifti files with unusual dimensions (pr/332) (Chris
Markiewicz);
* Fix typos on benchmarks and tests (pr/336, pr/340, pr/347) (Chris
Markiewicz);
* Fix Windows install script (pr/339) (MB);
* Support for Python 3.5 (pr/363) (MB) and numpy 1.10 (pr/358) (Chris
Markiewicz);
* Update pydicom imports to permit version 1.0 (pr/379) (Chris Markiewicz);
* Workaround for Python 3.5.0 gzip regression (pr/383) (Ben Cipollini).
* tripwire.TripWire object now raises subclass of AttributeError when trying
to get an attribute, rather than a direct subclass of Exception. This
prevents Python 3.5 triggering the tripwire when doing inspection prior to
running doctests.
* Minor API change for tripwire.TripWire object; code that checked for
AttributeError will now also catch TripWireError.

* 2.0.1 (Saturday 27 June 2015)

Contributions from Ben Cipollini, Chris Markiewicz, Alexandre Gramfort,
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include AUTHOR COPYING Makefile* MANIFEST.in setup* README.*
include Changelog TODO
include Changelog TODO requirements.txt
recursive-include doc *
recursive-include bin *
recursive-include tools *
Expand Down
32 changes: 32 additions & 0 deletions doc/source/devel/advanced_testing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.. -*- mode: rst -*-
.. ex: set sts=4 ts=4 sw=4 et tw=79:
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
#
# See COPYING file distributed along with the NiBabel package for the
# copyright and license terms.
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
.. _advanced_testing:

************
Advanced Testing
************

Setup
-----

Before running advanced tests, please update all submodules of nibabel, by running ``git submodule update --init``


Long-running tests
------------------

Long-running tests are not enabled by default, and can be resource-intensive. To run these tests:

* Set environment variable ``NIPY_EXTRA_TESTS=slow``
* Run ``nosetests``.

Note that some tests may require a machine with >4GB of RAM.

.. include:: ../links_names.txt
1 change: 1 addition & 0 deletions doc/source/devel/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Developer documentation page
add_image_format
devdiscuss
make_release
advanced_testing
6 changes: 2 additions & 4 deletions doc/source/devel/make_release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,9 @@ Release checklist
* Check on different platforms, particularly windows and PPC. Look at the
`nipy buildbot`_ automated test runs for this.

* Check the documentation doctests::
* Check the documentation doctests (forcing Python 2)::

cd doc
make doctest
cd ..
make -C doc doctest SPHINXBUILD="python $(which sphinx-build)"

This should also be tested by `nibabel on travis`_.

Expand Down
5 changes: 2 additions & 3 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ contributed code and discussion (in rough order of appearance):
* Bago Amirbekian
* Brendan Moloney
* Félix C. Morency
* Chris Johnson
* Chris Markiewicz
* JB Poline
* Nolan Nichols
* Nguyen, Ly
Expand All @@ -61,8 +61,7 @@ contributed code and discussion (in rough order of appearance):
* Demian Wassermann
* Philippe Gervais
* Justin Lecher
* Ben Cippolini
* Chris Markiewicz
* `Ben Cipollini`_
* Clemens C. C. Bauer

License reprise
Expand Down
11 changes: 10 additions & 1 deletion doc/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ Just install the modules by invoking::
If sudo is not configured (or even installed) you might have to use
``su`` instead.

Now fire up Python and try importing the module to see if everything is fine.

Validating your install
-----------------------

For a basic test of your installation, fire up Python and try importing the module to see if everything is fine.
It should look something like this::

Python 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35)
Expand All @@ -123,4 +127,9 @@ It should look something like this::
>>> import nibabel
>>>


To run the nibabel test suite, from the terminal run ``nosetests nibabel`` or ``python -c "import nibabel; nibabel.test()``.

To run an extended test suite that validates ``nibabel`` for long-running and resource-intensive cases, please see :ref:`advanced_testing`.

.. include:: links_names.txt
3 changes: 2 additions & 1 deletion doc/source/links_names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
and name substitutions. It may be included in many files,
therefore it should only contain link targets and name
substitutions. Try grepping for "^\.\. _" to find plausible
candidates for this list.
candidates for this list.
.. NOTE: reST targets are
Expand Down Expand Up @@ -233,6 +233,7 @@
.. _Michael Hanke: http://mih.voxindeserto.de
.. _Gaël Varoquaux: http://gael-varoquaux.info/
.. _Stephan Gerhard: http://www.unidesign.ch
.. _Ben Cipollini: http://bcipolli.github.io/

.. Substitutions
.. |emdash| unicode:: U+02014
Expand Down
2 changes: 1 addition & 1 deletion nibabel/benchmarks/bench_array_to_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def bench_array_to_file():
mtime = measure('array_to_file(arr, BytesIO(), np.int16)', repeat)
print('%30s %6.2f' % ('Save float64 to int16, infs', mtime))
# Int16 input, float output
arr = np.random.random_integers(low=-1000,high=-1000, size=img_shape)
arr = np.random.random_integers(low=-1000, high=1000, size=img_shape)
arr = arr.astype(np.int16)
mtime = measure('array_to_file(arr, BytesIO(), np.float32)', repeat)
print('%30s %6.2f' % ('Save Int16 to float32', mtime))
Expand Down
2 changes: 1 addition & 1 deletion nibabel/benchmarks/bench_finite_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def bench_finite_range():
mtime = measure('finite_range(arr)', repeat)
print('%30s %6.2f' % ('float64 many infs', mtime))
# Int16 input, float output
arr = np.random.random_integers(low=-1000,high=-1000, size=img_shape)
arr = np.random.random_integers(low=-1000, high=1000, size=img_shape)
arr = arr.astype(np.int16)
mtime = measure('finite_range(arr)', repeat)
print('%30s %6.2f' % ('int16', mtime))
Expand Down
2 changes: 1 addition & 1 deletion nibabel/benchmarks/bench_load_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def bench_load_save():
mtime = measure('img.from_file_map(img.file_map)', repeat)
print('%30s %6.2f' % ('Load from int16, NaNs', mtime))
# Int16 input, float output
arr = np.random.random_integers(low=-1000,high=-1000, size=img_shape)
arr = np.random.random_integers(low=-1000, high=1000, size=img_shape)
arr = arr.astype(np.int16)
img = Nifti1Image(arr, np.eye(4))
sio = BytesIO()
Expand Down
10 changes: 8 additions & 2 deletions nibabel/fileslice.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,15 @@ def strided_scalar(shape, scalar=0.):
strided_arr : array
Array of shape `shape` for which all values == `scalar`, built by
setting all strides of `strided_arr` to 0, so the scalar is broadcast
out to the full array `shape`.
out to the full array `shape`. `strided_arr` is flagged as not
`writeable`.
The array is set read-only to avoid a numpy error when broadcasting -
see https://github.com/numpy/numpy/issues/6491
"""
shape = tuple(shape)
scalar = np.array(scalar)
strides = [0] * len(shape)
return np.lib.stride_tricks.as_strided(scalar, shape, strides)
strided_scalar = np.lib.stride_tricks.as_strided(scalar, shape, strides)
strided_scalar.flags.writeable = False
return strided_scalar
4 changes: 2 additions & 2 deletions nibabel/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
_version_major = 2
_version_minor = 0
_version_micro = 2
_version_extra = 'dev'
#_version_extra = ''
#_version_extra = 'dev'
_version_extra = ''

# Format expected by setup.py and doc/source/conf.py: string of form "X.Y.Z"
__version__ = "%s.%s.%s%s" % (_version_major,
Expand Down
7 changes: 5 additions & 2 deletions nibabel/nicom/dicomwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ def wrapper_from_file(file_like, *args, **kwargs):
dcm_w : ``dicomwrappers.Wrapper`` or subclass
DICOM wrapper corresponding to DICOM data type
"""
import dicom
try:
from dicom import read_file
except ImportError:
from pydicom.dicomio import read_file

with BinOpener(file_like) as fobj:
dcm_data = dicom.read_file(fobj, *args, **kwargs)
dcm_data = read_file(fobj, *args, **kwargs)
return wrapper_from_data(dcm_data)


Expand Down
5 changes: 4 additions & 1 deletion nibabel/nicom/tests/test_csareader.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def test_csa_header_read():
assert_true(csa.is_mosaic(hdr))
# Get a shallow copy of the data, lacking the CSA marker
# Need to do it this way because del appears broken in pydicom 0.9.7
from dicom.dataset import Dataset
try:
from dicom.dataset import Dataset
except ImportError:
from pydicom.dataset import Dataset
data2 = Dataset()
for element in DATA:
if (element.tag.group, element.tag.elem) != (0x29, 0x10):
Expand Down
9 changes: 6 additions & 3 deletions nibabel/nicom/tests/test_dicomreaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def test_passing_kwds():
# Check that we correctly pass keywords to dicom
dwi_glob = 'siemens_dwi_*.dcm.gz'
csa_glob = 'csa*.bin'
import dicom
try:
from dicom.filereader import InvalidDicomError
except ImportError:
from pydicom.filereader import InvalidDicomError
for func in (didr.read_mosaic_dwi_dir, didr.read_mosaic_dir):
data, aff, bs, gs = func(IO_DATA_PATH, dwi_glob)
# This should not raise an error
Expand All @@ -49,14 +52,14 @@ def test_passing_kwds():
dwi_glob,
dicom_kwargs=dict(force=True))
assert_array_equal(data, data2)
# This should raise an error in dicom.read_file
# This should raise an error in pydicom.dicomio.read_file
assert_raises(TypeError,
func,
IO_DATA_PATH,
dwi_glob,
dicom_kwargs=dict(not_a_parameter=True))
# These are invalid dicoms, so will raise an error unless force=True
assert_raises(dicom.filereader.InvalidDicomError,
assert_raises(InvalidDicomError,
func,
IO_DATA_PATH,
csa_glob)
Expand Down
21 changes: 13 additions & 8 deletions nibabel/nicom/tests/test_dicomwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@

import numpy as np

have_dicom = True
try:
import dicom
import dicom as pydicom
read_file = pydicom.read_file
except ImportError:
have_dicom = False
else:
have_dicom = True
try:
import pydicom
except ImportError:
have_dicom = False
else:
from pydicom.dicomio import read_file
dicom_test = np.testing.dec.skipif(not have_dicom,
'could not import pydicom')

Expand All @@ -32,8 +37,8 @@
DATA_FILE = pjoin(IO_DATA_PATH, 'siemens_dwi_1000.dcm.gz')
DATA_FILE_PHILIPS = pjoin(IO_DATA_PATH, 'philips_mprage.dcm.gz')
if have_dicom:
DATA = dicom.read_file(gzip.open(DATA_FILE))
DATA_PHILIPS = dicom.read_file(gzip.open(DATA_FILE_PHILIPS))
DATA = read_file(gzip.open(DATA_FILE))
DATA_PHILIPS = read_file(gzip.open(DATA_FILE_PHILIPS))
else:
DATA = None
DATA_PHILIPS = None
Expand Down Expand Up @@ -166,7 +171,7 @@ def test_wrapper_from_data():

@dicom_test
def test_wrapper_args_kwds():
# Test we can pass args, kwargs to dicom.read_file
# Test we can pass args, kwargs to read_file
dcm = didw.wrapper_from_file(DATA_FILE)
data = dcm.get_data()
# Passing in non-default arg for defer_size
Expand All @@ -177,7 +182,7 @@ def test_wrapper_args_kwds():
assert_array_equal(data, dcm2.get_data())
# Trying to read non-dicom file raises pydicom error, usually
csa_fname = pjoin(IO_DATA_PATH, 'csa2_b0.bin')
assert_raises(dicom.filereader.InvalidDicomError,
assert_raises(pydicom.filereader.InvalidDicomError,
didw.wrapper_from_file,
csa_fname)
# We can force the read, in which case rubbish returns
Expand Down
Loading

0 comments on commit 8522d9d

Please sign in to comment.