def randSimpleDict(): pyDict = {} length = randint(0, MAX_DICT_LENGTH) for i in range(length): pyDict[choice(simpleTypePool)()[0]] = choice(simpleTypePool)()[0] #Overwriting keys isn't really a big deal, since we are choosing the length randomly anyway. return (pyDict, toScala(pyDict))
def randSimpleDict(): pyDict = {} length = randint(0,MAX_DICT_LENGTH) for i in range(length): pyDict[choice(simpleTypePool)()[0]]=choice(simpleTypePool)()[0] #Overwriting keys isn't really a big deal, since we are choosing the length randomly anyway. return (pyDict,toScala(pyDict))
def randSimpleTuple(): pyList = [] length = randint(1,MAX_TUPLE_LENGTH) for i in range(length): pyList.append(choice(simpleTypePool)()[0]) tup = tuple(pyList) return (tup,toScala(tup))
def randSimpleTuple(): pyList = [] length = randint(1, MAX_TUPLE_LENGTH) for i in range(length): pyList.append(choice(simpleTypePool)()[0]) tup = tuple(pyList) return (tup, toScala(tup))
def randList(depth=1): pyList = [] length = randint(0,MAX_LIST_LENGTH) if depth >= MAX_DEPTH: for i in range(length): pyList.append(choice(completeSimplePool)()[0]) else: for i in range(length): if random() < RECURSE_RATE: pyList.append(choice(recursiveContainerPool)(depth+1)[0]) else: pyList.append(choice(completeSimplePool)()[0]) return (pyList,toScala(pyList))
def randList(depth=1): pyList = [] length = randint(0, MAX_LIST_LENGTH) if depth >= MAX_DEPTH: for i in range(length): pyList.append(choice(completeSimplePool)()[0]) else: for i in range(length): if random() < RECURSE_RATE: pyList.append(choice(recursiveContainerPool)(depth + 1)[0]) else: pyList.append(choice(completeSimplePool)()[0]) return (pyList, toScala(pyList))
def randTuple(depth=1): pyList = [] length = randint(1,MAX_TUPLE_LENGTH) if depth >= MAX_DEPTH: for i in range(length): pyList.append(choice(simpleTypePool)()[0]) else: for i in range(length): if random() < RECURSE_RATE: pyList.append(choice(recursiveContainerPool)(depth+1)[0]) else: pyList.append(choice(completeSimplePool)()[0]) tup = tuple(pyList) return (tup,toScala(tup))
def randTuple(depth=1): pyList = [] length = randint(1, MAX_TUPLE_LENGTH) if depth >= MAX_DEPTH: for i in range(length): pyList.append(choice(simpleTypePool)()[0]) else: for i in range(length): if random() < RECURSE_RATE: pyList.append(choice(recursiveContainerPool)(depth + 1)[0]) else: pyList.append(choice(completeSimplePool)()[0]) tup = tuple(pyList) return (tup, toScala(tup))
def randDict(depth=1): pyDict = {} length = randint(0,MAX_DICT_LENGTH) if depth >= MAX_DEPTH: for i in range(length): pyDict[choice(simpleTypePool)()[0]] = choice(simpleTypePool)()[0] else: key=None value=None for i in range(length): key = choice(simpleTypePool)()[0] if random() < RECURSE_RATE: value = choice(recursiveContainerPool)(depth+1)[0] else: value = choice(completeSimplePool)()[0] pyDict[key]=value return (pyDict,toScala(pyDict))
def randDict(depth=1): pyDict = {} length = randint(0, MAX_DICT_LENGTH) if depth >= MAX_DEPTH: for i in range(length): pyDict[choice(simpleTypePool)()[0]] = choice(simpleTypePool)()[0] else: key = None value = None for i in range(length): key = choice(simpleTypePool)()[0] if random() < RECURSE_RATE: value = choice(recursiveContainerPool)(depth + 1)[0] else: value = choice(completeSimplePool)()[0] pyDict[key] = value return (pyDict, toScala(pyDict))
def randLong128(): num=randInt(128) return (long(num),toScala(num))
def randLong64(): num=randInt(64) #Need to convert to long because some Python ints may not fit into a Scala Int. #This is important for when toArray tries to implicitly determine the type of the array. return (long(num),toScala(num))
def randSimpleList(): pyList = [] length = randint(0,MAX_LIST_LENGTH) for i in range(length): pyList.append(choice(simpleTypePool)()[0]) return (pyList,toScala(pyList))
def randLong128(): num = randInt(128) return (long(num), toScala(num))
def randLong64(): num = randInt(64) #Need to convert to long because some Python ints may not fit into a Scala Int. #This is important for when toArray tries to implicitly determine the type of the array. return (long(num), toScala(num))
def randSimpleList(): pyList = [] length = randint(0, MAX_LIST_LENGTH) for i in range(length): pyList.append(choice(simpleTypePool)()[0]) return (pyList, toScala(pyList))