Skip to content

BUG: Fix deprecation warning on use of np.fromstring. #706

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nibabel/gifti/parse_gifti_fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def read_data_block(encoding, endian, ordering, datatype, shape, data):
dec = base64.b64decode(data.encode('ascii'))
dt = data_type_codes.type[datatype]
sh = tuple(shape)
newarr = np.fromstring(dec, dtype=dt)
newarr = np.frombuffer(dec, dtype=dt)
if len(newarr.shape) != len(sh):
newarr = newarr.reshape(sh, order=ord)

Expand All @@ -59,7 +59,7 @@ def read_data_block(encoding, endian, ordering, datatype, shape, data):
zdec = zlib.decompress(dec)
dt = data_type_codes.type[datatype]
sh = tuple(shape)
newarr = np.fromstring(zdec, dtype=dt)
newarr = np.frombuffer(zdec, dtype=dt)
if len(newarr.shape) != len(sh):
newarr = newarr.reshape(sh, order=ord)

Expand Down
2 changes: 1 addition & 1 deletion nibabel/nifti1.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def from_fileobj(klass, fileobj, size, byteswap):
# otherwise there should be a full extension header
if not len(ext_def) == 8:
raise HeaderDataError('failed to read extension header')
ext_def = np.fromstring(ext_def, dtype=np.int32)
ext_def = np.frombuffer(ext_def, dtype=np.int32)
if byteswap:
ext_def = ext_def.byteswap()
# be extra verbose
Expand Down
2 changes: 1 addition & 1 deletion nibabel/parrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def _process_gen_dict(gen_dict):
value = props[1](value)
elif len(props) == 3:
# array with dtype and shape
value = np.fromstring(value, props[1], sep=' ')
value = np.frombuffer(value, props[1], sep=' ')
# if shape is None, allow arbitrary length
if props[2] is not None:
value.shape = props[2]
Expand Down
2 changes: 1 addition & 1 deletion nibabel/streamlines/trk.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def _read_header(fileobj):

# Read the header in one block.
header_str = f.read(header_2_dtype.itemsize)
header_rec = np.fromstring(string=header_str, dtype=header_2_dtype)
header_rec = np.frombuffer(string=header_str, dtype=header_2_dtype)

# Check endianness
endianness = native_code
Expand Down