def test_mismatching_list_lenght(self): z = [31.4, 14.6, 6.4, 28.3, 42.1, 15.3, 14.3, 18.9] w = [345, 168, 94, 187, 621, 255, 316] x = [65, 18, 0, 185, 87] y = [23, 18, 0, 98, 10, 14, 15] result = get_variables(z, w, x, y) expected_result = [ [7, 171.30000000000004, 1986, 355], [171.30000000000004, 4609.17, 53743.90000000001, 11202.0], [1986, 53743.90000000001, 741576, 114071], [355, 11202.0, 114071, 46343] ] self.assertEqual(result, expected_result)
def test_valid_input(self): z = [31.4, 14.6, 6.4, 28.3, 42.1, 15.3] w = [345, 168, 94, 187, 621, 255] x = [65, 18, 0, 185, 87, 0] y = [23, 18, 0, 98, 10, 0] result = get_variables(z, w, x, y) expected_result = [ [6, 138.10000000000002, 1670, 355], [138.10000000000002, 4047.4700000000003, 49225.100000000006, 11202.0], [1670, 49225.100000000006, 641720, 114071], [355, 11202.0, 114071, 46343] ] self.assertEqual(result, expected_result)
def check_tautology(input_string): is_tautology = True input_string = input_string.replace(" ", "") variables = get_variables( input_string) # get list of distinct variables in string input_combos = truth_combos( variables) # generate all possible input combinations for truth_values in input_combos: # iterate over all input combinations valued_statement = replace_variables( input_string, truth_values ) # replace variables with their corresponding truth values new_statement = replace_negation( valued_statement) # Replace all the negation operators directly postfix_expression = create_postfix( new_statement) # create a postfix expresion result = evaluate_postfix(postfix_expression) # Evaluate postfix if result != 1: is_tautology = False break return is_tautology
from src.User import User from src.Config import Config from src.ReverseProxied import ReverseProxied import utils import os, json, re, copy, traceback # Flask app app = Flask(__name__, static_url_path="/", static_folder="static", template_folder="templates") app.wsgi_app = ReverseProxied(app.wsgi_app) # Set variables and instantiate objects vars = utils.get_variables() app.secret_key = vars["FLASK_SECRET"] app.config["ABSOLUTE_URI"] = vars["ABSOLUTE_URI"] app.config["INSTANCES"] = Instances(vars["DOCKER_HOST"], vars["API_URI"]) app.config["CONFIG"] = Config() app.config["SESSION_COOKIE_DOMAIN"] = vars["ABSOLUTE_URI"].replace( "http://", "").replace("https://", "").split("/")[0] app.config["WTF_CSRF_SSL_STRICT"] = False # Declare functions for jinja2 app.jinja_env.globals.update(env_to_summary_class=utils.env_to_summary_class) app.jinja_env.globals.update(form_service_gen=utils.form_service_gen) app.jinja_env.globals.update( form_service_gen_multiple=utils.form_service_gen_multiple) app.jinja_env.globals.update( form_service_gen_multiple_values=utils.form_service_gen_multiple_values)
def test_complicated_brackets(self): expr = 'a&((a|b)&(b|c))' self.assertEqual(get_variables(expr), ['a', 'b', 'c'])
def test_repitition(self): expr = 'a&(a|b)' self.assertEqual(get_variables(expr), ['a', 'b'])
def test_simple_two_variable(self): expr = 'a&b' self.assertEqual(get_variables(expr), ['a', 'b'])
def test_single_variable(self): expr = 'a' self.assertEqual(get_variables(expr), ['a'])
def __init__(self, *args, **kwargs): self.routes = utils.get_routes() self.ipv4_address = utils.get_variables().get("ipv4_address", utils.get_ipv4_address()) self.ipv6_address = utils.get_variables().get("ipv6_address", utils.get_ipv6_address()) super().__init__(*args, **kwargs)
def get_policy_parameters(sess): weights = get_variables(scope="training_policy", filter='/b:') weights.extend(get_variables(scope="training_policy", filter='/W:')) return flatten_tensors(weights), weights