Spaces:
Runtime error
Runtime error
Added function docstring
Browse files
app.py
CHANGED
|
@@ -16,6 +16,14 @@ import gradio as gr
|
|
| 16 |
import numexpr
|
| 17 |
|
| 18 |
def safe_math_eval(expression: str) -> float:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
try:
|
| 20 |
return numexpr.evaluate(expression).item()
|
| 21 |
except Exception as e:
|
|
|
|
| 16 |
import numexpr
|
| 17 |
|
| 18 |
def safe_math_eval(expression: str) -> float:
|
| 19 |
+
"""Safely evaluate a mathematical formula
|
| 20 |
+
|
| 21 |
+
Args:
|
| 22 |
+
expression: The nunexpr formatted expression to evaluate
|
| 23 |
+
|
| 24 |
+
Returns:
|
| 25 |
+
The result of the evaluation
|
| 26 |
+
"""
|
| 27 |
try:
|
| 28 |
return numexpr.evaluate(expression).item()
|
| 29 |
except Exception as e:
|