Skip to content

Global Sub-Module

t3co.constants.Global

Global constants Stores paths to directories used for input files, as well as constants referenced throughout the code base

set_tco_intermediates()

This function sets path for TCO_INTERMEDIATES to save tsv files

Source code in src/t3co/constants/Global.py
66
67
68
69
70
71
72
73
74
75
76
77
def set_tco_intermediates():
    """
    This function sets path for TCO_INTERMEDIATES to save tsv files
    """
    global TCO_INTERMEDIATES

    # ./t3co/resources/f'vehicles/{vocation_scenario}/tco/tco_intermediates'
    TCO_INTERMEDIATES = (
        RESOURCES_FOLDERPATH / f"vehicles/{vocation_scenario}/tco/tco_intermediates"
    )
    if not TCO_INTERMEDIATES.exists():
        TCO_INTERMEDIATES.mkdir(parents=True)

set_tco_results()

This function sets path for TCO_RESULTS

Source code in src/t3co/constants/Global.py
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
def set_tco_results():
    """
    This function sets path for TCO_RESULTS
    """
    global TCO_RESULTS
    # ./t3co/resources/f'vehicles/{vocation_scenario}/tco/tco_results'
    TCO_RESULTS = RESOURCES_FOLDERPATH / f"vehicles/{vocation_scenario}/tco/tco_results"
    if not TCO_RESULTS.exists():
        TCO_RESULTS.mkdir(parents=True)

    global TCO_RES_FIGS
    # ./t3co/resources/f'vehicles/{vocation_scenario}/result_figures/'
    TCO_RES_FIGS = (
        RESOURCES_FOLDERPATH / f"vehicles/{vocation_scenario}/result_figures/"
    )
    if not TCO_RES_FIGS.exists():
        TCO_RES_FIGS.mkdir(parents=True)

kg_to_lbs(kgs)

This function converts kg to lb

Parameters:

Name Type Description Default
kgs float

mass in kg

required

Returns:

Type Description
float

mass in pounds

Source code in src/t3co/constants/Global.py
152
153
154
155
156
157
158
159
160
161
162
def kg_to_lbs(kgs: float) -> float:
    """
    This function converts kg to lb

    Args:
        kgs (float): mass in kg

    Returns:
        (float): mass in pounds
    """
    return kgs * KG_2_LB

lbs_to_kgs(lbs)

This function converts lb to kg

Parameters:

Name Type Description Default
lbs float

mass in pounds

required

Returns:

Type Description
float

mass in kg

Source code in src/t3co/constants/Global.py
165
166
167
168
169
170
171
172
173
174
175
def lbs_to_kgs(lbs: float) -> float:
    """
    This function converts lb to kg

    Args:
        lbs (float): mass in pounds

    Returns:
        (float): mass in kg
    """
    return lbs / KG_2_LB

not_falsy(var)

This function returns True to verify that var is NOT falsy: not in [None, np.nan, 0, False]

Parameters:

Name Type Description Default
var float

variable to check

required

Returns:

Type Description
bool

True if not in [None, 0, False]

Source code in src/t3co/constants/Global.py
178
179
180
181
182
183
184
185
186
187
188
189
def not_falsy(var: float) -> bool:
    """
    This function returns True to verify that var is NOT falsy: not in [None, np.nan, 0, False]


    Args:
        var (float): variable to check

    Returns:
        (bool): True if not in [None, 0, False]
    """
    return var not in [None, 0, False]