diff --git a/batters/calcs_batter.py b/batters/calcs_batter.py
index 0693d0f..b039041 100644
--- a/batters/calcs_batter.py
+++ b/batters/calcs_batter.py
@@ -573,7 +573,7 @@ def stealing_line(steal_data: dict):
else:
good_jump = "2-12"
- return f'{"*" if sd[2] else ""}{good_jump}/- ({sd[1] if sd[1] else "-"}-{sd[0] if sd[0] else "-"})'
+ return f"{'*' if sd[2] else ''}{good_jump}/- ({sd[1] if sd[1] else '-'}-{sd[0] if sd[0] else '-'})"
def running(extra_base_pct: str):
@@ -583,7 +583,7 @@ def running(extra_base_pct: str):
xb_pct = float(extra_base_pct.strip("%")) / 80
except Exception as e:
logger.error(f"calcs_batter running - {e}")
- xb_pct = 20
+ return 8
return max(min(round(6 + (10 * xb_pct)), 17), 8)
@@ -693,11 +693,11 @@ def get_batter_ratings(df_data) -> List[dict]:
logger.debug(
f"all on base: {vl.hbp + vl.walk + vl.total_hits()} / all chances: {vl.total_chances()}"
- f'{"*******ERROR ABOVE*******" if vl.hbp + vl.walk + vl.total_hits() != vl.total_chances() else ""}'
+ f"{'*******ERROR ABOVE*******' if vl.hbp + vl.walk + vl.total_hits() != vl.total_chances() else ''}"
)
logger.debug(
f"all on base: {vr.hbp + vr.walk + vr.total_hits()} / all chances: {vr.total_chances()}"
- f'{"*******ERROR ABOVE*******" if vr.hbp + vr.walk + vr.total_hits() != vr.total_chances() else ""}'
+ f"{'*******ERROR ABOVE*******' if vr.hbp + vr.walk + vr.total_hits() != vr.total_chances() else ''}"
)
vl.calculate_strikeouts(df_data["SO_vL"], df_data["AB_vL"], df_data["H_vL"])
diff --git a/creation_helpers.py b/creation_helpers.py
index f1081e0..d8bd9ad 100644
--- a/creation_helpers.py
+++ b/creation_helpers.py
@@ -595,21 +595,21 @@ def legal_splits(tot_chances):
def result_string(tba_data, row_num, split_min=None, split_max=None):
- bold1 = f'{"" if tba_data["bold"] else ""}'
- bold2 = f'{"" if tba_data["bold"] else ""}'
- row_string = f'{" " if int(row_num) < 10 else ""}{row_num}'
+ bold1 = f"{'' if tba_data['bold'] else ''}"
+ bold2 = f"{'' if tba_data['bold'] else ''}"
+ row_string = f"{' ' if int(row_num) < 10 else ''}{row_num}"
if TESTING:
print(
- f'adding {tba_data["string"]} to row {row_num} / '
+ f"adding {tba_data['string']} to row {row_num} / "
f"split_min: {split_min} / split_max: {split_max}"
)
# No splits; standard result
if not split_min:
- return f'{bold1}{row_string}-{tba_data["string"]}{bold2}'
+ return f"{bold1}{row_string}-{tba_data['string']}{bold2}"
# With splits
- split_nums = f'{split_min if split_min != 20 else ""}{"-" if split_min != 20 else ""}{split_max}'
+ split_nums = f"{split_min if split_min != 20 else ''}{'-' if split_min != 20 else ''}{split_max}"
data_string = (
tba_data["sm-string"] if "sm-string" in tba_data.keys() else tba_data["string"]
)
@@ -618,10 +618,10 @@ def result_string(tba_data, row_num, split_min=None, split_max=None):
spaces -= 3
elif "SI**" in data_string:
spaces += 1
+ elif "DO**" in data_string:
+ spaces -= 2
elif "DO*" in data_string:
spaces -= 1
- elif "DO*" in data_string:
- spaces -= 2
elif "so" in data_string:
spaces += 3
elif "gb" in data_string:
@@ -638,41 +638,39 @@ def result_string(tba_data, row_num, split_min=None, split_max=None):
row_output = " "
if TESTING:
print(f"row_output: {row_output}")
- return f'{bold1}{row_output}{data_string}{" " * spaces}{split_nums}{bold2}'
+ return f"{bold1}{row_output}{data_string}{' ' * spaces}{split_nums}{bold2}"
def result_data(
tba_data, row_num, tba_data_bottom=None, top_split_max=None, fatigue=False
):
ret_data = {}
- top_bold1 = f'{"" if tba_data["bold"] else ""}'
- top_bold2 = f'{"" if tba_data["bold"] else ""}'
+ top_bold1 = f"{'' if tba_data['bold'] else ''}"
+ top_bold2 = f"{'' if tba_data['bold'] else ''}"
bot_bold1 = None
bot_bold2 = None
if tba_data_bottom:
- bot_bold1 = f'{"" if tba_data_bottom["bold"] else ""}'
- bot_bold2 = f'{"" if tba_data_bottom["bold"] else ""}'
+ bot_bold1 = f"{'' if tba_data_bottom['bold'] else ''}"
+ bot_bold2 = f"{'' if tba_data_bottom['bold'] else ''}"
if tba_data_bottom is None:
ret_data["2d6"] = f"{top_bold1}{int(row_num)}-{top_bold2}"
ret_data["splits"] = f"{top_bold1}{top_bold2}"
ret_data["result"] = (
- f"{top_bold1}"
- f'{tba_data["string"]}{" •" if fatigue else ""}'
- f"{top_bold2}"
+ f"{top_bold1}{tba_data['string']}{' •' if fatigue else ''}{top_bold2}"
)
else:
ret_data["2d6"] = f"{top_bold1}{int(row_num)}-{top_bold2}\n"
ret_data["splits"] = (
- f'{top_bold1}1{"-" if top_split_max != 1 else ""}'
- f'{top_split_max if top_split_max != 1 else ""}{top_bold2}\n'
- f'{bot_bold1}{top_split_max+1}{"-20" if top_split_max != 19 else ""}{bot_bold2}'
+ f"{top_bold1}1{'-' if top_split_max != 1 else ''}"
+ f"{top_split_max if top_split_max != 1 else ''}{top_bold2}\n"
+ f"{bot_bold1}{top_split_max + 1}{'-20' if top_split_max != 19 else ''}{bot_bold2}"
)
ret_data["result"] = (
- f'{top_bold1}{tba_data["sm-string"] if "sm-string" in tba_data.keys() else tba_data["string"]}'
+ f"{top_bold1}{tba_data['sm-string'] if 'sm-string' in tba_data.keys() else tba_data['string']}"
f"{top_bold2}\n"
f"{bot_bold1}"
- f'{tba_data_bottom["sm-string"] if "sm-string" in tba_data_bottom.keys() else tba_data_bottom["string"]}'
+ f"{tba_data_bottom['sm-string'] if 'sm-string' in tba_data_bottom.keys() else tba_data_bottom['string']}"
f"{bot_bold2}"
)
@@ -688,9 +686,9 @@ def get_of(batter_hand, pitcher_hand, pull_side=True):
if batter_hand == "S":
if pitcher_hand == "L":
- return "rf" if pull_side else "rf"
+ return "lf" if pull_side else "rf"
else:
- return "lf" if pull_side else "lf"
+ return "rf" if pull_side else "lf"
def get_col(col_num):
@@ -729,7 +727,7 @@ def get_position_string(all_pos: list, inc_p: bool):
for x in all_pos:
if x.position == "OF":
- of_arm = f'{"+" if "-" not in x.arm else ""}{x.arm}'
+ of_arm = f"{'+' if '-' not in x.arm else ''}{x.arm}"
of_error = x.error
of_innings = x.innings
elif x.position == "CF":
@@ -744,7 +742,7 @@ def get_position_string(all_pos: list, inc_p: bool):
elif x.position == "C":
all_def.append(
(
- f'c-{x.range}({"+" if int(x.arm) >= 0 else ""}{x.arm}) e{x.error} T-{x.overthrow}(pb-{x.pb})',
+ f"c-{x.range}({'+' if int(x.arm) >= 0 else ''}{x.arm}) e{x.error} T-{x.overthrow}(pb-{x.pb})",
x.innings,
)
)
@@ -1079,7 +1077,7 @@ def mlbteam_and_franchise(mlbam_playerid):
p_data["franchise"] = normalize_franchise(data["currentTeam"]["name"])
else:
logger.error(
- f'Could not set team for {mlbam_playerid}; received {data["currentTeam"]["name"]}'
+ f"Could not set team for {mlbam_playerid}; received {data['currentTeam']['name']}"
)
else:
logger.error(
@@ -1222,5 +1220,5 @@ def get_hand(df_data):
else:
return "R"
except Exception:
- logger.error(f'Error in get_hand for {df_data["Name"]}')
+ logger.error(f"Error in get_hand for {df_data['Name']}")
return "R"
diff --git a/tests/test_helpers.py b/tests/test_helpers.py
index 875d8ab..83d4268 100644
--- a/tests/test_helpers.py
+++ b/tests/test_helpers.py
@@ -1,10 +1,4 @@
-from creation_helpers import pd_positions_df, mround, sanitize_chance_output
-
-
-def test_positions_df():
- cardset_19_pos = pd_positions_df(19)
-
- assert True == True
+from creation_helpers import mround, sanitize_chance_output
def test_mround():