Skip to content

Commit 491f350

Browse files
committed
TEST: Bitten by int64 <-> int32 issue in .annot unit test. And ndarray.tobytes
no exist in numpy 1.7
1 parent a5694e3 commit 491f350

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nibabel/freesurfer/tests/test_io.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ def test_read_annot_old_format():
301301
"""Test reading an old-style .annot file."""
302302
def gen_old_annot_file(fpath, nverts, labels, rgba, names):
303303
dt = '>i'
304-
vdata = np.zeros((nverts, 2))
304+
vdata = np.zeros((nverts, 2), dtype=dt)
305305
vdata[:, 0] = np.arange(nverts)
306306
vdata[:, [1]] = _pack_rgba(rgba[labels, :])
307307
fbytes = b''
308308
# number of vertices
309309
fbytes += struct.pack(dt, nverts)
310310
# vertices + annotation values
311-
fbytes += vdata.astype(dt).tobytes()
311+
fbytes += bytes(vdata.astype(dt).tostring())
312312
# is there a colour table?
313313
fbytes += struct.pack(dt, 1)
314314
# number of entries in colour table
@@ -320,15 +320,15 @@ def gen_old_annot_file(fpath, nverts, labels, rgba, names):
320320
# length of entry name (+1 for terminating byte)
321321
fbytes += struct.pack(dt, len(names[i]) + 1)
322322
fbytes += names[i].encode('ascii') + b'\00'
323-
fbytes += rgba[i, :].astype(dt).tobytes()
323+
fbytes += bytes(rgba[i, :].astype(dt))
324324
with open(fpath, 'wb') as f:
325325
f.write(fbytes)
326326
with InTemporaryDirectory():
327327
nverts = 10
328328
nlabels = 3
329329
names = ['Label {}'.format(l) for l in range(nlabels)]
330330
labels = np.concatenate((
331-
np.arange(nlabels), np.random.randint(0, 3, nverts - nlabels)))
331+
np.arange(nlabels), np.random.randint(0, nlabels, nverts - nlabels)))
332332
np.random.shuffle(labels)
333333
rgba = np.random.randint(0, 255, (nlabels, 4))
334334
# write an old .annot file

0 commit comments

Comments
 (0)