當前位置: 首頁>>代碼示例>>Python>>正文


Python Formatter.writeDataWrap方法代碼示例

本文整理匯總了Python中Formatter.writeDataWrap方法的典型用法代碼示例。如果您正苦於以下問題:Python Formatter.writeDataWrap方法的具體用法?Python Formatter.writeDataWrap怎麽用?Python Formatter.writeDataWrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Formatter的用法示例。


在下文中一共展示了Formatter.writeDataWrap方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: tagAction

# 需要導入模塊: import Formatter [as 別名]
# 或者: from Formatter import writeDataWrap [as 別名]
TWO_SECS_DATA_AMOUNT = 2 * DATA_AMOUNT_PER_SEC
THREE_SECS_DATA_AMOUNT = 3 * DATA_AMOUNT_PER_SEC
FIVE_SECS_DATA_AMOUNT = 5 * DATA_AMOUNT_PER_SEC

def tagAction(channels, startTime, endTime, actionInterval, actingDuration):
    doNothing = [[] if channel else None for channel in channels]
    action = copy.deepcopy(doNothing)
    actionDataAmount = int(actingDuration * DATA_AMOUNT_PER_SEC)
    actionIntervalDataAmount = int(actionInterval * DATA_AMOUNT_PER_SEC)
    for dataPtr in xrange(int(startTime * DATA_AMOUNT_PER_SEC) + 1, int(endTime * DATA_AMOUNT_PER_SEC), actionIntervalDataAmount):
        for i, channel in enumerate(channels):
            if channel:
                action[i].extend(channel[dataPtr: dataPtr + actionDataAmount])
                doNothing[i].extend(channel[dataPtr + actionDataAmount: dataPtr + actionIntervalDataAmount])

    return doNothing, action

if __name__ == "__main__":
    channelsWrap = Formatter.format({"step": 1, "wink": 1}, [1, 2, 3, 4])
    winkDoNothing, wink = tagAction(channelsWrap["wink"][0], 10, 101, 5, 1)
    stepDoNothing, leftStep = tagAction(channelsWrap["step"][0], 4.87, 100.87, 5, 0.85)
    stepDoNothing2, rightStep = tagAction(channelsWrap["step"][0], 104.87, 200.87, 5, 0.85)
    channelsWrap.clear()
    channelsWrap["winkdonothing"] = [winkDoNothing]
    channelsWrap["wink"] = [wink]
    channelsWrap["stepdonothing"] = [stepDoNothing]
    channelsWrap["leftstep"] = [leftStep]
    channelsWrap["rightstep"] = [rightStep]
    channelsWrap = Sampler.sampleChannelsWrap(channelsWrap, 2)
    Formatter.writeDataWrap(channelsWrap, 3)
開發者ID:maeglin89273,項目名稱:EEG-ML-Classification,代碼行數:32,代碼來源:Tagger.py

示例2: sampleChannelsStream

# 需要導入模塊: import Formatter [as 別名]
# 或者: from Formatter import writeDataWrap [as 別名]
__author__ = 'maeglin89273'

import Formatter

DEFAULT_SAMPLING_RATE = 5


def sampleChannelsStream(channelData, samplingRate):

    sampledData = [[] if channel else None for channel in channelData]

    for (i, channelValues) in enumerate(zip(*filter(lambda channel: bool(channel), channelData))):
        if i % samplingRate == 0:
            for (j, channelNum) in enumerate((num for num in xrange(len(channelData)) if channelData[num])):
                sampledData[channelNum].append(channelValues[j])

    return sampledData


def sampleChannelsWrap(channelsWrap, samplingRate):
    for category in channelsWrap:
        for fileNum, channelData in enumerate(channelsWrap[category]):
            sampledData = sampleChannelsStream(channelData, samplingRate)
            channelsWrap[category][fileNum] = sampledData

    return channelsWrap

if __name__ == "__main__":
    channelsWrap = Formatter.format({"righthand": 4, "sleep": 1}, [1, 2, 3, 4, 8])
    Formatter.writeDataWrap(sampleChannelsWrap(channelsWrap, DEFAULT_SAMPLING_RATE), 2)
開發者ID:maeglin89273,項目名稱:EEG-ML-Classification,代碼行數:32,代碼來源:Sampler.py


注:本文中的Formatter.writeDataWrap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。