Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
c1a4fec
1
Parent(s):
0cd448a
Better names for plotting functions
Browse files- gui/app.py +8 -5
- gui/plots.py +2 -2
gui/app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from data import test_equations
|
3 |
-
from plots import
|
4 |
from processing import processing
|
5 |
|
6 |
|
@@ -225,7 +225,7 @@ def main():
|
|
225 |
outputs=blocks["df"],
|
226 |
)
|
227 |
|
228 |
-
# Any update to the equation choice will trigger a
|
229 |
eqn_components = [
|
230 |
blocks["test_equation"],
|
231 |
blocks["num_points"],
|
@@ -234,17 +234,20 @@ def main():
|
|
234 |
]
|
235 |
for eqn_component in eqn_components:
|
236 |
eqn_component.change(
|
237 |
-
|
|
|
|
|
|
|
238 |
)
|
239 |
|
240 |
# Update plot when dataframe is updated:
|
241 |
blocks["df"].change(
|
242 |
-
|
243 |
inputs=[blocks["df"], blocks["maxsize"]],
|
244 |
outputs=[blocks["pareto"]],
|
245 |
show_progress=False,
|
246 |
)
|
247 |
-
demo.load(
|
248 |
|
249 |
demo.launch(debug=True)
|
250 |
|
|
|
1 |
import gradio as gr
|
2 |
from data import test_equations
|
3 |
+
from plots import plot_example_data, plot_pareto_curve
|
4 |
from processing import processing
|
5 |
|
6 |
|
|
|
225 |
outputs=blocks["df"],
|
226 |
)
|
227 |
|
228 |
+
# Any update to the equation choice will trigger a plot_example_data:
|
229 |
eqn_components = [
|
230 |
blocks["test_equation"],
|
231 |
blocks["num_points"],
|
|
|
234 |
]
|
235 |
for eqn_component in eqn_components:
|
236 |
eqn_component.change(
|
237 |
+
plot_example_data,
|
238 |
+
eqn_components,
|
239 |
+
blocks["example_plot"],
|
240 |
+
show_progress=False,
|
241 |
)
|
242 |
|
243 |
# Update plot when dataframe is updated:
|
244 |
blocks["df"].change(
|
245 |
+
plot_pareto_curve,
|
246 |
inputs=[blocks["df"], blocks["maxsize"]],
|
247 |
outputs=[blocks["pareto"]],
|
248 |
show_progress=False,
|
249 |
)
|
250 |
+
demo.load(plot_example_data, eqn_components, blocks["example_plot"])
|
251 |
|
252 |
demo.launch(debug=True)
|
253 |
|
gui/plots.py
CHANGED
@@ -14,7 +14,7 @@ plt.rcParams["font.family"] = [
|
|
14 |
from data import generate_data
|
15 |
|
16 |
|
17 |
-
def
|
18 |
fig, ax = plt.subplots(figsize=(6, 6), dpi=100)
|
19 |
|
20 |
if len(df) == 0 or "Equation" not in df.columns:
|
@@ -56,7 +56,7 @@ def replot_pareto(df: pd.DataFrame, maxsize: int):
|
|
56 |
return fig
|
57 |
|
58 |
|
59 |
-
def
|
60 |
X, y = generate_data(test_equation, num_points, noise_level, data_seed)
|
61 |
x = X["x"]
|
62 |
|
|
|
14 |
from data import generate_data
|
15 |
|
16 |
|
17 |
+
def plot_pareto_curve(df: pd.DataFrame, maxsize: int):
|
18 |
fig, ax = plt.subplots(figsize=(6, 6), dpi=100)
|
19 |
|
20 |
if len(df) == 0 or "Equation" not in df.columns:
|
|
|
56 |
return fig
|
57 |
|
58 |
|
59 |
+
def plot_example_data(test_equation, num_points, noise_level, data_seed):
|
60 |
X, y = generate_data(test_equation, num_points, noise_level, data_seed)
|
61 |
x = X["x"]
|
62 |
|