Skip to content

Commit

Permalink
replaced deprecated f'romstring' by 'frombuffer', this fixes issue #64
Browse files Browse the repository at this point in the history
  • Loading branch information
SKolodynski committed Dec 26, 2018
1 parent a47696a commit 7e64a28
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
because of 'async' becoming a keyword in Python 3.7
- replaced DataFrame.as_matrix() method (deprecated since Pandas 0.23.0) by
DataFrame.values
- replaced numpy.fromstring method (deprecated since NumPy 1.14) by
numpy.frombuffer

------------------------------------------------------------------------------
qPython 1.3.0 [2017.03.xx]
Expand Down
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __getattr__(cls, name):

# workaround for building docs without numpy
import numpy
numpy.fromstring = lambda x, dtype: [None]
numpy.frombuffer = lambda x, dtype: [None]
numpy.ndarray = Mock
# end-of-workaround

Expand Down
4 changes: 2 additions & 2 deletions doc/source/type-conversion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ Please note that q ``null`` values are defined as::
_QNULL2 = numpy.int16(-2**15)
_QNULL4 = numpy.int32(-2**31)
_QNULL8 = numpy.int64(-2**63)
_QNAN32 = numpy.fromstring('\x00\x00\xc0\x7f', dtype=numpy.float32)[0]
_QNAN64 = numpy.fromstring('\x00\x00\x00\x00\x00\x00\xf8\x7f', dtype=numpy.float64)[0]
_QNAN32 = numpy.frombuffer('\x00\x00\xc0\x7f', dtype=numpy.float32)[0]
_QNAN64 = numpy.frombuffer('\x00\x00\x00\x00\x00\x00\xf8\x7f', dtype=numpy.float64)[0]
_QNULL_BOOL = numpy.bool_(False)
_QNULL_SYM = numpy.string_('')
_QNULL_GUID = uuid.UUID('00000000-0000-0000-0000-000000000000')
Expand Down
4 changes: 2 additions & 2 deletions qpython/qreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def read_data(self, message_size, is_compressed = False, **options):
uncompressed_size = -8 + self._buffer.get_int()
compressed_data = self._read_bytes(message_size - 12) if self._stream else self._buffer.raw(message_size - 12)

raw_data = numpy.fromstring(compressed_data, dtype = numpy.uint8)
raw_data = numpy.frombuffer(compressed_data, dtype = numpy.uint8)
if uncompressed_size <= 0:
raise QReaderException('Error while data decompression.')

Expand Down Expand Up @@ -296,7 +296,7 @@ def _read_list(self, qtype):
return qlist(data, qtype = qtype, adjust_dtype = False)
elif conversion:
raw = self._buffer.raw(length * ATOM_SIZE[qtype])
data = numpy.fromstring(raw, dtype = conversion)
data = numpy.frombuffer(raw, dtype = conversion)
if not self._is_native:
data.byteswap(True)

Expand Down
4 changes: 2 additions & 2 deletions qpython/qtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@
_QNULL2 = numpy.int16(-2**15)
_QNULL4 = numpy.int32(-2**31)
_QNULL8 = numpy.int64(-2**63)
_QNAN32 = numpy.fromstring(b'\x00\x00\xc0\x7f', dtype=numpy.float32)[0]
_QNAN64 = numpy.fromstring(b'\x00\x00\x00\x00\x00\x00\xf8\x7f', dtype=numpy.float64)[0]
_QNAN32 = numpy.frombuffer(b'\x00\x00\xc0\x7f', dtype=numpy.float32)[0]
_QNAN64 = numpy.frombuffer(b'\x00\x00\x00\x00\x00\x00\xf8\x7f', dtype=numpy.float64)[0]
_QNULL_BOOL = numpy.bool_(False)
_QNULL_SYM = numpy.string_('')
_QNULL_GUID = uuid.UUID('00000000-0000-0000-0000-000000000000')
Expand Down

1 comment on commit 7e64a28

@wec7
Copy link

@wec7 wec7 commented on 7e64a28 Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this released? @SKolodynski

Please sign in to comment.