Skip to content

Commit 61e1dd2

Browse files
NumberPiOsogithub-actions
and
github-actions
authored
[mypy] Fix type annotation in euler_method.py (TheAlgorithms#5649)
* [mypy] Fix type annotation in euler_method.py In line with issue TheAlgorithms#4052. * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent 11a15cc commit 61e1dd2

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

DIRECTORY.md

+1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
* [Swap Nodes](https://github.com/TheAlgorithms/Python/blob/master/data_structures/linked_list/swap_nodes.py)
187187
* Queue
188188
* [Circular Queue](https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/circular_queue.py)
189+
* [Circular Queue Linked List](https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/circular_queue_linked_list.py)
189190
* [Double Ended Queue](https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/double_ended_queue.py)
190191
* [Linked Queue](https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/linked_queue.py)
191192
* [Priority Queue Using List](https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/priority_queue_using_list.py)

maths/euler_method.py

+17-10
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)