本文整理汇总了Python中pycast.common.timeseries.TimeSeries.sort_timeseries方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeries.sort_timeseries方法的具体用法?Python TimeSeries.sort_timeseries怎么用?Python TimeSeries.sort_timeseries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycast.common.timeseries.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.sort_timeseries方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pycast.common.timeseries import TimeSeries [as 别名]
# 或者: from pycast.common.timeseries.TimeSeries import sort_timeseries [as 别名]
def execute(self, timeSeries):
"""Creates a new TimeSeries containing the SMA values for the predefined windowsize.
:param TimeSeries timeSeries: The TimeSeries used to calculate the simple moving average values.
:return: TimeSeries object containing the smooth moving average.
:rtype: TimeSeries
:raise: Raises a :py:exc:`ValueError` wif the defined windowsize is larger than the number of elements
in timeSeries
:note: This implementation aims to support independent for loop execution.
"""
windowsize = self._parameters["windowsize"]
if len (timeSeries) < windowsize:
raise ValueError("windowsize is larger than the number of elements in timeSeries.")
tsLength = len(timeSeries)
nbrOfLoopRuns = tsLength - windowsize + 1
res = TimeSeries()
for idx in xrange(nbrOfLoopRuns):
end = idx + windowsize
data = timeSeries[idx:end]
timestamp = data[windowsize//2][0]
value = sum([i[1] for i in data])/windowsize
res.add_entry(timestamp, value)
res.sort_timeseries()
return res
示例2: timeseries_sort_test
# 需要导入模块: from pycast.common.timeseries import TimeSeries [as 别名]
# 或者: from pycast.common.timeseries.TimeSeries import sort_timeseries [as 别名]
def timeseries_sort_test(self):
"""Tests the sort_timeseries function."""
data = [[0.0, 0.0], [0.1, 0.1], [0.2, 0.2], [0.3, 0.3], [0.4, 0.4], [0.5, 0.5]]
ts = TimeSeries.from_twodim_list(data)
ts.sort_timeseries()
ts.sort_timeseries(False)
ts = TimeSeries(isSorted=True)
ts.sort_timeseries()