本文整理汇总了Python中thunder.rdds.fileio.seriesloader.SeriesLoader.collect方法的典型用法代码示例。如果您正苦于以下问题:Python SeriesLoader.collect方法的具体用法?Python SeriesLoader.collect怎么用?Python SeriesLoader.collect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thunder.rdds.fileio.seriesloader.SeriesLoader
的用法示例。
在下文中一共展示了SeriesLoader.collect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fromMultipleArrays
# 需要导入模块: from thunder.rdds.fileio.seriesloader import SeriesLoader [as 别名]
# 或者: from thunder.rdds.fileio.seriesloader.SeriesLoader import collect [as 别名]
def test_fromMultipleArrays(self):
ary = arange(8, dtype=dtype('int16')).reshape((2, 4))
ary2 = arange(8, 16, dtype=dtype('int16')).reshape((2, 4))
series = SeriesLoader(self.sc).fromArrays([ary, ary2])
seriesvals = series.collect()
seriesary = series.pack()
# check ordering of keys
assert_equals((0, 0), seriesvals[0][0]) # first key
assert_equals((1, 0), seriesvals[1][0]) # second key
assert_equals((3, 0), seriesvals[3][0])
assert_equals((0, 1), seriesvals[4][0])
assert_equals((3, 1), seriesvals[7][0])
# check dimensions tuple is reversed from numpy shape
assert_equals(ary.shape[::-1], series.dims.count)
# check that values are in original order, with subsequent point concatenated in values
collectedvals = array([kv[1] for kv in seriesvals], dtype=dtype('int16'))
assert_true(array_equal(ary.ravel(), collectedvals[:, 0]))
assert_true(array_equal(ary2.ravel(), collectedvals[:, 1]))
# check that packing returns concatenation of input arrays, with time as first dimension
assert_true(array_equal(ary.T, seriesary[0]))
assert_true(array_equal(ary2.T, seriesary[1]))
示例2: test_fromArrays
# 需要导入模块: from thunder.rdds.fileio.seriesloader import SeriesLoader [as 别名]
# 或者: from thunder.rdds.fileio.seriesloader.SeriesLoader import collect [as 别名]
def test_fromArrays(self):
ary = arange(8, dtype=dtype('int16')).reshape((2, 4))
series = SeriesLoader(self.sc).fromArrays(ary)
seriesvals = series.collect()
seriesary = series.pack()
# check ordering of keys
assert_equals((0, 0), seriesvals[0][0]) # first key
assert_equals((1, 0), seriesvals[1][0]) # second key
assert_equals((2, 0), seriesvals[2][0])
assert_equals((3, 0), seriesvals[3][0])
assert_equals((0, 1), seriesvals[4][0])
assert_equals((1, 1), seriesvals[5][0])
assert_equals((2, 1), seriesvals[6][0])
assert_equals((3, 1), seriesvals[7][0])
# check dimensions tuple is reversed from numpy shape
assert_equals(ary.shape[::-1], series.dims.count)
# check that values are in original order
collectedvals = array([kv[1] for kv in seriesvals], dtype=dtype('int16')).ravel()
assert_true(array_equal(ary.ravel(), collectedvals))
# check that packing returns transpose of original array
assert_true(array_equal(ary.T, seriesary))