Skip to content

CI: Run coverage on as many tests as possible #722

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 7 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 18 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ matrix:
- python: 3.4
dist: trusty
sudo: false
- python: 2.7
env:
- COVERAGE=1
- python: 3.5
env:
- COVERAGE=1
# Absolute minimum dependencies
- python: 2.7
env:
Expand Down Expand Up @@ -99,25 +93,20 @@ matrix:
env:
- OPTIONAL_DEPENDS="indexed_gzip"
before_install:
- source tools/travis_tools.sh
- python -m pip install --upgrade pip
- pip install --upgrade virtualenv
- travis_retry python -m pip install --upgrade pip
- travis_retry pip install --upgrade virtualenv
- virtualenv --python=python venv
- source venv/bin/activate
- python --version # just to check
- pip install -U pip setuptools>=27.0 wheel
- travis_retry pip install -U pip setuptools>=27.0 wheel
- travis_retry pip install coverage
- if [ "${CHECK_TYPE}" == "test" ]; then
retry pip install nose mock;
travis_retry pip install nose mock;
fi
- if [ "${CHECK_TYPE}" == "style" ]; then
retry pip install flake8;
fi
- pip install $EXTRA_PIP_FLAGS $DEPENDS $OPTIONAL_DEPENDS
- if [ "${COVERAGE}" == "1" ]; then
pip install coverage;
pip install coveralls;
pip install codecov;
travis_retry pip install flake8;
fi
- travis_retry pip install $EXTRA_PIP_FLAGS $DEPENDS $OPTIONAL_DEPENDS
# command to install dependencies
install:
- |
Expand All @@ -128,7 +117,6 @@ install:
python setup_egg.py sdist
pip install $EXTRA_PIP_FLAGS dist/*.tar.gz
elif [ "$INSTALL_TYPE" == "wheel" ]; then
pip install wheel
python setup_egg.py bdist_wheel
pip install $EXTRA_PIP_FLAGS dist/*.whl
elif [ "$INSTALL_TYPE" == "requirements" ]; then
Expand All @@ -146,7 +134,9 @@ script:
elif [ "${CHECK_TYPE}" == "import" ]; then
# Import nibabel without attempting to test
# Allows us to check missing dependencies masked by testing libraries
python -c 'import nibabel; print(nibabel.__version__)'
printf 'import nibabel\nprint(nibabel.__version__)\n' > import_only.py
cat import_only.py
coverage run import_only.py
elif [ "${CHECK_TYPE}" == "doc_doctests" ]; then
cd doc
pip install -r ../doc-requirements.txt
Expand All @@ -156,16 +146,18 @@ script:
# Change into an innocuous directory and find tests from installation
mkdir for_testing
cd for_testing
if [ "${COVERAGE}" == "1" ]; then
cp ../.coveragerc .;
COVER_ARGS="--with-coverage --cover-package nibabel";
fi
nosetests --with-doctest $COVER_ARGS nibabel;
cp ../.coveragerc .
nosetests --with-doctest --with-coverage --cover-package nibabel nibabel
else
false
fi
after_success:
- if [ "${COVERAGE}" == "1" ]; then coveralls; codecov; fi
- |
if [ "${CHECK_TYPE}" == "test" ]; then
travis_retry pip install coveralls codecov
coveralls
codecov
fi

notifications:
webhooks: http://nipy.bic.berkeley.edu:54856/travis
9 changes: 7 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ install:

# Install the dependencies of the project.
- python -m pip install --upgrade pip setuptools wheel
- pip install numpy scipy matplotlib nose h5py mock pydicom
- pip install numpy scipy matplotlib h5py pydicom
- pip install nose mock coverage codecov
- pip install .
- SET NIBABEL_DATA_DIR=%CD%\nibabel-data

Expand All @@ -33,4 +34,8 @@ test_script:
# Change into an innocuous directory and find tests from installation
- mkdir for_testing
- cd for_testing
- nosetests --with-doctest nibabel
- cp ../.coveragerc .
- nosetests --with-doctest --with-coverage --cover-package nibabel nibabel

after_test:
- codecov
12 changes: 11 additions & 1 deletion nibabel/streamlines/array_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ def is_ndarray_of_int_or_bool(obj):
np.issubdtype(obj.dtype, np.bool_)))


def _safe_resize(a, shape):
""" Resize an ndarray safely, using minimal memory """
try:
a.resize(shape)
except ValueError:
a = a.copy()
a.resize(shape, refcheck=False)
return a


class _BuildCache(object):
def __init__(self, arr_seq, common_shape, dtype):
self.offsets = list(arr_seq._offsets)
Expand Down Expand Up @@ -196,7 +206,7 @@ def _resize_data_to(self, n_rows, build_cache):
if self._data.size == 0:
self._data = np.empty(new_shape, dtype=build_cache.dtype)
else:
self._data.resize(new_shape)
self._data = _safe_resize(self._data, new_shape)

def shrink_data(self):
self._data.resize((self._get_next_offset(),) + self.common_shape,
Expand Down
4 changes: 4 additions & 0 deletions nibabel/streamlines/tests/test_array_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ def test_arraysequence_extend(self):
seq = SEQ_DATA['seq'].copy() # Copy because of in-place modification.
assert_raises(ValueError, seq.extend, data)

# Extend after extracting some slice
working_slice = seq[:2]
seq.extend(ArraySequence(new_data))

def test_arraysequence_getitem(self):
# Get one item
for i, e in enumerate(SEQ_DATA['seq']):
Expand Down
32 changes: 0 additions & 32 deletions tools/travis_tools.sh

This file was deleted.