Spaces:
Runtime error
Runtime error
feat: simplify descriptions and examples in Gradio interfaces for arithmetic and calculus tools
Browse files- maths/arithmetic/calculate_array.py +2 -14
- maths/arithmetic/calculate_array_with_visualization.py +1 -2
- maths/arithmetic/divide.py +1 -2
- maths/arithmetic/multiply.py +1 -2
- maths/arithmetic/subtract.py +1 -2
- maths/calculus/calculate_limit.py +2 -1
- maths/calculus/derivative_polynomial.py +2 -1
- maths/calculus/fourier_series_example.py +2 -1
- maths/calculus/integral_polynomial.py +2 -1
- maths/calculus/multiple_integral.py +2 -1
- maths/calculus/partial_derivative.py +2 -1
- maths/calculus/taylor_series_expansion.py +2 -1
maths/arithmetic/calculate_array.py
CHANGED
@@ -31,25 +31,13 @@ def calculate_array(numbers: list, operations: list) -> float:
|
|
31 |
raise ValueError(f"Unsupported operation: {op}")
|
32 |
return result
|
33 |
|
34 |
-
def parse_number_list(s):
|
35 |
-
try:
|
36 |
-
return [float(x.strip()) for x in s.split(',') if x.strip() != '']
|
37 |
-
except Exception:
|
38 |
-
return []
|
39 |
-
|
40 |
-
def parse_operation_list(s):
|
41 |
-
ops = [x.strip().lower() for x in s.split(',') if x.strip() != '']
|
42 |
-
valid_ops = {'add', 'subtract', 'multiply', 'divide'}
|
43 |
-
return [op for op in ops if op in valid_ops]
|
44 |
-
|
45 |
array_calc_interface = gr.Interface(
|
46 |
-
fn=lambda numbers, operations: calculate_array(
|
47 |
inputs=[
|
48 |
gr.Textbox(label="Numbers (comma-separated, e.g. 2, 3, 4)"),
|
49 |
gr.Textbox(label="Operations (comma-separated, e.g. add, multiply)")
|
50 |
],
|
51 |
outputs="text",
|
52 |
title="Array Calculation",
|
53 |
-
description="Calculate a sequence of numbers with specified operations
|
54 |
-
examples=[["2, 3, 4", "add, multiply"], ["10, 2, 3", "subtract, divide"], ["5, 0", "divide"]],
|
55 |
)
|
|
|
31 |
raise ValueError(f"Unsupported operation: {op}")
|
32 |
return result
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
array_calc_interface = gr.Interface(
|
35 |
+
fn=lambda numbers, operations: calculate_array(numbers, operations),
|
36 |
inputs=[
|
37 |
gr.Textbox(label="Numbers (comma-separated, e.g. 2, 3, 4)"),
|
38 |
gr.Textbox(label="Operations (comma-separated, e.g. add, multiply)")
|
39 |
],
|
40 |
outputs="text",
|
41 |
title="Array Calculation",
|
42 |
+
description="Calculate a sequence of numbers with specified operations. Example: Numbers: 2, 3, 4; Operations: add, multiply โ (2 + 3) * 4"
|
|
|
43 |
)
|
maths/arithmetic/calculate_array_with_visualization.py
CHANGED
@@ -57,6 +57,5 @@ array_calc_vis_interface = gr.Interface(
|
|
57 |
],
|
58 |
outputs=[gr.Textbox(label="Result"), gr.Plot(label="Visualization")],
|
59 |
title="Array Calculation with Visualization",
|
60 |
-
description="Calculate a sequence of numbers with specified operations and see a number line visualization
|
61 |
-
examples=[["2, 3, 4", "add, multiply"], ["10, 2, 3", "subtract, divide"], ["5, 0", "divide"]],
|
62 |
)
|
|
|
57 |
],
|
58 |
outputs=[gr.Textbox(label="Result"), gr.Plot(label="Visualization")],
|
59 |
title="Array Calculation with Visualization",
|
60 |
+
description="Calculate a sequence of numbers with specified operations and see a number line visualization."
|
|
|
61 |
)
|
maths/arithmetic/divide.py
CHANGED
@@ -16,6 +16,5 @@ divide_interface = gr.Interface(
|
|
16 |
inputs=[gr.Number(label="A"), gr.Number(label="B")],
|
17 |
outputs="text",
|
18 |
title="Division",
|
19 |
-
description="Divide two numbers
|
20 |
-
examples=[[6, 3], [5, 2], [7, 0]],
|
21 |
)
|
|
|
16 |
inputs=[gr.Number(label="A"), gr.Number(label="B")],
|
17 |
outputs="text",
|
18 |
title="Division",
|
19 |
+
description="Divide two numbers"
|
|
|
20 |
)
|
maths/arithmetic/multiply.py
CHANGED
@@ -14,6 +14,5 @@ multiply_interface = gr.Interface(
|
|
14 |
inputs=[gr.Number(label="A"), gr.Number(label="B")],
|
15 |
outputs="number",
|
16 |
title="Multiplication",
|
17 |
-
description="Multiply two numbers
|
18 |
-
examples=[[2, 3], [-1.5, 4], [0, 5]],
|
19 |
)
|
|
|
14 |
inputs=[gr.Number(label="A"), gr.Number(label="B")],
|
15 |
outputs="number",
|
16 |
title="Multiplication",
|
17 |
+
description="Multiply two numbers"
|
|
|
18 |
)
|
maths/arithmetic/subtract.py
CHANGED
@@ -14,6 +14,5 @@ subtract_interface = gr.Interface(
|
|
14 |
inputs=[gr.Number(label="A"), gr.Number(label="B")],
|
15 |
outputs="number",
|
16 |
title="Subtraction",
|
17 |
-
description="Subtract two numbers
|
18 |
-
examples=[[5, 3], [-1.5, 4.2], [0, 0]],
|
19 |
)
|
|
|
14 |
inputs=[gr.Number(label="A"), gr.Number(label="B")],
|
15 |
outputs="number",
|
16 |
title="Subtraction",
|
17 |
+
description="Subtract two numbers"
|
|
|
18 |
)
|
maths/calculus/calculate_limit.py
CHANGED
@@ -50,5 +50,6 @@ limit_interface = gr.Interface(
|
|
50 |
],
|
51 |
outputs="text",
|
52 |
title="Limit Calculator",
|
53 |
-
description="Calculate the limit of an expression. Use 'oo' for infinity. Ensure variable in expression matches variable input
|
|
|
54 |
)
|
|
|
50 |
],
|
51 |
outputs="text",
|
52 |
title="Limit Calculator",
|
53 |
+
description="Calculate the limit of an expression.\n\n**Description:**\nThis tool calculates the limit of a mathematical expression as a variable approaches a point. Use 'oo' for infinity. Ensure the variable in the expression matches the variable input.\n\n**Examples:**\n- Expression: sin(x)/x, Variable: x, Point: 0, Direction: '+-' โ Output: 1\n- Expression: 1/x, Variable: x, Point: 0, Direction: '+' โ Output: oo\n- Expression: exp(-x), Variable: x, Point: oo, Direction: '+-' โ Output: 0",
|
54 |
+
examples=[["sin(x)/x", "x", "0", "+-"], ["1/x", "x", "0", "+"], ["exp(-x)", "x", "oo", "+-"]],
|
55 |
)
|
maths/calculus/derivative_polynomial.py
CHANGED
@@ -26,5 +26,6 @@ derivative_interface = gr.Interface(
|
|
26 |
inputs=gr.Textbox(label="Polynomial Coefficients (comma-separated, highest degree first)"),
|
27 |
outputs="json",
|
28 |
title="Polynomial Derivative",
|
29 |
-
description="Find the derivative of a polynomial function"
|
|
|
30 |
)
|
|
|
26 |
inputs=gr.Textbox(label="Polynomial Coefficients (comma-separated, highest degree first)"),
|
27 |
outputs="json",
|
28 |
title="Polynomial Derivative",
|
29 |
+
description="Find the derivative of a polynomial function.\n\n**Description:**\nThis tool computes the derivative of a polynomial given its coefficients (highest degree first).\n\n**Examples:**\n- Input: 3,2,1 (represents 3x^2 + 2x + 1) โ Output: [6,2] (represents 6x + 2)\n- Input: 5,0,-4 (represents 5x^2 - 4) โ Output: [10,0] (represents 10x)\n- Input: 7 (represents constant 7) โ Output: [0]",
|
30 |
+
examples=[["3,2,1"],["5,0,-4"],["7"]],
|
31 |
)
|
maths/calculus/fourier_series_example.py
CHANGED
@@ -41,5 +41,6 @@ fourier_series_interface = gr.Interface(
|
|
41 |
],
|
42 |
outputs="text",
|
43 |
title="Fourier Series Examples",
|
44 |
-
description="Generate Fourier series for predefined periodic functions
|
|
|
45 |
)
|
|
|
41 |
],
|
42 |
outputs="text",
|
43 |
title="Fourier Series Examples",
|
44 |
+
description="Generate Fourier series for predefined periodic functions.\n\n**Description:**\nThis tool generates the Fourier series for a sawtooth or square wave with a specified number of terms.\n\n**Examples:**\n- Function Type: sawtooth, n=3 โ Output: Fourier series for sawtooth wave (f(x)=x on [-pi,pi]): ...\n- Function Type: square, n=5 โ Output: Fourier series for square wave (f(x)=1 on [0,pi], -1 on [-pi,0]): ...",
|
45 |
+
examples=[["sawtooth", 3], ["square", 5]],
|
46 |
)
|
maths/calculus/integral_polynomial.py
CHANGED
@@ -28,5 +28,6 @@ integral_interface = gr.Interface(
|
|
28 |
],
|
29 |
outputs="json",
|
30 |
title="Polynomial Integration",
|
31 |
-
description="Find the indefinite integral of a polynomial function"
|
|
|
32 |
)
|
|
|
28 |
],
|
29 |
outputs="json",
|
30 |
title="Polynomial Integration",
|
31 |
+
description="Find the indefinite integral of a polynomial function.\n\n**Description:**\nThis tool computes the indefinite integral of a polynomial given its coefficients (highest degree first) and an optional constant.\n\n**Examples:**\n- Input: 3,2,1 (represents 3x^2 + 2x + 1), c=0 โ Output: [1.0, 1.0, 1.0, 0.0] (represents x^3 + x^2 + x)\n- Input: 4,0,-2, c=5 โ Output: [1.333..., 0.0, -2.0, 5.0] (represents (4/3)x^3 - 2x + 5)\n- Input: 7, c=2 โ Output: [7.0, 2.0] (represents 7x + 2)",
|
32 |
+
examples=[["3,2,1",0],["4,0,-2",5],["7",2]],
|
33 |
)
|
maths/calculus/multiple_integral.py
CHANGED
@@ -76,5 +76,6 @@ multiple_integral_interface = gr.Interface(
|
|
76 |
],
|
77 |
outputs="text",
|
78 |
title="Definite Multiple Integral Calculator",
|
79 |
-
description="Compute multiple integrals.
|
|
|
80 |
)
|
|
|
76 |
],
|
77 |
outputs="text",
|
78 |
title="Definite Multiple Integral Calculator",
|
79 |
+
description="Compute multiple integrals.\n\n**Description:**\nThis tool computes definite multiple integrals for a given expression and bounds. The order of variables in the list is inner-most integral first.\n\n**Examples:**\n- Expression: x*y, Variables: [[\"y\", \"0\", \"x\"], [\"x\", \"0\", \"1\"]] โ Output: 1/6\n- Expression: x**2, Variables: [[\"x\", \"0\", \"2\"]] โ Output: 8/3\n- Expression: 1, Variables: [[\"x\", \"0\", \"1\"], [\"y\", \"0\", \"1\"]] โ Output: 1",
|
80 |
+
examples=[["x*y", '[["y", "0", "x"], ["x", "0", "1"]]'], ["x**2", '[["x", "0", "2"]]'], ["1", '[["x", "0", "1"], ["y", "0", "1"]]']],
|
81 |
)
|
maths/calculus/partial_derivative.py
CHANGED
@@ -44,5 +44,6 @@ partial_derivative_interface = gr.Interface(
|
|
44 |
],
|
45 |
outputs="text",
|
46 |
title="Partial Derivative Calculator",
|
47 |
-
description="Compute partial derivatives. For d/dy(d/dx(f)), enter 'x,y'. For dยฒf/dxยฒ, enter 'x,x'
|
|
|
48 |
)
|
|
|
44 |
],
|
45 |
outputs="text",
|
46 |
title="Partial Derivative Calculator",
|
47 |
+
description="Compute partial derivatives.\n\n**Description:**\nThis tool computes partial derivatives of an expression with respect to specified variables, in order. For d/dy(d/dx(f)), enter 'x,y'. For dยฒf/dxยฒ, enter 'x,x'.\n\n**Examples:**\n- Expression: x**2*y**3, Variables: x โ Output: 2*x*y**3\n- Expression: x**2*y**3, Variables: y โ Output: 3*x**2*y**2\n- Expression: x**2*y**3, Variables: x,y โ Output: 6*x*y**2",
|
48 |
+
examples=[["x**2*y**3", "x"], ["x**2*y**3", "y"], ["x**2*y**3", "x,y"]],
|
49 |
)
|
maths/calculus/taylor_series_expansion.py
CHANGED
@@ -32,5 +32,6 @@ taylor_series_interface = gr.Interface(
|
|
32 |
],
|
33 |
outputs="text",
|
34 |
title="Taylor Series Expansion",
|
35 |
-
description="Compute the Taylor series of a function around a point
|
|
|
36 |
)
|
|
|
32 |
],
|
33 |
outputs="text",
|
34 |
title="Taylor Series Expansion",
|
35 |
+
description="Compute the Taylor series of a function around a point.\n\n**Description:**\nThis tool computes the Taylor series expansion of a function around a specified point and order.\n\n**Examples:**\n- Expression: exp(x), Variable: x, Point: 0, Order: 5 โ Output: 1 + x + x**2/2 + x**3/6 + x**4/24 + x**5/120\n- Expression: cos(x), Variable: x, Point: 0, Order: 4 โ Output: 1 - x**2/2 + x**4/24\n- Expression: sin(x), Variable: x, Point: 0, Order: 3 โ Output: x - x**3/6",
|
36 |
+
examples=[["exp(x)", "x", 0, 5], ["cos(x)", "x", 0, 4], ["sin(x)", "x", 0, 3]],
|
37 |
)
|