Esempio n. 1
0
def get_constructor_name(cid, include_flag=True):
    """
    Gets the stylized version of the given constructor's name
    :param cid: Constructor ID
    :param include_flag: Whether to include the nationality flag in the constructor's name
    :return: String
    """
    global constructors
    if constructors is None:
        constructors = load_constructors()
    try:
        constructor = constructors.loc[cid]
        name = constructor["name"]
        if include_flag:
            nat = constructor["nationality"].lower()
            if nat in NATIONALITY_TO_FLAG.index:
                flag_t = NATIONALITY_TO_FLAG.loc[nat, "flag"]
                name = flag.flagize(f":{flag_t}: " + name)
            else:
                logging.warning(
                    f"Unknown nationality {nat}, constructor ID: {cid}")
        return name
    except KeyError:
        return "UNKNOWN"
Esempio n. 2
0
import pandas as pd
from data_loading.data_loader import load_races, load_fastest_lap_data, load_results, load_constructors, \
    load_constructor_standings
from mode.constructor import generate_positions_plot, get_layout, generate_circuit_performance_table, \
    generate_finishing_position_bar_plot, generate_wcc_position_bar_plot, generate_win_plot, \
    generate_driver_performance_table, generate_stats_layout
from utils import time_decorator, get_constructor_name

# Biggest JOKE of a "unit test" but it works
error_ids = []
times = {"cid": [], "time": []}

logger = logging.getLogger()
logger.disabled = True

constructors = load_constructors()
results = load_results()
constructor_standings = load_constructor_standings()
races = load_races()
fastest_lap_data = load_fastest_lap_data()
constructor_id = 6  # Ferrari

constructor_results = results[results["constructorId"] == constructor_id]
constructor_constructor_standings = constructor_standings[
    constructor_standings["constructorId"] == constructor_id]
constructor_rids = constructor_results["raceId"].unique()
constructor_races = races[races.index.isin(constructor_rids)].sort_values(
    by=["year", "raceId"])
constructor_years = constructor_races[constructor_races.index.isin(
    constructor_constructor_standings["raceId"])]
constructor_years = constructor_years["year"].unique()