7
7
import warnings
8
8
from os .path import isdir
9
9
from os .path import join as pjoin
10
+ from pathlib import Path
10
11
11
12
import numpy as np
12
13
import pytest
46
47
)
47
48
48
49
49
- def _hash_file_content (fname ):
50
- hasher = hashlib .md5 ()
51
- with open (fname , 'rb' ) as afile :
52
- buf = afile .read ()
53
- hasher .update (buf )
54
- return hasher .hexdigest ()
55
-
56
-
57
50
@freesurfer_test
58
51
def test_geometry ():
59
52
"""Test IO of .surf"""
@@ -179,7 +172,6 @@ def test_annot():
179
172
annots = ['aparc' , 'aparc.a2005s' ]
180
173
for a in annots :
181
174
annot_path = pjoin (data_path , 'label' , f'lh.{ a } .annot' )
182
- hash_ = _hash_file_content (annot_path )
183
175
184
176
labels , ctab , names = read_annot (annot_path )
185
177
assert labels .shape == (163842 ,)
@@ -190,9 +182,10 @@ def test_annot():
190
182
labels_orig , _ , _ = read_annot (annot_path , orig_ids = True )
191
183
np .testing .assert_array_equal (labels == - 1 , labels_orig == 0 )
192
184
# Handle different version of fsaverage
193
- if hash_ == 'bf0b488994657435cdddac5f107d21e8' :
185
+ content_hash = hashlib .md5 (Path (annot_path ).read_bytes ()).hexdigest ()
186
+ if content_hash == 'bf0b488994657435cdddac5f107d21e8' :
194
187
assert np .sum (labels_orig == 0 ) == 13887
195
- elif hash_ == 'd4f5b7cbc2ed363ac6fcf89e19353504' :
188
+ elif content_hash == 'd4f5b7cbc2ed363ac6fcf89e19353504' :
196
189
assert np .sum (labels_orig == 1639705 ) == 13327
197
190
else :
198
191
raise RuntimeError (
0 commit comments