本文整理汇总了Python中arctic.tickstore.tickstore.TickStore._to_bucket方法的典型用法代码示例。如果您正苦于以下问题:Python TickStore._to_bucket方法的具体用法?Python TickStore._to_bucket怎么用?Python TickStore._to_bucket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arctic.tickstore.tickstore.TickStore
的用法示例。
在下文中一共展示了TickStore._to_bucket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tickstore_to_bucket_always_forwards_image
# 需要导入模块: from arctic.tickstore.tickstore import TickStore [as 别名]
# 或者: from arctic.tickstore.tickstore.TickStore import _to_bucket [as 别名]
def test_tickstore_to_bucket_always_forwards_image():
symbol = 'SYM'
tz = 'UTC'
initial_image = {'index': dt(2014, 2, 1, 0, 0, tzinfo=mktz(tz)), 'A': 123, 'B': 54.4, 'C': 'DESC'}
data = [{'index': dt(2014, 1, 1, 0, 1, tzinfo=mktz(tz)), 'A': 124, 'D': 0}]
with pytest.raises(UnorderedDataException) as e:
TickStore._to_bucket(data, symbol, initial_image)
示例2: test_tickstore_to_bucket_with_image
# 需要导入模块: from arctic.tickstore.tickstore import TickStore [as 别名]
# 或者: from arctic.tickstore.tickstore.TickStore import _to_bucket [as 别名]
def test_tickstore_to_bucket_with_image():
symbol = 'SYM'
tz = 'UTC'
initial_image = {'index': dt(2014, 1, 1, 0, 0, tzinfo=mktz(tz)), 'A': 123, 'B': 54.4, 'C': 'DESC'}
data = [{'index': dt(2014, 1, 1, 0, 1, tzinfo=mktz(tz)), 'A': 124, 'D': 0},
{'index': dt(2014, 1, 1, 0, 2, tzinfo=mktz(tz)), 'A': 125, 'B': 27.2}]
bucket, final_image = TickStore._to_bucket(data, symbol, initial_image)
assert bucket[COUNT] == 2
assert bucket[END] == dt(2014, 1, 1, 0, 2, tzinfo=mktz(tz))
assert set(bucket[COLUMNS]) == set(('A', 'B', 'D'))
assert set(bucket[COLUMNS]['A']) == set((ROWMASK, DTYPE, DATA))
assert get_coldata(bucket[COLUMNS]['A']) == ([124, 125], [1, 1, 0, 0, 0, 0, 0, 0])
assert get_coldata(bucket[COLUMNS]['B']) == ([27.2], [0, 1, 0, 0, 0, 0, 0, 0])
assert get_coldata(bucket[COLUMNS]['D']) == ([0], [1, 0, 0, 0, 0, 0, 0, 0])
index = [dt.fromtimestamp(int(i/1000)).replace(tzinfo=mktz(tz)) for i in
list(np.cumsum(np.frombuffer(decompress(bucket[INDEX]), dtype='uint64')))]
assert index == [i['index'] for i in data]
assert bucket[COLUMNS]['A'][DTYPE] == 'int64'
assert bucket[COLUMNS]['B'][DTYPE] == 'float64'
assert bucket[SYMBOL] == symbol
assert bucket[START] == initial_image['index']
assert bucket[IMAGE_DOC][IMAGE] == initial_image
assert bucket[IMAGE_DOC] == {IMAGE: initial_image,
IMAGE_TIME: initial_image['index']}
assert final_image == {'index': data[-1]['index'], 'A': 125, 'B': 27.2, 'C': 'DESC', 'D': 0}
示例3: test_tickstore_to_bucket_no_image
# 需要导入模块: from arctic.tickstore.tickstore import TickStore [as 别名]
# 或者: from arctic.tickstore.tickstore.TickStore import _to_bucket [as 别名]
def test_tickstore_to_bucket_no_image():
symbol = 'SYM'
data = [{'index': dt(2014, 1, 1, 0, 1, tzinfo=mktz()), 'A': 124, 'D': 0},
{'index': dt(2014, 1, 1, 0, 2, tzinfo=mktz()), 'A': 125, 'B': 27.2}]
bucket, final_image = TickStore._to_bucket(data, symbol, None)
assert bucket[COUNT] == 2
assert bucket[END] == dt(2014, 1, 1, 0, 2, tzinfo=mktz())
assert bucket[SYMBOL] == symbol
assert bucket[START] == dt(2014, 1, 1, 0, 1, tzinfo=mktz())
assert 'A' in bucket[COLUMNS]
assert IMAGE_DOC not in bucket
assert not final_image