Пример #1
0
def add_athlete(athlete_id, division):
    if Division(division).add_athlete(athlete_id):
        athlete = Athlete(athlete_id)

        return json.dumps(athlete.get())
    else:
        return 'Incorrect gender for Division'
Пример #2
0
    def test_Division_add_athlete_whenCalledWithNewAthlete_addsToCorrectDivision(
            self):
        division = Division('tbotr')

        division.add_athlete('123456')

        self.assertTrue('123456' in redisclient.smembers('tbotr_members'))

        division.remove_athlete_from_division('tbotr', '123456')
Пример #3
0
from suma import Suma
from resta import Resta
from division import Division
from multiplicacion import Multiplicacion
operando_uno = int(input("Ingrese el primer operando: "))
operando_dos = int(input("Ingrese el segundo operando: "))
suma = Suma(operando_uno, operando_dos)
resta = Resta(operando_uno, operando_dos)
division = Division(operando_uno, operando_dos)
multiplicacion = Multiplicacion(operando_uno, operando_dos)
print("El resultado de la suma es: ", suma.sumar())
print("El resultado de la resta es: ", resta.restar())
print("El resultado de la multiplicacion es: ", multiplicacion.multiplicar())
print("El resultado de la division es: ", division.dividir())
Пример #4
0
 def division(self):
     self.withdraw()
     Division(self, self.main_root)
    while True:
        try:
            letter = input(
                "Would you like to make another calculation (Y,N): ")
            if letter != 'Y' and letter != 'y' and letter != 'N' and letter != 'n':
                raise ValueError
            break
        except ValueError:
            print("Oops!  That was no valid symbol.  Try again...")

    return letter


while True:

    symbol = operant()

    if symbol == '+':
        print("Result: " + str(afronden(Addition(num_input(), num_input()))))
    elif symbol == '-':
        print("Result: " +
              str(afronden(Subtraction(num_input(), num_input()))))
    elif symbol == '*':
        print("Result: " +
              str(afronden(Multiplication(num_input(), num_input()))))
    elif symbol == '/':
        print("Result: " + str(afronden(Division(num_input(), num_input()))))

    antwoord = yes_no()
    if antwoord == 'N' or antwoord == 'n':
        break
Пример #6
0
    temperature = initial_temperature
    current_division = initial_division
    current_distance = current_division.count_distance()
    best_division = current_division
    best_distance = current_distance
    temperature_change = 1 - temperature_change_factor
    while time() < end_time:
        new_division = get_neighbour(current_division)
        new_distance = new_division.count_distance()
        temperature *= temperature_change
        if (new_distance < current_distance
                or (new_distance >= current_distance
                    and random.random() < probability_for_worse_solution())):
            current_division = new_division
            current_distance = current_division.count_distance()
            if current_distance < best_distance:
                best_division = current_division
                best_distance = current_distance

    return best_division


if __name__ == '__main__':
    t, n, m, k = input().split()
    t, n, m, k = float(t), int(n), int(m), int(k)
    matrix = np.array([input().split() for i in range(n)], np.uint8(1))
    Division.data = matrix
    result = simulated_annealing(t, Division(k))
    print(result.count_distance())
    print(result, file=sys.stderr)
Пример #7
0
def read_info():
    """Reads in all of the files apart from matches and returns: void"""
    matchFileTour = os.path.join(my_path, ".."+data_paths+"TOURNAMENT INFO.csv")
    DivInfo = os.path.join(my_path, ".."+data_paths+"DIVISION INFO.csv")
    ranking_points = os.path.join(my_path, ".."+data_paths+"RANKING POINTS.csv")

    ranking_list = []
    with open(ranking_points, 'r') as csvFile:
        reader = csv.DictReader(csvFile)
        for row in reader:
            temp = int(row["Tournament Ranking Points"])
            if temp is not None:
                ranking_list.sort()
                if (ex.binary_search(ranking_list, temp) == None):
                    ranking_list.append(temp)
            ranking_list.sort()
    # Find out the number of columns in the tournament info csv
    number_columns = 0
    with open(matchFileTour, 'r') as f1:
        csvlines = csv.reader(f1, delimiter=',')
        for lineNum, line in enumerate(csvlines):
            if lineNum == 0:
                number_columns = (len(line))
                break
            break

    # Find all of the seasons in the file and load them into seasons
    season_list = []
    with open(matchFileTour, 'r') as csvFile:
        reader = csv.DictReader(csvFile)
        for row in reader:
            temp = row["Season"]
            if temp is not None:
                if(ex.binary_search(season_list,temp) == None):
                    season_list.append(temp)
    for i in season_list:
        seasons.append(Season(i,ranking_list))

    # Load in all tournaments to their respective seasons
    # Also finds which places get prize money
    for i in seasons:
        with open(matchFileTour, 'r') as csvFile:
            reader = csv.DictReader(csvFile)
            for row in reader:
                if(row["Season"] == i.get_name()):
                    temp = []
                    row_name = "Place "
                    number_places = (number_columns - 3)
                    for x in range(0,number_places):
                        temp.append(float(row[row_name+str(x+1)].replace(',','')))
                    new_list = list(set(temp)) # Find unique elements in list

                    i.add_tournament(Tournament(row["Tournament"],row["Difficulty"],new_list))

    # Load in divisions for each tournament
    for x in seasons:
        for j in x.get_tournaments():
            with open(DivInfo, 'r') as csvFile:
                reader = csv.DictReader(csvFile)
                for row in reader:
                    if (row["Season"] == x.get_name()) and (row["Tournament"] == j.get_name()):
                        j.add_division(Division(row["Division"],row["Best Of"],row["Players"]))

    # Add players to seasons
    list_all_divisions = []
    for x in seasons:
        for j in x.get_tournaments():
            for k in j.get_divisions():
                if list_all_divisions is not None: # Find all of the divisions in the season
                    list_all_divisions.sort()
                    if(ex.binary_search(list_all_divisions,k.get_player_type()) == None):
                        list_all_divisions.append(str(k.get_player_type()))
        for i in list_all_divisions:
            with open(os.path.join(my_path, ".."+data_paths+"PLAYERS "+i+".csv"), 'r') as csvFile:
                reader = csv.DictReader(csvFile)
                temp = []
                for row in reader:
                    player = Player(row["Player"],i)
                    player.set_number_tournaments(x.number_tournaments())
                    temp.append(player)
            x.add_participants(temp)