def base_case_test(self):
        """base_case_test: this test is used to check the function for searching the maximum value -- using artificial data"""

        ARRAY_TUPLED = namedtuple(
            'ARRAY_TUPLED', 'AXC AYC AZC GXC GYC GZC AVMC GVMC'
            ' AXT AYT AZT GXT GYT GZT AVMT GVMT ANNOT')
        target_list_base = [[[1, 1, 1, 1, 1, 1, 1, 1, 0],
                             [1, 1, 1, 1, 1, 1, 1, 1, 0]],
                            [[2, 2, 2, 2, 2, 2, 2, 2, 0],
                             [2, 2, 2, 2, 2, 2, 2, 2, 2, 0]],
                            [[3, 3, 3, 3, 3, 3, 3, 3, 2],
                             [3, 3, 3, 3, 3, 3, 3, 3, 0]]]

        source_list = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],
                       [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
                       [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]]

        data_pool_base = []

        for temp_data in source_list:
            source_line = ARRAY_TUPLED(*temp_data)
            data_pool_base.append(source_line)

        result_list = searchmax.micAn(data_pool_base)

        for i in range(len(target_list_base)):
            for j in range(len(target_list_base[0])):
                temp = target_list_base[0]
                for k in range(len(temp)):
                    self.assertAlmostEqual(target_list_base[i][j][k],
                                           result_list[i][j][k])
def micro_annotate_search(sourceFile):

    flag = False
    counter = 0
    tempData = []
    output = []
    quemican = deque
    ARRAY_TUPLED = namedtuple('ARRAY_TUPLED', 'AXC AYC AZC GXC GYC GZC AVMC GVMC'
                                 ' AXT AYT AZT GXT GYT GZT AVMT GVMT DUMMY ANNOT') #change this for OJ's data, add one element before ANNOT

    print('start to re-annotate')
    print('Please waiting! ....')

    with open(sourceFile) as objectFile:
        for line in objectFile:

            dataread = line.split()

            ori_data = [float(x) for x in dataread[:len(dataread)]]
            data = ARRAY_TUPLED(*ori_data)

            if data.ANNOT in FALL_SET: #change this for OJ's data

                tempData.append(data)

                if flag == False:
                    flag = True


            elif (flag is True) and (data.ANNOT not in FALL_SET) :

                micanDat = searchmax.micAn(tempData) #search for maximum value
                for x in range(len(micanDat)):
                    output.append(micanDat[x])

                flag = False
                tempData = []
                output.append(reannotright.reanotright(data))

            else:

                saveData = reannotright.reanotright(data)
                output.append(saveData)

    #write_csv(destFile, output)
    return output

    print('finish')
def micro_annotate_search(sourceFile):

    flag = False
    counter = 0
    tempData = []
    output = []
    quemican = deque
    ARRAY_TUPLED = namedtuple(
        'ARRAY_TUPLED', 'AXC AYC AZC GXC GYC GZC AVMC GVMC'
        ' AXT AYT AZT GXT GYT GZT AVMT GVMT ANNOT')

    print('start to re-annotate')
    with open(sourceFile) as objectFile:
        for line in objectFile:

            dataread = line.split()

            ori_data = [float(x) for x in dataread[:len(dataread)]]
            data = ARRAY_TUPLED(*ori_data)

            if data.ANNOT in FALL_SET:  #change this for OJ's data

                tempData.append(data)

                if not flag:
                    flag = True

            elif flag and (data.ANNOT not in FALL_SET):

                micanDat = searchmax.micAn(tempData)  #search for maximum value
                for x in range(len(micanDat)):
                    output.append(micanDat[x])

                flag = False
                tempData = []
                output.append(reannotright.reanotright(data))

            else:

                saveData = reannotright.reanotright(data)
                output.append(saveData)

    #write_csv(destFile, output)
    return output
示例#4
0
    def micro_test(self):

    """micro_test: this test is used to check the function for searching the maximum value"""

        ARRAY_TUPLED = namedtuple('ARRAY_TUPLED', 'AXC AYC AZC GXC GYC GZC AVMC GVMC'
                                 ' AXT AYT AZT GXT GYT GZT AVMT GVMT ANNOT')

        data_pool =[]

        targetList = [[[0.9398233871,0.1540502688,-0.1714986559,2.5631636763,1.4646649579,-1.4646649579,0.9676834571,
                              3.2954961553,2],[0.9474754032,0.0440576613,0.2685430108,0.7323324789,-1.8308311974,0.3661662395,
                              0.9857819566,2.0055750916,0]],
                      [[0.9261432796,0.1331620968,-0.1741370968,2.9293299158,
                              2.9293299158,-1.8308311974,0.9517338109,4.5292262456,0],[0.9685012097,0.0307068548,0.2496505376,0.3661662395,
                              -0.7323324789,0.7323324789,1.0006312483,1.0984987184,2]],
                      [[0.9179352151,0.1305510753,-0.1926061828,1.0984987184,
                              5.1263273526,-1.0984987184,0.9469666224,5.3565502887,2],[0.9553600806,0.0146858871,0.2577473118,-0.7323324789,
                              -1.4646649579,0.7323324789,0.9896273216,1.7938408955,0]]]

        rawsourceList = [[0.9398233871,0.1540502688,-0.1714986559,2.5631636763,1.4646649579,-1.4646649579,0.9676834571,3.2954961553,
                       0.9474754032,0.0440576613,0.2685430108,0.7323324789,-1.8308311974,0.3661662395,0.9857819566,2.0055750916,2],
                      [0.9261432796,0.1331620968,-0.1741370968,2.9293299158,2.9293299158,-1.8308311974,0.9517338109,4.5292262456,
                       0.9685012097,0.0307068548,0.2496505376,0.3661662395,-0.7323324789,0.7323324789,1.0006312483,1.0984987184,2],
                      [0.9179352151,0.1305510753,-0.1926061828,1.0984987184,5.1263273526,-1.0984987184,0.9469666224,5.3565502887,
                       0.9553600806,0.0146858871,0.2577473118,-0.7323324789,-1.4646649579,0.7323324789,0.9896273216,1.7938408955,2]]

        for temp_data in rawsourceList:
            sourceList = ARRAY_TUPLED(*temp_data)
            data_pool.append(sourceList)

        resultList = searchmax.micAn(data_pool)
        #self.assertAlmostEqual(targetListnonFalls,sourceListnonFalls)


        for i in range(len(targetList)):
            for j in range(len(targetList[0])):
                temp = targetList[0]
                for k in range(len(temp)):
                    self.assertAlmostEqual(targetList[i][j][k],resultList[i][j][k])
    def micro_test(self):

        ARRAY_TUPLED = namedtuple('ARRAY_TUPLED', 'AXC AYC AZC GXC GYC GZC AVMC GVMC'
                                 ' AXT AYT AZT GXT GYT GZT AVMT GVMT ANNOT')

        data_pool =[]

        targetList = [[[0.9398233871,0.1540502688,-0.1714986559,2.5631636763,1.4646649579,-1.4646649579,0.9676834571,
                              3.2954961553,2],[0.9474754032,0.0440576613,0.2685430108,0.7323324789,-1.8308311974,0.3661662395,
                              0.9857819566,2.0055750916,0]],
                      [[0.9261432796,0.1331620968,-0.1741370968,2.9293299158,
                              2.9293299158,-1.8308311974,0.9517338109,4.5292262456,0],[0.9685012097,0.0307068548,0.2496505376,0.3661662395,
                              -0.7323324789,0.7323324789,1.0006312483,1.0984987184,2]],
                      [[0.9179352151,0.1305510753,-0.1926061828,1.0984987184,
                              5.1263273526,-1.0984987184,0.9469666224,5.3565502887,2],[0.9553600806,0.0146858871,0.2577473118,-0.7323324789,
                              -1.4646649579,0.7323324789,0.9896273216,1.7938408955,0]]]

        rawsourceList = [[0.9398233871,0.1540502688,-0.1714986559,2.5631636763,1.4646649579,-1.4646649579,0.9676834571,3.2954961553,
                       0.9474754032,0.0440576613,0.2685430108,0.7323324789,-1.8308311974,0.3661662395,0.9857819566,2.0055750916,2],
                      [0.9261432796,0.1331620968,-0.1741370968,2.9293299158,2.9293299158,-1.8308311974,0.9517338109,4.5292262456,
                       0.9685012097,0.0307068548,0.2496505376,0.3661662395,-0.7323324789,0.7323324789,1.0006312483,1.0984987184,2],
                      [0.9179352151,0.1305510753,-0.1926061828,1.0984987184,5.1263273526,-1.0984987184,0.9469666224,5.3565502887,
                       0.9553600806,0.0146858871,0.2577473118,-0.7323324789,-1.4646649579,0.7323324789,0.9896273216,1.7938408955,2]]

        for temp_data in rawsourceList:
            sourceList = ARRAY_TUPLED(*temp_data)
            data_pool.append(sourceList)

        resultList = searchmax.micAn(data_pool)
        #self.assertAlmostEqual(targetListnonFalls,sourceListnonFalls)


        for i in range(len(targetList)):
            for j in range(len(targetList[0])):
                temp = targetList[0]
                for k in range(len(temp)):
                    self.assertAlmostEqual(targetList[i][j][k],resultList[i][j][k])