Skip to content

Commit 55bfb4e

Browse files
authored
FIX: Deprecated args (#252)
1 parent f766d51 commit 55bfb4e

File tree

6 files changed

+57
-68
lines changed

6 files changed

+57
-68
lines changed

.travis.yml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,28 @@ language: c
22
sudo: false
33

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

810
matrix:
911
include:
10-
# Full (Linux, 3.6)
12+
# Full
1113
- os: linux
12-
env: CONDA_ENVIRONMENT="environment.yml"
1314
addons:
1415
apt:
1516
packages:
1617
- mencoder
1718

18-
# Full (Linux, 2.7)
19+
# 2.7, no mencoder
1920
- os: linux
20-
env: CONDA_DEPENDENCIES="numpy scipy matplotlib mayavi flake8 pytest pytest-cov coverage"
21-
PIP_DEPENDENCIES="codecov nibabel imageio"
22-
addons:
23-
apt:
24-
packages:
25-
- mencoder
26-
27-
# Minimal (no mencoder)
28-
- os: linux
29-
env: CONDA_DEPENDENCIES="numpy scipy matplotlib mayavi flake8 pytest pytest-cov coverage"
30-
PIP_DEPENDENCIES="codecov nibabel"
21+
env: PYTHON_VERSION=2.7
22+
CONDA_DEPENDENCIES="numpy scipy matplotlib coverage pytest pytest-cov flake8 mayavi"
23+
PIP_DEPENDENCIES="codecov pytest-sugar faulthandler pytest-faulthandler nibabel imageio"
3124

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

3728
# Setup anaconda
3829
before_install:
@@ -47,6 +38,10 @@ before_install:
4738
fi;
4839
- git clone https://github.com/astropy/ci-helpers.git
4940
- source ci-helpers/travis/setup_conda.sh
41+
- if [ "$PYTHON_VERSION" != "2.7" ]; then
42+
pip install vtk;
43+
pip install mayavi;
44+
fi;
5045

5146
install:
5247
- python setup.py build
@@ -68,7 +63,7 @@ before_script:
6863

6964
script:
7065
- cd ${SRC_DIR}
71-
- pytest surfer --cov=surfer
66+
- pytest surfer --cov=surfer -v
7267
- make flake
7368

7469
after_success:

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ environment:
66
install:
77
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
88
- "python --version"
9-
- "pip install numpy scipy matplotlib nose pillow pytest pytest-cov coverage imageio codecov pyqt5==5.9"
9+
- "pip install numpy scipy matplotlib nose pillow pytest pytest-cov pytest-faulthandler coverage imageio codecov pyqt5==5.9"
1010
- "pip install traits traitsui pyface vtk mayavi nibabel"
1111
- "python -c \"import imageio; imageio.plugins.ffmpeg.download()\""
1212
- "powershell make/get_fsaverage.ps1"
@@ -18,7 +18,7 @@ build: false # Not a C# project, build stuff at the test step instead.
1818

1919
test_script:
2020
# Run the project tests
21-
- "pytest surfer --cov=surfer"
21+
- "pytest surfer --cov=surfer -v"
2222

2323
on_success:
2424
- "codecov"

environment.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

setup.cfg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
[tool:pytest]
22
addopts = --showlocals --durations=10 --doctest-modules -rs --cov-report= --doctest-ignore-import-errors
3+
filterwarnings =
4+
error::
5+
ignore:Importing from numpy.testing.decorators is deprecated, import from numpy.testing instead.:DeprecationWarning
6+
ignore:use "HasTraits.trait_.et" instead:DeprecationWarning
7+
ignore:np.loads is deprecated, use pickle.loads instead:DeprecationWarning
8+
ignore:can't resolve package from __spec__ or __package__, falling back on __name__ and __path__:ImportWarning
9+
ignore:The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead:DeprecationWarning
10+
ignore:elementwise == comparison failed:DeprecationWarning
11+
ignore:Matplotlib is building the font cache using fc-list. This may take a moment.:UserWarning

surfer/tests/test_viz.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from mayavi import mlab
99
import nibabel as nib
1010
import numpy as np
11-
from numpy.testing import assert_array_equal
11+
from numpy.testing import assert_array_equal, assert_array_less
12+
1213
from unittest import SkipTest
1314

1415
from surfer import Brain, io, utils
@@ -27,13 +28,12 @@ def _set_backend(backend=None):
2728
"""Use testing backend for Windows."""
2829
only_test = (sys.platform == 'win32' or
2930
(os.getenv('TRAVIS', 'false') == 'true' and
30-
sys.version[0] == '3'))
31+
sys.platform == 'linux') and sys.version[0] == '3')
3132
if backend is None:
3233
backend = 'test' if only_test else 'auto'
33-
else:
34-
if only_test:
35-
raise SkipTest('non-testing backend crashes on Windows and '
36-
'Travis Py3k')
34+
if only_test and backend != 'test':
35+
raise SkipTest('non-testing backend crashes on Windows and '
36+
'Travis Py3k')
3737
mlab.options.backend = backend
3838

3939

@@ -64,18 +64,11 @@ def check_view(brain, view):
6464
@requires_fsaverage()
6565
def test_offscreen():
6666
"""Test offscreen rendering."""
67-
if os.getenv('TRAVIS', 'false') == 'true':
68-
if sys.platform == 'darwin':
69-
raise SkipTest('Offscreen Travis tests fail on OSX')
70-
if sys.version[0] == '3':
71-
raise SkipTest('Offscreen Travis tests fail on Py3k')
7267
_set_backend()
7368
brain = Brain(*std_args, offscreen=True)
74-
# Sometimes the first screenshot is rendered with a different
75-
# resolution on OS X
76-
brain.screenshot()
7769
shot = brain.screenshot()
78-
assert_array_equal(shot.shape, (800, 800, 3))
70+
assert_array_less((400, 400, 2), shot.shape)
71+
assert_array_less(shot.shape, (801, 801, 4))
7972
brain.close()
8073

8174

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

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

377-
if sys.platform == 'darwin' and os.getenv('TRAVIS', '') == 'true':
378-
raise SkipTest('movie saving on OSX Travis is not supported')
379369
# save movies with different options
380370
dst = str(tmpdir.join('test.mov'))
381371
# test the number of frames in the movie

surfer/utils.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,28 @@ def set_log_file(fname=None, output_format='%(message)s', overwrite=None):
332332
logger.addHandler(lh)
333333

334334

335+
if hasattr(inspect, 'signature'): # py35
336+
def _get_args(function, varargs=False):
337+
params = inspect.signature(function).parameters
338+
args = [key for key, param in params.items()
339+
if param.kind not in (param.VAR_POSITIONAL, param.VAR_KEYWORD)]
340+
if varargs:
341+
varargs = [param.name for param in params.values()
342+
if param.kind == param.VAR_POSITIONAL]
343+
if len(varargs) == 0:
344+
varargs = None
345+
return args, varargs
346+
else:
347+
return args
348+
else:
349+
def _get_args(function, varargs=False):
350+
out = inspect.getargspec(function) # args, varargs, keywords, defaults
351+
if varargs:
352+
return out[:2]
353+
else:
354+
return out[0]
355+
356+
335357
def verbose(function):
336358
"""Decorator to allow functions to override default log level
337359
@@ -348,7 +370,7 @@ def verbose(function):
348370
None defaults to using the current log level [e.g., set using
349371
mne.set_log_level()].
350372
"""
351-
arg_names = inspect.getargspec(function).args
373+
arg_names = _get_args(function)
352374
# this wrap allows decorated functions to be pickled (e.g., for parallel)
353375

354376
@wraps(function)

0 commit comments

Comments
 (0)