-
Notifications
You must be signed in to change notification settings - Fork 272
TEST: Convert FreeSurfer tests to pytest #881
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
Changes from 6 commits
85ac452
2bc5308
dba6f59
406e6dc
e1bb16d
8d92977
ae39e06
665b28a
441e4fe
f99d926
6e1e1c1
d27b124
6890a62
b7e8abb
5dbe408
24d96e4
e8965c1
bbc36d7
e626a38
2fb977b
30a4639
1987f79
165da32
54fc107
27ef400
a3a2517
fdd26a2
e3f171b
eaab253
6dd27a3
5064f9a
27f0f03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,17 +9,18 @@ | |||||
|
|
||||||
| from ...tmpdirs import InTemporaryDirectory | ||||||
|
|
||||||
| from nose.tools import assert_true | ||||||
|
|
||||||
| import pytest | ||||||
| import numpy as np | ||||||
| from numpy.testing import assert_equal, assert_raises, dec, assert_allclose, assert_array_equal | ||||||
| from numpy.testing import assert_allclose, assert_array_equal | ||||||
|
|
||||||
| from .. import (read_geometry, read_morph_data, read_annot, read_label, | ||||||
| write_geometry, write_morph_data, write_annot) | ||||||
| from ..io import _pack_rgb | ||||||
|
|
||||||
| from ...tests.nibabel_data import get_nibabel_data, needs_nibabel_data | ||||||
| from ...fileslice import strided_scalar | ||||||
| from ...testing import clear_and_catch_warnings | ||||||
| from ...testing_pytest import clear_and_catch_warnings | ||||||
|
|
||||||
| DATA_SDIR = 'fsaverage' | ||||||
|
|
||||||
|
|
@@ -35,10 +36,7 @@ | |||||
| data_path = pjoin(nib_data, 'nitest-freesurfer', DATA_SDIR) | ||||||
| have_freesurfer = isdir(data_path) | ||||||
|
|
||||||
| freesurfer_test = dec.skipif( | ||||||
| not have_freesurfer, | ||||||
| 'cannot find freesurfer {0} directory'.format(DATA_SDIR)) | ||||||
|
|
||||||
| freesurfer_test = pytest.mark.skipif(not have_freesurfer, reason='cannot find freesurfer {0} directory'.format(DATA_SDIR)) | ||||||
|
|
||||||
| def _hash_file_content(fname): | ||||||
| hasher = hashlib.md5() | ||||||
|
|
@@ -53,19 +51,19 @@ def test_geometry(): | |||||
| """Test IO of .surf""" | ||||||
| surf_path = pjoin(data_path, "surf", "%s.%s" % ("lh", "inflated")) | ||||||
| coords, faces = read_geometry(surf_path) | ||||||
| assert_equal(0, faces.min()) | ||||||
| assert_equal(coords.shape[0], faces.max() + 1) | ||||||
| assert 0 == faces.min() | ||||||
| assert coords.shape[0] == faces.max() + 1 | ||||||
|
|
||||||
| surf_path = pjoin(data_path, "surf", "%s.%s" % ("lh", "sphere")) | ||||||
| coords, faces, volume_info, create_stamp = read_geometry( | ||||||
| surf_path, read_metadata=True, read_stamp=True) | ||||||
|
|
||||||
| assert_equal(0, faces.min()) | ||||||
| assert_equal(coords.shape[0], faces.max() + 1) | ||||||
| assert_equal(9, len(volume_info)) | ||||||
| assert_equal([2, 0, 20], volume_info['head']) | ||||||
| assert_equal(u'created by greve on Thu Jun 8 19:17:51 2006', | ||||||
| create_stamp) | ||||||
| assert 0 == faces.min() | ||||||
| assert coords.shape[0] == (faces.max() + 1) | ||||||
orduek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| assert 9 == len(volume_info) | ||||||
| # assert np.array_equal([2, 0, 20],volume_info['head']) | ||||||
orduek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| np.testing.assert_array_equal([2, 0, 20],volume_info['head']) | ||||||
orduek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| assert create_stamp == ['created by greve on Thu Jun 8 19:17:51 2006'] # this creates assertion error - should we just remove it? | ||||||
|
||||||
| assert create_stamp == ['created by greve on Thu Jun 8 19:17:51 2006'] # this creates assertion error - should we just remove it? | |
| assert create_stamp == 'created by greve on Thu Jun 8 19:17:51 2006' |
orduek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
orduek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do the same for the next few assert_true(any(...))?
| assert(any('volume information contained' in str(ww.message) | |
| assert any('volume information contained' in str(ww.message) for ww in w) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for ww in w)) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is the convention you were following? Since assert_array_equal is imported, you can remove the np.testing. from all cases. If you want to have a consistent convention for the whole file, I would suggest settling on one of the following:
assert_array_equal(a, b)assert np.array_equal(a, b)assert np.all(a == b)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert coords.shape[0] == (faces.max() + 1) | |
| assert coords.shape[0] == faces.max() + 1 |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert np.array_equal (curv2, curv) | |
| assert np.array_equal(curv2, curv) |
orduek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like some overzealous tabbing.
| # Windows 32-bit overflows Python int | |
| # Windows 32-bit overflows Python int |
orduek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can become:
assert any('Annotation values in {} will be incorrect'.format(annot_path) == str(ww.message)
for ww in w)Similarly below.
Uh oh!
There was an error while loading. Please reload this page.