Update app.py
Browse files
app.py
CHANGED
|
@@ -30,14 +30,6 @@ def reset_state():
|
|
| 30 |
st.session_state.x_vals = [st.session_state.starting_point]
|
| 31 |
st.session_state.y_vals = [safe_eval(st.session_state.func_input, st.session_state.starting_point)]
|
| 32 |
|
| 33 |
-
# Predefined function buttons
|
| 34 |
-
predefined_functions = {
|
| 35 |
-
"x²": "x**2",
|
| 36 |
-
"x³": "x**3",
|
| 37 |
-
"sin(x)": "np.sin(x)",
|
| 38 |
-
"log(x)": "np.log(x)"
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
# Initialize session state variables
|
| 42 |
if "func_input" not in st.session_state:
|
| 43 |
st.session_state.func_input = "x**2 + x"
|
|
@@ -102,16 +94,6 @@ col1, col2 = st.columns([1, 2])
|
|
| 102 |
with col1:
|
| 103 |
st.subheader("🔧 Define Your Function")
|
| 104 |
|
| 105 |
-
# Display the predefined function buttons
|
| 106 |
-
st.write("Or choose a predefined function:")
|
| 107 |
-
cols = st.columns(4)
|
| 108 |
-
for i, (btn_label, func_value) in enumerate(predefined_functions.items()):
|
| 109 |
-
with cols[i]:
|
| 110 |
-
if st.button(btn_label):
|
| 111 |
-
st.session_state.func_input = func_value
|
| 112 |
-
reset_state() # Ensure that the reset function is called to update the state
|
| 113 |
-
st.experimental_rerun() # Re-run to ensure everything updates properly
|
| 114 |
-
|
| 115 |
# Use text input for the user to define a function
|
| 116 |
func_input = st.text_input(
|
| 117 |
"Enter a function of 'x':",
|
|
|
|
| 30 |
st.session_state.x_vals = [st.session_state.starting_point]
|
| 31 |
st.session_state.y_vals = [safe_eval(st.session_state.func_input, st.session_state.starting_point)]
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Initialize session state variables
|
| 34 |
if "func_input" not in st.session_state:
|
| 35 |
st.session_state.func_input = "x**2 + x"
|
|
|
|
| 94 |
with col1:
|
| 95 |
st.subheader("🔧 Define Your Function")
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
# Use text input for the user to define a function
|
| 98 |
func_input = st.text_input(
|
| 99 |
"Enter a function of 'x':",
|