本文整理匯總了Python中pandas.msgpack.Unpacker.read_array_header方法的典型用法代碼示例。如果您正苦於以下問題:Python Unpacker.read_array_header方法的具體用法?Python Unpacker.read_array_header怎麽用?Python Unpacker.read_array_header使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas.msgpack.Unpacker
的用法示例。
在下文中一共展示了Unpacker.read_array_header方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_correct_type_nested_array
# 需要導入模塊: from pandas.msgpack import Unpacker [as 別名]
# 或者: from pandas.msgpack.Unpacker import read_array_header [as 別名]
def test_correct_type_nested_array():
unpacker = Unpacker()
unpacker.feed(packb({'a': ['b', 'c', 'd']}))
try:
unpacker.read_array_header()
assert 0, 'should raise exception'
except UnexpectedTypeException:
assert 1, 'okay'
示例2: test_incorrect_type_array
# 需要導入模塊: from pandas.msgpack import Unpacker [as 別名]
# 或者: from pandas.msgpack.Unpacker import read_array_header [as 別名]
def test_incorrect_type_array():
unpacker = Unpacker()
unpacker.feed(packb(1))
try:
unpacker.read_array_header()
assert 0, 'should raise exception'
except UnexpectedTypeException:
assert 1, 'okay'
示例3: test_unpack_array_header_from_file
# 需要導入模塊: from pandas.msgpack import Unpacker [as 別名]
# 或者: from pandas.msgpack.Unpacker import read_array_header [as 別名]
def test_unpack_array_header_from_file(self):
f = BytesIO(packb([1,2,3,4]))
unpacker = Unpacker(f)
assert unpacker.read_array_header() == 4
assert unpacker.unpack() == 1
assert unpacker.unpack() == 2
assert unpacker.unpack() == 3
assert unpacker.unpack() == 4
self.assertRaises(OutOfData, unpacker.unpack)
示例4: test_read_array_header
# 需要導入模塊: from pandas.msgpack import Unpacker [as 別名]
# 或者: from pandas.msgpack.Unpacker import read_array_header [as 別名]
def test_read_array_header():
unpacker = Unpacker()
unpacker.feed(packb(['a', 'b', 'c']))
assert unpacker.read_array_header() == 3
assert unpacker.unpack() == b'a'
assert unpacker.unpack() == b'b'
assert unpacker.unpack() == b'c'
try:
unpacker.unpack()
assert 0, 'should raise exception'
except OutOfData:
assert 1, 'okay'