Skip to content

Commit 37969e0

Browse files
committed
FIX numpy had removed fromstring in favor of frombuffer
1 parent f27bfd1 commit 37969e0

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

cortex/formats.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def read_stl(filename):
6868
if header[:5] == "solid":
6969
raise TypeError("Cannot read ASCII STL files")
7070
npolys, = struct.unpack('I', fp.read(4))
71-
data = np.fromstring(fp.read(), dtype=dtype)
71+
data = np.frombuffer(fp.read(), dtype=dtype)
7272
if npolys != len(data):
7373
raise ValueError('File invalid')
7474

cortex/freesurfer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ def parse_surf(filename):
416416
fp.readline()
417417
print(comment)
418418
verts, faces = struct.unpack('>2I', fp.read(8))
419-
pts = np.fromstring(fp.read(4*3*verts), dtype='f4').byteswap()
420-
polys = np.fromstring(fp.read(4*3*faces), dtype='i4').byteswap()
419+
pts = np.frombuffer(fp.read(4*3*verts), dtype='f4').byteswap()
420+
polys = np.frombuffer(fp.read(4*3*faces), dtype='i4').byteswap()
421421

422422
return pts.reshape(-1, 3), polys.reshape(-1, 3)
423423

@@ -470,7 +470,7 @@ def parse_curv(filename):
470470
"""
471471
with open(filename, 'rb') as fp:
472472
fp.seek(15)
473-
return np.fromstring(fp.read(), dtype='>f4').byteswap().view(np.dtype('>f4').newbyteorder('='))
473+
return np.frombuffer(fp.read(), dtype='>f4').byteswap().view(np.dtype('>f4').newbyteorder('='))
474474

475475

476476
def parse_patch(filename):
@@ -479,7 +479,7 @@ def parse_patch(filename):
479479
with open(filename, 'rb') as fp:
480480
header, = struct.unpack('>i', fp.read(4))
481481
nverts, = struct.unpack('>i', fp.read(4))
482-
data = np.fromstring(fp.read(), dtype=[('vert', '>i4'), ('x', '>f4'),
482+
data = np.frombuffer(fp.read(), dtype=[('vert', '>i4'), ('x', '>f4'),
483483
('y', '>f4'), ('z', '>f4')])
484484
assert len(data) == nverts
485485
return data

0 commit comments

Comments
 (0)