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 66import numpy .typing as npt
77
88
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 :
1215 '''Generate x-values in given range
1316
1417 Parameters
@@ -28,12 +31,12 @@ def generate_input(a: float | np.float32 | np.float64,
2831 return np .linspace (a , b , n )
2932
3033
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 )
3336 return y
3437
3538
36- def plot_function (x : npt . NDArray [ np . float64 ] , y : npt . NDArray [ np . float64 ] ) -> None :
39+ def plot_function (x : Vector , y : Vector ) -> None :
3740 plt .plot (x , y )
3841 plt .show ()
3942 return
You can’t perform that action at this time.
0 commit comments