Exemplo n.º 1
0
 def test_pick0and100(self):
     output = True
     filepaths = glob.glob("tmp/log_MakerMain/*")
     # データ取得
     datas = manager.getStateswithViewPoint(filepaths, [], [])
     stateDict = {}
     stateDict["before"] = []
     stateDict["after"] = []
     for count, d in enumerate(datas):
         stateDict["before"].append(datas[d][0])
         stateDict["after"].append(datas[d][100])
         if count >= 49:
             break
     for _ in range(3):
         tempDict = {}
         tempDict["before"] = []
         tempDict["after"] = []
         for count, d in enumerate(datas):
             tempDict["before"].append(datas[d][0])
             tempDict["after"].append(datas[d][100])
             if count >= 49:
                 break
         if len(stateDict["before"]) != len(tempDict["before"]):
             output = False
             break
         for i in range(len(stateDict["before"])):
             output = output and (stateDict["before"][i]["step"]
                                  == tempDict["before"][i]["step"])
         if output == False:
             break
     self.assertTrue(output)
Exemplo n.º 2
0
 def test_ViewPointManager_getStatewithViewPoint(self):
     output = True
     filepaths = glob.glob("tmp/log_MakerMain/*")
     # データ取得
     datas = manager.getStateswithViewPoint(filepaths, [], [])
     for _ in range(3):
         temp = manager.getStateswithViewPoint(filepaths, [], [])
         for fname in datas:
             if len(datas[fname]) != len(temp[fname]):
                 output = False
                 break
             for i in range(len(datas[fname])):
                 for o in datas[fname][i]:
                     a = datas[fname][i][o]
                     b = temp[fname][i][o]
                     if type(a) == type(np.array([])):
                         output = output and (np.allclose(a, b))
                     else:
                         output = output and (a == b)
         if output == False:
             break
     self.assertTrue(output)
Exemplo n.º 3
0
def run():
    if os.path.exists(DIR_PATH) == False:
        os.mkdir(DIR_PATH)
    print("start MAINSYU")
    filepaths = glob.glob("tmp/log_MakerMain/*")
    dirname = "3-2000-10-0.11-200-5-5-False-100"
    # dirname   = "CHEATNANODA_results"
    # データ取得
    datas = manager.getStateswithViewPoint(filepaths, [], [])
    pm = ParamManager("MAINSYU")
    pm.printREADME("MAINSYU")
    p = pm.firstParams()
    paramNum = len(p)

    count = 0
    while True:
        print("[MAINSYU]iteration:" + str(count))
        count += 1
        if p == NOPARAMS:
            break
        print("---------- : make DP_main_results.dill")
        with open("tmp/log_MakerMain/dills/DP_main_results.dill", "wb") as f:
            # 指定したディレクトリの境界情報を取得
            interdict = matching.getInterDict(dirname)
            interdict = matching.pruningInterDict(interdict)
            dill.dump(matching.DP_main(datas, interdict, \
                sampleSize=pm.pick(p, "sampleSize"), \
                n_iter=pm.pick(p, "n_iter"),\
                distError=pm.pick(p, "distError")), f)
        print("+++++----- : save Histogram as png")
        summarizer.run([DIR_PATH] +
                       [p[name] for name in pm.getParamNameList()])
        print("++++++++++ : Finished")
        p = pm.nextParams()
    # kirei で result.csv を p, r, f に集計
    for y in range(paramNum):
        for x in range(y):
            kirei.execute(x, y)
Exemplo n.º 4
0
            if len(rests[fname]) == 0:
                print("[predictMatching]DP_main:Empty - " + fname)
                for i in range(len(stateDict["fname"])):
                    if stateDict["fname"][i] == fname:
                        stateDict["before"].pop(i)
                        stateDict["fname"].pop(i)
                        break
                continue
    return output


if __name__ == "__main__":
    filepaths = glob.glob("tmp/forTest_predictMatching/*")
    # filepaths = glob.glob("tmp/log_MakerMain/*")
    # データ取得
    datas = manager.getStateswithViewPoint(filepaths, [], [])
    stateDict = {}
    stateDict["before"] = []
    stateDict["after"] = []
    stateDict["fname"] = []
    stateDict["isadd"] = []

    for count, d in enumerate(sorted(list(datas.keys()))):
        stateDict["before"].append(datas[d][0])
        stateDict["after"].append(datas[d][200])
        stateDict["fname"].append(d)
        stateDict["isadd"].append(False)
        if count >= 249:
            break
        if count >= 239:
            stateDict["before"].append(datas[d][0])