Skip to content
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

replace tostring deprecations #114

Merged
merged 1 commit into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bench/blpk_vs_gzip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ python -c "
import numpy
a = numpy.linspace(0, 100, 2e7)
with open('$testfile', 'w') as test_file:
test_file.write(a.tostring())
test_file.write(a.tobytes())
"
echo "$testfile is: $(get_fs $testfile)"

Expand Down
2 changes: 1 addition & 1 deletion bloscpack/testutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_array(repeats, in_file, progress=False):
def create_array_fp(repeats, in_fp, progress=False):
for i in range(repeats):
array_ = np.linspace(i, i+1, int(2e6))
in_fp.write(array_.tostring())
in_fp.write(array_.tobytes())
if progress:
progress(i)
in_fp.flush()
Expand Down
4 changes: 2 additions & 2 deletions test/test_append.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def test_append_mix_shuffle():
# the linspace used in 'new' doesn't work anymore as of python-blosc 1.6.1
to_append = np.zeros(int(2e6))
to_append_fp = StringIO()
to_append_fp.write(to_append.tostring())
to_append_fp.write(to_append.tobytes())
to_append_fp_size = to_append_fp.tell()
to_append_fp.seek(0)

Expand All @@ -362,7 +362,7 @@ def test_append_mix_shuffle():

# now sanity check the length and content of the decompressed
assert len(dcmp_str) == len(new_str) + to_append_fp_size
assert dcmp_str == new_str + to_append.tostring()
assert dcmp_str == new_str + to_append.tobytes()

# now get the first and the last chunk and check that the shuffle doesn't
# match
Expand Down
4 changes: 2 additions & 2 deletions test/test_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_pack_unpack_fp():

def test_pack_unpack_bytes_to_from_file():
array_ = np.linspace(0, 1e5)
input_bytes = array_.tostring()
input_bytes = array_.tobytes()
with create_tmp_files() as (tdir, in_file, out_file, dcmp_file):
pack_bytes_to_file(input_bytes, out_file)
output_bytes, _ = unpack_bytes_from_file(out_file)
Expand All @@ -253,7 +253,7 @@ def test_pack_unpack_bytes_to_from_file():

def test_pack_unpack_bytes_bytes():
a = np.linspace(0, 1e5)
b = a.tostring()
b = a.tobytes()
c = pack_bytes_to_bytes(b)
d, _ = unpack_bytes_from_bytes(c)
assert b == d
Expand Down
6 changes: 3 additions & 3 deletions test/test_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_decode_metadata_options_exceptions():


def test_decode_blosc_header_basic():
array_ = np.linspace(0, 100, int(2e4)).tostring()
array_ = np.linspace(0, 100, int(2e4)).tobytes()
blosc_args = BloscArgs()
compressed = blosc.compress(array_, **blosc_args)
header = decode_blosc_header(compressed)
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_decode_blosc_header_deactivate_shuffle():

def test_decode_blosc_header_uncompressible_data():
array_ = np.asarray(np.random.randn(255),
dtype=np.float32).tostring()
dtype=np.float32).tobytes()
blosc_args = BloscArgs()
blosc_args.shuffle = True
compressed = blosc.compress(array_, **blosc_args)
Expand All @@ -182,7 +182,7 @@ def test_decode_blosc_header_uncompressible_data():

def test_decode_blosc_header_uncompressible_data_dont_split_false():
array_ = np.asarray(np.random.randn(256),
dtype=np.float32).tostring()
dtype=np.float32).tobytes()
blosc_args = BloscArgs()
blosc_args.shuffle = True
compressed = blosc.compress(array_, **blosc_args)
Expand Down
2 changes: 1 addition & 1 deletion test/test_numpy_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_conv():
def test_unpack_exception():
a = np.arange(50)
sio = StringIO()
a_str = a.tostring()
a_str = a.tobytes()
source = PlainFPSource(StringIO(a_str))
sink = CompressedFPSink(sio)
pack(source, sink, *calculate_nchunks(len(a_str)))
Expand Down