default='/data/', help="data file path", required=False) parser.add_argument('--result', default='/output/result.txt', help="result file path", required=False) args = parser.parse_args() config = create_config(args.config) config.set("data", "test_data_path", args.input) fs = ",".join(os.listdir(args.input)) print(fs) config.set("data", "test_file_list", fs) gpu_list = [] if args.gpu: os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu device_list = args.gpu.split(",") for a in range(0, len(device_list)): gpu_list.append(int(a)) parameters = init_all(config, gpu_list, args.checkpoint, "test") predict = test(parameters, config, gpu_list) json.dump(predict, open(args.result, "w", encoding="utf8"), ensure_ascii=False, sort_keys=True, indent=2)
import sys sys.path.append('..') from test_tool import test from HashTable import HashMap h = HashMap() allTestPassed = True failedTestCases = [] #Testing Insertion and Lookups testA = test(HashMap()) expectedResult = [] testA.executeCommands( "insert", [[1, "one"], [2, "two"], [3, "three"], [4, "four"], [5, "five"]], str(expectedResult), False, True) #Not a Truth Assertion/Skip Validation expectedResult = True testA.executeCommands("isIn", [5], expectedResult, True) expectedResult = "five" testA.executeCommands("lookup", [5], expectedResult, True) expectedResult = "one" testA.executeCommands("lookup", [1], expectedResult, True) #Validating Removals expectedResult = True testA.executeCommands("remove", [5], expectedResult, False, True) #Skip Validation of removal
import sys sys.path.append('..') from test_tool import test from trie import trieTree allTestPassed = True failedTestCases = [] #Bulk Insertion testA = test(trieTree()) expectedResult = [] testA.executeCommands("insert", ["hello","hellbent", "healthy", "hell", "pears", "pear", "race", "racecar"], str(expectedResult),False, True) #Not a Truth Assertion/Skip Validation expectedResult = True testA.executeCommands("isWord", ["hell"], expectedResult, True) expectedResult = True testA.executeCommands("isWord", ["race"], expectedResult, True) expectedResult = False testA.executeCommands("isWord", ["raceca"], expectedResult, True) expectedResult = True testA.executeCommands("isWord", ["racecar"], expectedResult, True) expectedResult = True testA.executeCommands("isWord", ["pear"], expectedResult, True) expectedResult = False testA.executeCommands("isWord", ["pea"], expectedResult, True)
import sys sys.path.append('..') from test_tool import test from linkedlist import LinkedList allTestPassed = True failedTestCases = [] testList = LinkedList() testA = test(testList) #Testing Bulk Insertion expectedResult = [1, 2, 3, 4, 5] testA.executeCommands("insertVal", [1, 2, 3, 4, 5], str(expectedResult)) allTestPassed = allTestPassed and testA.passed if not testA.passed: failedTestCases += testA.failedCases #Testing Bulk Insertion testList = LinkedList() testB = test(testList) expectedResult = [1, 2, 1, 4, 5, 8, 4, 7, 8] testB.executeCommands("insertVal", [1, 2, 1, 4, 5, 8, 4, 7, 8], str(expectedResult)) # Singleton Removal expectedResult = [2, 1, 4, 5, 8, 4, 7, 8] testB.executeCommands("removeOne", [1], str(expectedResult)) allTestPassed = allTestPassed and testB.passed
import sys sys.path.append('..') import test_tool as TEST import set as SET allTestPassed = True failedTestCases = [] testSet = SET.custom_set() testA = TEST.test(testSet) #Testing Bulk Insertion expectedResult = [{1: 0, 2: 1, 3: 2, 4: 3, 5: 4}, [1, 2, 3, 4, 5]] testA.executeCommands("insert", [1,2,3,4,5], str(expectedResult)) allTestPassed = allTestPassed & testA.passed failedTestCases.append(testA.failedCases) #Testing Removal expectedResult = [{5: 0, 2: 1, 3: 2, 4: 3}, [5, 2, 3, 4]] testA.executeCommands("remove", [1], str(expectedResult)) allTestPassed = allTestPassed and testA.passed failedTestCases.append(testA.failedCases) #Testing Inserting Duplicate Element expectedResult = [{5: 0, 2: 1, 3: 2, 4: 3}, [5, 2, 3, 4]] testA.executeCommands("insert", [5], str(expectedResult)) allTestPassed = allTestPassed and testA.passed failedTestCases.append(testA.failedCases) if allTestPassed: