Skip to content

Commit 078f5f4

Browse files
committed
[mypy] Fix type annotation in euler_method.py
In line with issue TheAlgorithms#4052.
1 parent 11a15cc commit 078f5f4

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

‎maths/euler_method.py‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1+
from typing import Callable
2+
13
import numpy as np
24

35

4-
def explicit_euler(ode_func, y0, x0, step_size, x_end):
5-
"""
6-
Calculate numeric solution at each step to an ODE using Euler's Method
6+
def explicit_euler(
7+
ode_func: Callable, y0: float, x0: float, step_size: float, x_end: float
8+
) -> np.ndarray:
9+
"""Calculate numeric solution at each step to an ODE using Euler's Method
10+
11+
For reference to Euler's method refer to https://en.wikipedia.org/wiki/Euler_method.
712
8-
https://en.wikipedia.org/wiki/Euler_method
13+
Args:
14+
ode_func (Callable): The ordinary differential equation
15+
as a function of x and y.
16+
y0 (float): The initial value for y.
17+
x0 (float): The initial value for x.
18+
step_size (float): The increment value for x.
19+
x_end (float): The final value of x to be calculated.
920
10-
Arguments:
11-
ode_func -- The ode as a function of x and y
12-
y0 -- the initial value for y
13-
x0 -- the initial value for x
14-
stepsize -- the increment value for x
15-
x_end -- the end value for x
21+
Returns:
22+
np.ndarray: Solution of y for every step in x.
1623
1724
>>> # the exact solution is math.exp(x)
1825
>>> def f(x, y):

0 commit comments

Comments
 (0)