Update app.py
Browse files
app.py
CHANGED
|
@@ -47,6 +47,11 @@ class Quadratic:
|
|
| 47 |
# -------- Function for Gradio --------
|
| 48 |
def solve_and_plot(a, b, c):
|
| 49 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
quad = Quadratic(a, b, c)
|
| 51 |
root1, root2 = quad.solveQuad()
|
| 52 |
fig = quad.drawFigure()
|
|
@@ -69,7 +74,7 @@ theme = gr.themes.Soft(
|
|
| 69 |
secondary_hue="blue",
|
| 70 |
neutral_hue="slate",
|
| 71 |
font=[
|
| 72 |
-
gr.themes.GoogleFont("Inter"),
|
| 73 |
"ui-sans-serif",
|
| 74 |
"system-ui"
|
| 75 |
]
|
|
@@ -80,9 +85,9 @@ theme = gr.themes.Soft(
|
|
| 80 |
interface = gr.Interface(
|
| 81 |
fn=solve_and_plot,
|
| 82 |
inputs=[
|
| 83 |
-
gr.
|
| 84 |
-
gr.
|
| 85 |
-
gr.
|
| 86 |
],
|
| 87 |
outputs=[
|
| 88 |
gr.Textbox(label="Solution"),
|
|
|
|
| 47 |
# -------- Function for Gradio --------
|
| 48 |
def solve_and_plot(a, b, c):
|
| 49 |
try:
|
| 50 |
+
# Convert string inputs to float (supports negative values)
|
| 51 |
+
a = float(a)
|
| 52 |
+
b = float(b)
|
| 53 |
+
c = float(c)
|
| 54 |
+
|
| 55 |
quad = Quadratic(a, b, c)
|
| 56 |
root1, root2 = quad.solveQuad()
|
| 57 |
fig = quad.drawFigure()
|
|
|
|
| 74 |
secondary_hue="blue",
|
| 75 |
neutral_hue="slate",
|
| 76 |
font=[
|
| 77 |
+
gr.themes.GoogleFont("Inter"),
|
| 78 |
"ui-sans-serif",
|
| 79 |
"system-ui"
|
| 80 |
]
|
|
|
|
| 85 |
interface = gr.Interface(
|
| 86 |
fn=solve_and_plot,
|
| 87 |
inputs=[
|
| 88 |
+
gr.Textbox(label="Coefficient a", value="1"),
|
| 89 |
+
gr.Textbox(label="Coefficient b", value="0"),
|
| 90 |
+
gr.Textbox(label="Coefficient c", value="0"),
|
| 91 |
],
|
| 92 |
outputs=[
|
| 93 |
gr.Textbox(label="Solution"),
|