File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 6
6
import numpy .typing as npt
7
7
8
8
9
- def generate_input (a : float | np .float32 | np .float64 ,
10
- b : float | np .float32 | np .float64 ,
11
- n : int | np .int32 | np .int64 ) -> npt .NDArray [np .float64 ]:
9
+ type Float = float | np .float32 | np .float64
10
+ type Int = int | np .int32 | np .int64
11
+ type Vector = npt .NDArray [np .float64 ]
12
+
13
+
14
+ def generate_input (a : Float , b : Float , n : Int ) -> Vector :
12
15
'''Generate x-values in given range
13
16
14
17
Parameters
@@ -28,12 +31,12 @@ def generate_input(a: float | np.float32 | np.float64,
28
31
return np .linspace (a , b , n )
29
32
30
33
31
- def gaussian (x : npt . NDArray [ np . float64 ] , mu : float , sigma : float ) -> npt . NDArray [ np . float64 ] :
32
- y : npt . NDArray [ np . float64 ] = np .exp (- 0.5 * (x - mu )** 2 / sigma )/ np .sqrt (2.0 * np .pi * sigma )
34
+ def gaussian (x : Vector , mu : Float , sigma : Float ) -> Vector :
35
+ y : Vector = np .exp (- 0.5 * (x - mu )** 2 / sigma )/ np .sqrt (2.0 * np .pi * sigma )
33
36
return y
34
37
35
38
36
- def plot_function (x : npt . NDArray [ np . float64 ] , y : npt . NDArray [ np . float64 ] ) -> None :
39
+ def plot_function (x : Vector , y : Vector ) -> None :
37
40
plt .plot (x , y )
38
41
plt .show ()
39
42
return
You can’t perform that action at this time.
0 commit comments