9
9
10
10
from ...tmpdirs import InTemporaryDirectory
11
11
12
- from nose .tools import assert_true
12
+
13
+ import pytest
13
14
import numpy as np
14
15
from numpy .testing import assert_equal , assert_raises , dec , assert_allclose , assert_array_equal
15
16
@@ -92,13 +93,13 @@ def test_geometry():
92
93
with clear_and_catch_warnings () as w :
93
94
warnings .filterwarnings ('always' , category = DeprecationWarning )
94
95
read_geometry (surf_path , read_metadata = True )
95
- assert_true (any ('volume information contained' in str (ww .message )
96
+ assert (any ('volume information contained' in str (ww .message )
96
97
for ww in w ))
97
- assert_true (any ('extension code' in str (ww .message ) for ww in w ))
98
+ assert (any ('extension code' in str (ww .message ) for ww in w ))
98
99
volume_info ['head' ] = [1 , 2 ]
99
100
with clear_and_catch_warnings () as w :
100
101
write_geometry (surf_path , coords , faces , create_stamp , volume_info )
101
- assert_true (any ('Unknown extension' in str (ww .message ) for ww in w ))
102
+ assert (any ('Unknown extension' in str (ww .message ) for ww in w ))
102
103
volume_info ['a' ] = 0
103
104
assert_raises (ValueError , write_geometry , surf_path , coords ,
104
105
faces , create_stamp , volume_info )
@@ -137,8 +138,8 @@ def test_morph_data():
137
138
"""Test IO of morphometry data file (eg. curvature)."""
138
139
curv_path = pjoin (data_path , "surf" , "%s.%s" % ("lh" , "curv" ))
139
140
curv = read_morph_data (curv_path )
140
- assert_true (- 1.0 < curv .min () < 0 )
141
- assert_true (0 < curv .max () < 1.0 )
141
+ assert (- 1.0 < curv .min () < 0 )
142
+ assert (0 < curv .max () < 1.0 )
142
143
with InTemporaryDirectory ():
143
144
new_path = 'test'
144
145
write_morph_data (new_path , curv )
@@ -177,18 +178,18 @@ def test_annot():
177
178
hash_ = _hash_file_content (annot_path )
178
179
179
180
labels , ctab , names = read_annot (annot_path )
180
- assert_true (labels .shape == (163842 , ))
181
- assert_true (ctab .shape == (len (names ), 5 ))
181
+ assert (labels .shape == (163842 , ))
182
+ assert (ctab .shape == (len (names ), 5 ))
182
183
183
184
labels_orig = None
184
185
if a == 'aparc' :
185
186
labels_orig , _ , _ = read_annot (annot_path , orig_ids = True )
186
187
np .testing .assert_array_equal (labels == - 1 , labels_orig == 0 )
187
188
# Handle different version of fsaverage
188
189
if hash_ == 'bf0b488994657435cdddac5f107d21e8' :
189
- assert_true (np .sum (labels_orig == 0 ) == 13887 )
190
+ assert (np .sum (labels_orig == 0 ) == 13887 )
190
191
elif hash_ == 'd4f5b7cbc2ed363ac6fcf89e19353504' :
191
- assert_true (np .sum (labels_orig == 1639705 ) == 13327 )
192
+ assert (np .sum (labels_orig == 1639705 ) == 13327 )
192
193
else :
193
194
raise RuntimeError ("Unknown freesurfer file. Please report "
194
195
"the problem to the maintainer of nibabel." )
@@ -272,7 +273,7 @@ def test_write_annot_fill_ctab():
272
273
print (labels )
273
274
with clear_and_catch_warnings () as w :
274
275
write_annot (annot_path , labels , rgbal , names , fill_ctab = False )
275
- assert_true (
276
+ assert (
276
277
any ('Annotation values in {} will be incorrect' .format (
277
278
annot_path ) == str (ww .message ) for ww in w ))
278
279
labels2 , rgbal2 , names2 = read_annot (annot_path , orig_ids = True )
@@ -288,7 +289,7 @@ def test_write_annot_fill_ctab():
288
289
rgbal [:, 2 ] * (2 ** 16 ))
289
290
with clear_and_catch_warnings () as w :
290
291
write_annot (annot_path , labels , rgbal , names , fill_ctab = False )
291
- assert_true (
292
+ assert (
292
293
not any ('Annotation values in {} will be incorrect' .format (
293
294
annot_path ) == str (ww .message ) for ww in w ))
294
295
labels2 , rgbal2 , names2 = read_annot (annot_path )
@@ -348,13 +349,13 @@ def test_label():
348
349
label_path = pjoin (data_path , "label" , "lh.cortex.label" )
349
350
label = read_label (label_path )
350
351
# XXX : test more
351
- assert_true (label .min () >= 0 )
352
- assert_true (label .max () <= 163841 )
353
- assert_true (label .shape [0 ] <= 163842 )
352
+ assert (label .min () >= 0 )
353
+ assert (label .max () <= 163841 )
354
+ assert (label .shape [0 ] <= 163842 )
354
355
355
356
labels , scalars = read_label (label_path , True )
356
- assert_true (np .all (labels == label ))
357
- assert_true (len (labels ) == len (scalars ))
357
+ assert (np .all (labels == label ))
358
+ assert (len (labels ) == len (scalars ))
358
359
359
360
360
361
def test_write_annot_maxstruct ():
0 commit comments