Example #1
0
    def post(self):
        # gather registration info #
        username = cgi.escape(self.request.get('username'))
        password = cgi.escape(self.request.get('password'))
        avatar = self.request.get('avatar')
        tagline = cgi.escape(self.request.get('tagline'))

        # Run Validation #
        validate = Validation('register', username=username,
                              password=password, avatar=avatar,
                              tagline=tagline)
        validate.run_validation()
        if self.check_user(username):
            # check if username is duplicate #
            self.redirect('/register.html')
        elif validate.error_return():
            # set error flag if any #
            Register.error = validate.error_return()
            self.redirect('/register.html')
        elif not Register.error:
            # set user as active #
            SetUser(user=username, avatar=avatar, tagline=tagline)
            # add user info to database. #
            new_user = Users(user=username,
                             password=password,
                             link=avatar,
                             tagline=tagline)
            new_user.put()
            time.sleep(set_time)
            self.redirect('/forum.html')
Example #2
0
    def post(self):
        word = cgi.escape(self.request.get('word'))
        definition = cgi.escape(self.request.get('definition'))
        # validate information #
        validate = Validation('', word=word, definition=definition)
        validate.run_validation()

        if not validate.error_return():
            # looks good now add to DB #
            define = Definitions(word=word, definition=definition)
            define.put()
            time.sleep(set_time)
            Base.login = True
            self.redirect('/definitions.html')
        else:
            # set error flag #
            Definition.error = validate.error_return()
            self.redirect('definitions.html')
Example #3
0
    def post(self):
        # gather registration info #
        username = cgi.escape(self.request.get('username'))
        password = cgi.escape(self.request.get('password'))
        avatar = self.request.get('avatar')
        tagline = cgi.escape(self.request.get('tagline'))

        # Run Validation #
        validate = Validation('register',
                              username=username,
                              password=password,
                              avatar=avatar,
                              tagline=tagline)
        validate.run_validation()
        if self.check_user(username):
            # check if username is duplicate #
            self.redirect('/register.html')
        elif validate.error_return():
            # set error flag if any #
            Register.error = validate.error_return()
            self.redirect('/register.html')
        elif not Register.error:
            # set user as active #
            SetUser(user=username, avatar=avatar, tagline=tagline)
            # add user info to database. #
            new_user = Users(user=username,
                             password=password,
                             link=avatar,
                             tagline=tagline)
            new_user.put()
            time.sleep(set_time)
            self.redirect('/forum.html')
Example #4
0
def genetic_algo(nr_dict, pizzas):
    """
    The matrix representing the solution of this problem is 
    on the column the pizza_id and on the row the group_id.
    If an entry = true then that pizza_id will get delivered 
    to that group_id. 
    """

    val = Validation(nr_dict, pizzas)
    dimensions = (nr_dict['t2'] + nr_dict['t3'] + nr_dict['t4']) * len(pizzas)
    print(dimensions)
    model = ga(function=val.validate,
               dimension=dimensions,
               variable_type='bool')

    model.run()
Example #5
0
    def post(self):
        word = cgi.escape(self.request.get('word'))
        definition = cgi.escape(self.request.get('definition'))
        # validate information #
        validate = Validation('', word=word, definition=definition)
        validate.run_validation()

        if not validate.error_return():
            # looks good now add to DB #
            define = Definitions(word=word, definition=definition)
            define.put()
            time.sleep(set_time)
            Base.login = True
            self.redirect('/definitions.html')
        else:
            # set error flag #
            Definition.error = validate.error_return()
            self.redirect('definitions.html')
Example #6
0
if not args.val:
    trainer = Trainer(type=args.type,
                      dataset=args.dataset,
                      split=args.split,
                      lr=args.lr,
                      diter=args.diter,
                      vis_screen=args.vis_screen,
                      save_path=args.save_path,
                      l1_coef=args.l1_coef,
                      l2_coef=args.l2_coef,
                      pre_trained_disc=args.pre_trained_disc,
                      pre_trained_gen=args.pre_trained_gen,
                      batch_size=args.batch_size,
                      num_workers=args.num_workers,
                      epochs=args.epochs)

    if not args.inference:
        trainer.train(args.cls)
    else:
        trainer.predict()

else:
    validation = Validation(type=args.type,
                            dataset=args.dataset,
                            vis_screen=args.vis_screen,
                            pre_trained_gen=args.pre_trained_gen,
                            batch_size=args.batch_size,
                            num_workers=args.num_workers,
                            epochs=args.epochs)
    validation.validate()
Example #7
0
 def __init__(self):
     self.validate = Validation()
Example #8
0
class Math():
    def __init__(self):
        self.validate = Validation()

    #This fuction will sum(+) x and y. Assign it into result variable, then print it.
    def sum(self):
        #call function from validation class and assign the value returned to variable
        x = self.validate.validate_first_number()
        y = self.validate.validate_second_number()
        result = x + y
        print("\nThe sum of the two number is", result)

    #This fuction will multiplicate(*) x and y. Assign it into result variable, then print it.
    def multiplication(self):
        #call function from validation class and assign the value returned to variable
        x = self.validate.validate_first_number()
        y = self.validate.validate_second_number()
        result = x * y
        print("\nThe multiplication of the two number is", result)

    #This function will divide(/) x and y. Assing it into divison variable, then print it.
    def division(self):
        #call function from validation class and assign the value returned to variable
        x = self.validate.validate_first_number()
        y = self.validate.validate_second_number()
        division = x / y
        print("\nThe divison of the two number is", division)

    #While divison will return a float, you can use floor divison(//) which will remove the fraction.
    def division_fractional(self):
        #call function from validation class and assign the value returned to variable
        x = self.validate.validate_first_number()
        y = self.validate.validate_second_number()
        division = x // y
        print("\nThe fraction divison of the two number is", division)

    """ This function will divide x and y then take the remainder from the result of divison.
            Assign it into remainder variable, then print it. """

    def remainder(self):
        #call function from validation class and assign the value returned to variable
        x = self.validate.validate_first_number()
        y = self.validate.validate_second_number()
        remainder = x % y
        print("\nThe remainder of the two number is", remainder)

    """This function will power or square x and y based on user input. 
       Assign it into square variable, then print it. """

    def square(self):
        #call function from validation class and assign the value returned to variable
        x = self.validate.validate_first_number()
        y = self.validate.validate_second_number()
        square = x**y
        print("\nThe square/powered of the two number is", square)

    """ This function will power or square x and y based on user input. 
           Assign it into square variable, then print it. """

    def substraction(self):
        #call function from validation class and assign the value returned to variable
        x = self.validate.validate_first_number()
        y = self.validate.validate_second_number()
        substraction = x - y
        print("\nThe subsrtraction of the two number is", substraction)