From 078f5f49dc2c8f2bac72b5b2f2009f4113d230be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Osorio=20L=C3=B3pez?= Date: Thu, 28 Oct 2021 15:16:05 -0500 Subject: [PATCH 1/2] [mypy] Fix type annotation in euler_method.py In line with issue #4052. --- maths/euler_method.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/maths/euler_method.py b/maths/euler_method.py index 7c780198602b..155ef28d1f49 100644 --- a/maths/euler_method.py +++ b/maths/euler_method.py @@ -1,18 +1,25 @@ +from typing import Callable + import numpy as np -def explicit_euler(ode_func, y0, x0, step_size, x_end): - """ - Calculate numeric solution at each step to an ODE using Euler's Method +def explicit_euler( + ode_func: Callable, y0: float, x0: float, step_size: float, x_end: float +) -> np.ndarray: + """Calculate numeric solution at each step to an ODE using Euler's Method + + For reference to Euler's method refer to https://en.wikipedia.org/wiki/Euler_method. - https://en.wikipedia.org/wiki/Euler_method + Args: + ode_func (Callable): The ordinary differential equation + as a function of x and y. + y0 (float): The initial value for y. + x0 (float): The initial value for x. + step_size (float): The increment value for x. + x_end (float): The final value of x to be calculated. - Arguments: - ode_func -- The ode as a function of x and y - y0 -- the initial value for y - x0 -- the initial value for x - stepsize -- the increment value for x - x_end -- the end value for x + Returns: + np.ndarray: Solution of y for every step in x. >>> # the exact solution is math.exp(x) >>> def f(x, y): From c3a8b385f819b46c534de119c8861e67ad0d9862 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 28 Oct 2021 20:18:34 +0000 Subject: [PATCH 2/2] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index a8986f195901..434cddbfd32c 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -186,6 +186,7 @@ * [Swap Nodes](https://github.com/TheAlgorithms/Python/blob/master/data_structures/linked_list/swap_nodes.py) * Queue * [Circular Queue](https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/circular_queue.py) + * [Circular Queue Linked List](https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/circular_queue_linked_list.py) * [Double Ended Queue](https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/double_ended_queue.py) * [Linked Queue](https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/linked_queue.py) * [Priority Queue Using List](https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/priority_queue_using_list.py)