Skip to content

Commit

Permalink
Merge pull request #51 from maciejlach/master
Browse files Browse the repository at this point in the history
Fix: serialization of 0n in generic lists (when Pandas package is installed) (#50)
  • Loading branch information
SKolodynski committed Dec 5, 2018
2 parents 18b7543 + 1cdaaf2 commit 8f7dcf8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
qPython 1.3.0 [2017.03.xx]
------------------------------------------------------------------------------

- Add support for Python 3.5 and 3.6. Drop support for Python 3.3.
- Add support for Python 3.5 and 3.6. Drop support for Python 3.3
- Fix: serialization of 0n in generic lists

------------------------------------------------------------------------------
qPython 1.2.2 [2016.09.21]
Expand Down
11 changes: 7 additions & 4 deletions qpython/_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ def _write_pandas_data_frame(self, data, qtype = None):

@serialize(tuple, list)
def _write_generic_list(self, data):
self._buffer.write(struct.pack('=bxi', QGENERAL_LIST, len(data)))
for element in data:
# assume nan represents a string null
self._write(' ' if type(element) in [float, numpy.float32, numpy.float64] and numpy.isnan(element) else element)
if self._options.pandas:
self._buffer.write(struct.pack('=bxi', QGENERAL_LIST, len(data)))
for element in data:
# assume nan represents a string null
self._write(' ' if type(element) in [float, numpy.float32, numpy.float64] and numpy.isnan(element) else element)
else:
QWriter._write_generic_list(self, data)
2 changes: 1 addition & 1 deletion tests/pandas_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def test_writing_pandas():
data.meta = value['meta']
else:
data = value
serialized = binascii.hexlify(w.write(data, 1, single_char_strings = single_char_strings))[16:].lower()
serialized = binascii.hexlify(w.write(data, 1, single_char_strings = single_char_strings, pandas = True))[16:].lower()
assert serialized == BINARY[query].lower(), 'serialization failed: %s, expected: %s actual: %s' % (value, BINARY[query].lower(), serialized)
sys.stdout.write( '.' )

Expand Down

0 comments on commit 8f7dcf8

Please sign in to comment.