当前位置: 首页>>代码示例>>Python>>正文


Python Activity.duration方法代码示例

本文整理汇总了Python中models.Activity.duration方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.duration方法的具体用法?Python Activity.duration怎么用?Python Activity.duration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Activity的用法示例。


在下文中一共展示了Activity.duration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: filterActivityData

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import duration [as 别名]
def filterActivityData(dayOfActivityData):
    #filter
    walkingArray = []
    runningArray = []
    stationaryArray = []
    carArray = []
    unknownArray = []
    lastobj = Activity(duration=0,type=1)
    sumDuration = 0
    for actobj in dayOfActivityData:
        if actobj.type == 1:
            if lastobj.type == 1:
                if len(walkingArray) > 0:
                    sumDuration = actobj.duration + walkingArray[len(walkingArray)-1]
            else:
                sumDuration = actobj.duration
            walkingArray.append(sumDuration)
        elif actobj.type == 2:
            if lastobj.type == 2:
                if len(runningArray) > 0:
                    sumDuration = actobj.duration + runningArray[len(runningArray)-1]
            else:
                sumDuration = actobj.duration
            runningArray.append(sumDuration)
        elif actobj.type == 3:
            if lastobj.type == 3:
                if len(stationaryArray) > 0:
                    sumDuration = actobj.duration + stationaryArray[len(stationaryArray)-1]
            else:
                sumDuration = actobj.duration
            stationaryArray.append(sumDuration)
        elif actobj.type == 4:
            if lastobj.type == 4:
                if len(carArray) > 0:
                    sumDuration = actobj.duration + carArray[len(carArray)-1]
            else:
                sumDuration = actobj.duration
            carArray.append(sumDuration)
        else:    
            if lastobj.type == 5:
                if len(unknownArray) > 0:
                    sumDuration = actobj.duration + unknownArray[len(unknownArray)-1]
            else:
                sumDuration = actobj.duration
            unknownArray.append(sumDuration)
            lastobj = actobj
            lastobj.duration = actobj.duration
            lastobj.type = actobj.type
    filteredData = {"walking":walkingArray,"running":runningArray,"stationary":stationaryArray,"car":carArray,"unknown":unknownArray}
    return filteredData
开发者ID:i3l,项目名称:HIE_FALL_2013,代码行数:52,代码来源:vik.py


注:本文中的models.Activity.duration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。