本文整理汇总了Python中thunder.rdds.fileio.seriesloader.SeriesLoader.fromArrays方法的典型用法代码示例。如果您正苦于以下问题:Python SeriesLoader.fromArrays方法的具体用法?Python SeriesLoader.fromArrays怎么用?Python SeriesLoader.fromArrays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thunder.rdds.fileio.seriesloader.SeriesLoader
的用法示例。
在下文中一共展示了SeriesLoader.fromArrays方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadSeriesFromArray
# 需要导入模块: from thunder.rdds.fileio.seriesloader import SeriesLoader [as 别名]
# 或者: from thunder.rdds.fileio.seriesloader.SeriesLoader import fromArrays [as 别名]
def loadSeriesFromArray(self, values, index=None, npartitions=None):
"""
Load Series data from a local array
Parameters
----------
values : list or ndarray
A list of 1d numpy arrays, or a single 2d numpy array
index : array-like, optional, deafult = None
Index to set for Series object, if None will use linear indices.
npartitions : position int, optional, default = None
Number of partitions for RDD, if unspecified will use
default parallelism.
"""
from numpy import ndarray, asarray
from thunder.rdds.fileio.seriesloader import SeriesLoader
loader = SeriesLoader(self._sc)
if not npartitions:
npartitions = self._sc.defaultParallelism
if isinstance(values, list):
values = asarray(values)
if isinstance(values, ndarray) and values.ndim > 1:
values = list(values)
data = loader.fromArrays(values, npartitions=npartitions)
if index:
data.index = index
return data
示例2: _run_roundtrip_tst
# 需要导入模块: from thunder.rdds.fileio.seriesloader import SeriesLoader [as 别名]
# 或者: from thunder.rdds.fileio.seriesloader.SeriesLoader import fromArrays [as 别名]
def _run_roundtrip_tst(self, nimages, aryShape, dtypeSpec, sizeSpec):
testArrays = TestSeriesBinaryWriteFromStack.generateTestImages(nimages, aryShape, dtypeSpec)
loader = SeriesLoader(self.sc)
series = loader.fromArrays(testArrays)
blocks = series.toBlocks(sizeSpec)
roundtrippedSeries = blocks.toSeries(newDType=series.dtype)
packedSeries = series.pack()
packedRoundtrippedSeries = roundtrippedSeries.pack()
assert_true(array_equal(packedSeries, packedRoundtrippedSeries))
示例3: _run_roundtrip_exception_tst
# 需要导入模块: from thunder.rdds.fileio.seriesloader import SeriesLoader [as 别名]
# 或者: from thunder.rdds.fileio.seriesloader.SeriesLoader import fromArrays [as 别名]
def _run_roundtrip_exception_tst(self, nimages, aryShape, dtypeSpec, sizeSpec):
testArrays = TestSeriesBinaryWriteFromStack.generateTestImages(nimages, aryShape, dtypeSpec)
loader = SeriesLoader(self.sc)
series = loader.fromArrays(testArrays)
assert_raises(ValueError, series.toBlocks, sizeSpec)