Spaces:
Build error
Build error
Commit
·
79797b0
1
Parent(s):
65393ab
Make league locations invisible by default for both handedness
Browse files- gradio_function.py +4 -2
- pitcher_dashboard.py +3 -3
gradio_function.py
CHANGED
@@ -79,7 +79,7 @@ colorscale = [
|
|
79 |
|
80 |
|
81 |
@clone_df
|
82 |
-
def plot_loc(df, league_df=None, min_pitches=3, max_pitches=5000):
|
83 |
|
84 |
loc = df.select(['plate_x', 'plate_z'])
|
85 |
|
@@ -150,6 +150,7 @@ def plot_loc(df, league_df=None, min_pitches=3, max_pitches=5000):
|
|
150 |
},
|
151 |
showlegend=True,
|
152 |
showscale=False,
|
|
|
153 |
name='NPB'
|
154 |
))
|
155 |
|
@@ -344,7 +345,7 @@ def plot_usage(df, player):
|
|
344 |
return fig
|
345 |
|
346 |
@clone_df
|
347 |
-
def plot_pitch_cards(df, league_df, pitch_stats):
|
348 |
pitch_counts = df['pitch_name'].value_counts().sort('count', descending=True)
|
349 |
|
350 |
pitch_rows = []
|
@@ -374,6 +375,7 @@ def plot_pitch_cards(df, league_df, pitch_stats):
|
|
374 |
pitch_locs.append(gr.update(
|
375 |
value=plot_loc(
|
376 |
df=df.filter(pl.col('pitch_name') == pitch_name),
|
|
|
377 |
league_df=league_df.filter(pl.col('pitch_name') == pitch_name)
|
378 |
),
|
379 |
label='Pitch location',
|
|
|
79 |
|
80 |
|
81 |
@clone_df
|
82 |
+
def plot_loc(df, handedness, league_df=None, min_pitches=3, max_pitches=5000):
|
83 |
|
84 |
loc = df.select(['plate_x', 'plate_z'])
|
85 |
|
|
|
150 |
},
|
151 |
showlegend=True,
|
152 |
showscale=False,
|
153 |
+
visible=True if handedness != 'Both' else 'legendonly',
|
154 |
name='NPB'
|
155 |
))
|
156 |
|
|
|
345 |
return fig
|
346 |
|
347 |
@clone_df
|
348 |
+
def plot_pitch_cards(df, league_df, pitch_stats, handedness):
|
349 |
pitch_counts = df['pitch_name'].value_counts().sort('count', descending=True)
|
350 |
|
351 |
pitch_rows = []
|
|
|
375 |
pitch_locs.append(gr.update(
|
376 |
value=plot_loc(
|
377 |
df=df.filter(pl.col('pitch_name') == pitch_name),
|
378 |
+
handedness=handedness,
|
379 |
league_df=league_df.filter(pl.col('pitch_name') == pitch_name)
|
380 |
),
|
381 |
label='Pitch location',
|
pitcher_dashboard.py
CHANGED
@@ -79,13 +79,13 @@ def create_pitcher_dashboard():
|
|
79 |
pitch_locs.append(gr.Plot(label='Pitch Location', elem_classes='pitch-loc', visible=visible))
|
80 |
|
81 |
download_file_fn = create_set_download_file_fn('files/player.csv')
|
82 |
-
plot_loc_summary = lambda df: plot_loc(df)
|
83 |
fn_configs = {
|
84 |
download_file_fn: dict(inputs=[], outputs=download_file),
|
85 |
plot_usage: dict(inputs=[player], outputs=usage),
|
86 |
plot_velo_summary: dict(inputs=[app_league_df, player], outputs=velo_summary),
|
87 |
-
plot_loc_summary: dict(inputs=[], outputs=loc_summary),
|
88 |
-
plot_pitch_cards: dict(inputs=[app_league_df, app_pitch_stats], outputs=pitch_rows+pitch_groups+pitch_names+pitch_infos+pitch_velos+pitch_locs)
|
89 |
}
|
90 |
for k in fn_configs.keys():
|
91 |
fn_configs[k]['df'] = gr.State(df)
|
|
|
79 |
pitch_locs.append(gr.Plot(label='Pitch Location', elem_classes='pitch-loc', visible=visible))
|
80 |
|
81 |
download_file_fn = create_set_download_file_fn('files/player.csv')
|
82 |
+
plot_loc_summary = lambda df, handedness: plot_loc(df, handedness)
|
83 |
fn_configs = {
|
84 |
download_file_fn: dict(inputs=[], outputs=download_file),
|
85 |
plot_usage: dict(inputs=[player], outputs=usage),
|
86 |
plot_velo_summary: dict(inputs=[app_league_df, player], outputs=velo_summary),
|
87 |
+
plot_loc_summary: dict(inputs=[handedness], outputs=loc_summary),
|
88 |
+
plot_pitch_cards: dict(inputs=[app_league_df, app_pitch_stats, handedness], outputs=pitch_rows+pitch_groups+pitch_names+pitch_infos+pitch_velos+pitch_locs)
|
89 |
}
|
90 |
for k in fn_configs.keys():
|
91 |
fn_configs[k]['df'] = gr.State(df)
|