Skip to content
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

MRG: Deprecated args #252

Merged
merged 1 commit into from Sep 20, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 13 additions & 18 deletions .travis.yml
Expand Up @@ -2,37 +2,28 @@ language: c
sudo: false

env:
global: PYTHON_VERSION=2.7
global: PYTHON_VERSION=3.6
CONDA_DEPENDENCIES="numpy scipy matplotlib pyqt>=5.9 coverage pytest pytest-cov flake8 pygments traits traitsui pyface"
PIP_DEPENDENCIES="codecov pytest-sugar pytest-faulthandler nibabel imageio"
DISPLAY=:99.0

matrix:
include:
# Full (Linux, 3.6)
# Full
- os: linux
env: CONDA_ENVIRONMENT="environment.yml"
addons:
apt:
packages:
- mencoder

# Full (Linux, 2.7)
# 2.7, no mencoder
- os: linux
env: CONDA_DEPENDENCIES="numpy scipy matplotlib mayavi flake8 pytest pytest-cov coverage"
PIP_DEPENDENCIES="codecov nibabel imageio"
addons:
apt:
packages:
- mencoder

# Minimal (no mencoder)
- os: linux
env: CONDA_DEPENDENCIES="numpy scipy matplotlib mayavi flake8 pytest pytest-cov coverage"
PIP_DEPENDENCIES="codecov nibabel"
env: PYTHON_VERSION=2.7
CONDA_DEPENDENCIES="numpy scipy matplotlib coverage pytest pytest-cov flake8 mayavi"
PIP_DEPENDENCIES="codecov pytest-sugar faulthandler pytest-faulthandler nibabel imageio"

# OSX
- os: osx
env: CONDA_DEPENDENCIES="numpy scipy matplotlib mayavi flake8 pytest pytest-cov coverage"
PIP_DEPENDENCIES="codecov nibabel imageio"

# Setup anaconda
before_install:
Expand All @@ -47,6 +38,10 @@ before_install:
fi;
- git clone https://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh
- if [ "$PYTHON_VERSION" != "2.7" ]; then
pip install vtk;
pip install mayavi;
fi;

install:
- python setup.py build
Expand All @@ -68,7 +63,7 @@ before_script:

script:
- cd ${SRC_DIR}
- pytest surfer --cov=surfer
- pytest surfer --cov=surfer -v
- make flake

after_success:
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Expand Up @@ -6,7 +6,7 @@ environment:
install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "python --version"
- "pip install numpy scipy matplotlib nose pillow pytest pytest-cov coverage imageio codecov pyqt5==5.9"
- "pip install numpy scipy matplotlib nose pillow pytest pytest-cov pytest-faulthandler coverage imageio codecov pyqt5==5.9"
- "pip install traits traitsui pyface vtk mayavi nibabel"
- "python -c \"import imageio; imageio.plugins.ffmpeg.download()\""
- "powershell make/get_fsaverage.ps1"
Expand All @@ -18,7 +18,7 @@ build: false # Not a C# project, build stuff at the test step instead.

test_script:
# Run the project tests
- "pytest surfer --cov=surfer"
- "pytest surfer --cov=surfer -v"

on_success:
- "codecov"
27 changes: 0 additions & 27 deletions environment.yml

This file was deleted.

9 changes: 9 additions & 0 deletions setup.cfg
@@ -1,2 +1,11 @@
[tool:pytest]
addopts = --showlocals --durations=10 --doctest-modules -rs --cov-report= --doctest-ignore-import-errors
filterwarnings =
error::
ignore:Importing from numpy.testing.decorators is deprecated, import from numpy.testing instead.:DeprecationWarning
ignore:use "HasTraits.trait_.et" instead:DeprecationWarning
ignore:np.loads is deprecated, use pickle.loads instead:DeprecationWarning
ignore:can't resolve package from __spec__ or __package__, falling back on __name__ and __path__:ImportWarning
ignore:The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead:DeprecationWarning
ignore:elementwise == comparison failed:DeprecationWarning
ignore:Matplotlib is building the font cache using fc-list. This may take a moment.:UserWarning
30 changes: 10 additions & 20 deletions surfer/tests/test_viz.py
Expand Up @@ -8,7 +8,8 @@
from mayavi import mlab
import nibabel as nib
import numpy as np
from numpy.testing import assert_array_equal
from numpy.testing import assert_array_equal, assert_array_less

from unittest import SkipTest

from surfer import Brain, io, utils
Expand All @@ -27,13 +28,12 @@ def _set_backend(backend=None):
"""Use testing backend for Windows."""
only_test = (sys.platform == 'win32' or
(os.getenv('TRAVIS', 'false') == 'true' and
sys.version[0] == '3'))
sys.platform == 'linux') and sys.version[0] == '3')
if backend is None:
backend = 'test' if only_test else 'auto'
else:
if only_test:
raise SkipTest('non-testing backend crashes on Windows and '
'Travis Py3k')
if only_test and backend != 'test':
raise SkipTest('non-testing backend crashes on Windows and '
'Travis Py3k')
mlab.options.backend = backend


Expand Down Expand Up @@ -64,18 +64,11 @@ def check_view(brain, view):
@requires_fsaverage()
def test_offscreen():
"""Test offscreen rendering."""
if os.getenv('TRAVIS', 'false') == 'true':
if sys.platform == 'darwin':
raise SkipTest('Offscreen Travis tests fail on OSX')
if sys.version[0] == '3':
raise SkipTest('Offscreen Travis tests fail on Py3k')
_set_backend()
brain = Brain(*std_args, offscreen=True)
# Sometimes the first screenshot is rendered with a different
# resolution on OS X
brain.screenshot()
shot = brain.screenshot()
assert_array_equal(shot.shape, (800, 800, 3))
assert_array_less((400, 400, 2), shot.shape)
assert_array_less(shot.shape, (801, 801, 4))
brain.close()


Expand All @@ -93,8 +86,6 @@ def test_image(tmpdir):
brain.close()

brain = Brain(*std_args, size=100)
if sys.platform == 'darwin' and os.getenv('TRAVIS', '') == 'true':
raise SkipTest('image saving on OSX travis is not supported')
brain.save_image(tmp_name)
brain.save_image(tmp_name, 'rgba', True)
brain.screenshot()
Expand Down Expand Up @@ -138,7 +129,8 @@ def test_brains():
brain = Brain(subject_id, hemi, surf, title=title, cortex=cort,
alpha=alpha, size=s, background=bg, foreground=fg,
figure=fig, subjects_dir=sd)
brain.set_distance()
with np.errstate(invalid='ignore'): # encountered in double_scalars
brain.set_distance()
brain.close()
brain = Brain(subject_id, hemi, surf, subjects_dir=sd,
interaction='terrain')
Expand Down Expand Up @@ -374,8 +366,6 @@ def test_movie(tmpdir):
smoothing_steps=10, time=time, time_label='time=%0.2f ms')
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)

if sys.platform == 'darwin' and os.getenv('TRAVIS', '') == 'true':
raise SkipTest('movie saving on OSX Travis is not supported')
# save movies with different options
dst = str(tmpdir.join('test.mov'))
# test the number of frames in the movie
Expand Down
24 changes: 23 additions & 1 deletion surfer/utils.py
Expand Up @@ -332,6 +332,28 @@ def set_log_file(fname=None, output_format='%(message)s', overwrite=None):
logger.addHandler(lh)


if hasattr(inspect, 'signature'): # py35
def _get_args(function, varargs=False):
params = inspect.signature(function).parameters
args = [key for key, param in params.items()
if param.kind not in (param.VAR_POSITIONAL, param.VAR_KEYWORD)]
if varargs:
varargs = [param.name for param in params.values()
if param.kind == param.VAR_POSITIONAL]
if len(varargs) == 0:
varargs = None
return args, varargs
else:
return args
else:
def _get_args(function, varargs=False):
out = inspect.getargspec(function) # args, varargs, keywords, defaults
if varargs:
return out[:2]
else:
return out[0]


def verbose(function):
"""Decorator to allow functions to override default log level

Expand All @@ -348,7 +370,7 @@ def verbose(function):
None defaults to using the current log level [e.g., set using
mne.set_log_level()].
"""
arg_names = inspect.getargspec(function).args
arg_names = _get_args(function)
# this wrap allows decorated functions to be pickled (e.g., for parallel)

@wraps(function)
Expand Down