Exemple #1
0
def testResultSerialization():
    result = getRandomResult()

    assertMapArrayMatch(result.xingCharMap, result.xingCharSortedArray)
    assertMapArrayMatch(result.xingMap, result.xingSortedArray)
    assertMapArrayMatch(result.mingCharMap, result.mingCharSortedArray)
    assertMapArrayMatch(result.mingMap, result.mingSortedArray)
    assertMapArrayMatch(result.xingMingMap, result.xingMingSortedArray)

    result.writeToFile(fileForResultTest)

    newResult = Result()
    newResult.readFromFile(fileForResultTest)
    assertResultEqual(result, newResult)

    result.readableWriteToFile(dirForResultTest)
Exemple #2
0
def getRandomResult(length=1000):
    result = Result()

    result.glbalInfo = getRandomGlobalNameInfo()
    result.xingCharMap = getRandomResultMap(length)
    result.xingMap = getRandomResultMap(length)
    result.mingCharMap = getRandomResultMap(length)
    result.mingMap = getRandomResultMap(length)
    result.xingMingMap = getRandomResultMap(length)

    result.caculate()
    
    return result
Exemple #3
0
 def _importRankArrayFromFile(self, f, arrayName):
     items = Result.readArrayFromFileGenerator(f)
     for item in items:
         key = item[0]
         rank = item[1] + 1 # Rank is 1 based
         self._addRankArrayRecord(key, rank, arrayName)
Exemple #4
0
 def _importMapFromFile(self, f, tableName):
     infos = Result.readMapFromFileGenerator(f)
     for info in infos:
         self._importInfo(info, tableName)