stop = range_[-1] while True: ui = input("Input {:15}({:2} <= {:1} <= {:2}): ".format( description, start, variable, stop)) try: ui = int(ui) except ValueError: print("Input type must be int") continue if ui not in range_: print("Input must be between {} and {}".format(start, stop)) continue return ui if __name__ == '__main__': # get input from user print("Enter a number to be factored:") P = sanitised_input("product", "P", range(2**6)) # send problem to QPU print("Running on QPU") output = factor(P, False) # output results pprint(output)
def test_factor_output(self): P = randint(0, 2**6-1) output = factor(P) jsonschema.validate(output, json_schema)
def test_factor_validity(self): for P in [12, 21, 49]: # {a*b for a in range(2**3) for b in range(2**3)}: output = factor(P) self.assertTrue(output['results'][0]['valid'])
while True: ui = input("Input {:15}({:2} <= {:1} <= {:2}): ".format( description, start, variable, stop)) try: ui = int(ui) except ValueError: print("Input type must be int") continue if ui not in range_: print("Input must be between {} and {}".format(start, stop)) continue return ui if __name__ == '__main__': # get input from user # print("Enter a number to be factored:") # P = sanitised_input("product", "P", range(2 ** 6)) P = int(sys.argv[1]) # send problem to QPU print("Running on QPU") output = factor(P) # output results pprint(output)