mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-08 03:54:26 +08:00
refactor: Indent ... for visual purposes (#7744)
This commit is contained in:

committed by
GitHub

parent
e8915097c4
commit
9bba42eca8
@ -8,7 +8,7 @@ def bisection(function: Callable[[float], float], a: float, b: float) -> float:
|
||||
1.0000000149011612
|
||||
>>> bisection(lambda x: x ** 3 - 1, 2, 1000)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: could not find root in given interval.
|
||||
>>> bisection(lambda x: x ** 2 - 4 * x + 3, 0, 2)
|
||||
1.0
|
||||
@ -16,7 +16,7 @@ def bisection(function: Callable[[float], float], a: float, b: float) -> float:
|
||||
3.0
|
||||
>>> bisection(lambda x: x ** 2 - 4 * x + 3, 4, 1000)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: could not find root in given interval.
|
||||
"""
|
||||
start: float = a
|
||||
|
@ -10,7 +10,7 @@ def intersection(function: Callable[[float], float], x0: float, x1: float) -> fl
|
||||
0.9999999999954654
|
||||
>>> intersection(lambda x: x ** 3 - 1, 5, 5)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ZeroDivisionError: float division by zero, could not find root
|
||||
>>> intersection(lambda x: x ** 3 - 1, 100, 200)
|
||||
1.0000000000003888
|
||||
@ -24,7 +24,7 @@ def intersection(function: Callable[[float], float], x0: float, x1: float) -> fl
|
||||
0.0
|
||||
>>> intersection(math.cos, -math.pi, math.pi)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ZeroDivisionError: float division by zero, could not find root
|
||||
"""
|
||||
x_n: float = x0
|
||||
|
@ -42,7 +42,7 @@ def jacobi_iteration_method(
|
||||
>>> iterations = 3
|
||||
>>> jacobi_iteration_method(coefficient, constant, init_val, iterations)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Coefficient matrix dimensions must be nxn but received 2x3
|
||||
|
||||
>>> coefficient = np.array([[4, 1, 1], [1, 5, 2], [1, 2, 4]])
|
||||
@ -51,7 +51,7 @@ def jacobi_iteration_method(
|
||||
>>> iterations = 3
|
||||
>>> jacobi_iteration_method(coefficient, constant, init_val, iterations)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Coefficient and constant matrices dimensions must be nxn and nx1 but
|
||||
received 3x3 and 2x1
|
||||
|
||||
@ -61,7 +61,7 @@ def jacobi_iteration_method(
|
||||
>>> iterations = 3
|
||||
>>> jacobi_iteration_method(coefficient, constant, init_val, iterations)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Number of initial values must be equal to number of rows in coefficient
|
||||
matrix but received 2 and 3
|
||||
|
||||
@ -71,7 +71,7 @@ def jacobi_iteration_method(
|
||||
>>> iterations = 0
|
||||
>>> jacobi_iteration_method(coefficient, constant, init_val, iterations)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Iterations must be at least 1
|
||||
"""
|
||||
|
||||
@ -138,7 +138,7 @@ def strictly_diagonally_dominant(table: NDArray[float64]) -> bool:
|
||||
>>> table = np.array([[4, 1, 1, 2], [1, 5, 2, -6], [1, 2, 3, -4]])
|
||||
>>> strictly_diagonally_dominant(table)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Coefficient matrix is not strictly diagonally dominant
|
||||
"""
|
||||
|
||||
|
@ -31,7 +31,7 @@ def lower_upper_decomposition(
|
||||
>>> matrix = np.array([[2, -2, 1], [0, 1, 2]])
|
||||
>>> lower_upper_decomposition(matrix)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: 'table' has to be of square shaped array but got a 2x3 array:
|
||||
[[ 2 -2 1]
|
||||
[ 0 1 2]]
|
||||
|
@ -28,7 +28,7 @@ def newton(
|
||||
1.5707963267948966
|
||||
>>> newton(math.cos, lambda x: -math.sin(x), 0)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ZeroDivisionError: Could not find root
|
||||
"""
|
||||
prev_guess = float(starting_int)
|
||||
|
@ -32,7 +32,7 @@ def newton_raphson(
|
||||
1.2186556186174883e-10
|
||||
>>> newton_raphson('cos(x)', 0)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ZeroDivisionError: Could not find root
|
||||
"""
|
||||
|
||||
|
Reference in New Issue
Block a user