morisono commited on
Commit
c162999
·
1 Parent(s): d53853f

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +3 -9
  2. drawFn.py +72 -0
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: Chart Playground
3
- emoji: 🏢
4
- colorFrom: gray
5
- colorTo: gray
6
  sdk: gradio
7
- sdk_version: 3.41.0
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: chart_playground
3
+ app_file: drawFn.py
 
 
4
  sdk: gradio
5
+ sdk_version: 3.40.1
 
 
6
  ---
 
 
drawFn.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import matplotlib.pyplot as plt
4
+ from scipy import special as sp
5
+
6
+
7
+ def plot_function(function_name, x_min, x_max, y_min, y_max):
8
+ functions = {
9
+ "abs": np.abs,
10
+ "acos": np.arccos,
11
+ "acosh": np.arccosh,
12
+ "airy": sp.airy,
13
+ "asin": np.arcsin,
14
+ "asinh": np.arcsinh,
15
+ "atan": np.arctan,
16
+ "atanh": np.arctanh,
17
+ "ceil": np.ceil,
18
+ "cos": np.cos,
19
+ "cosh": np.cosh,
20
+ "erf": lambda x: np.vectorize(sp.erfi)(x).real,
21
+ "erfc": lambda x: np.vectorize(sp.erfi)(x).imag,
22
+ "exp": np.exp,
23
+ "floor": np.floor,
24
+ "imag": np.imag,
25
+ "int": lambda x: np.vectorize(int)(x),
26
+ "inverf": lambda x: np.vectorize(sp.erfi)(x).real,
27
+ "invnor": lambda x: np.vectorize(sp.erfi)(x).imag,
28
+ "lambertw": lambda x: np.vectorize(sp.lambertw)(x).real,
29
+ "log": np.log,
30
+ "log10": np.log10,
31
+ "real": np.real,
32
+ "sgn": lambda x: np.sign(x),
33
+ "sin": np.sin,
34
+ "sinh": np.sinh,
35
+ "sqrt": np.sqrt,
36
+ "tanh": np.tanh,
37
+ "jv": sp.jv,
38
+ "EllipticK": sp.ellipk,
39
+ "EllipticE": sp.ellipe,
40
+ "erfi": sp.erfi,
41
+ "gamma": sp.gamma,
42
+ "tan": np.tan
43
+ }
44
+ x = np.linspace(x_min, x_max, 1000)
45
+ y = functions[function_name](x)
46
+ plt.ylim(y_min, y_max)
47
+ plt.plot(x, y)
48
+ plt.title(function_name)
49
+ plt.xlabel('x')
50
+ plt.ylabel('y')
51
+ plt.grid(True)
52
+ plt.tight_layout()
53
+
54
+ return plt.gcf()
55
+
56
+ evals = ["abs", "acos", "acosh", "airy", "asin", "asinh", "atan", "atanh", "cdawson", "ceil", "cerf", "cos", "cosh", "erf", "erfc", "exp", "floor", "imag", "int", "inverf", "invnor", "lambertw", "lgamma", "log", "log10", "real", "sgn", "sin", "sinh", "sqrt", "tanh", "jv", "besj0", "besj1", "besy0", "EllipticK", "EllipticE", "besy1", "erfi", "gamma", "tan"]
57
+
58
+ inputs = [
59
+ gr.Dropdown(choices=evals),
60
+ gr.Number(0, label="x min"),
61
+ gr.Number(1, label="x max"),
62
+ gr.Number(0, label="y min"),
63
+ gr.Number(1, label="y max"),
64
+ ]
65
+ iface = gr.Interface(
66
+ title='gnuplot',
67
+ fn=plot_function,
68
+ inputs=inputs,
69
+ outputs="plot",
70
+ live=True
71
+ )
72
+ iface.launch()