Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4b79d77

Browse files
cclaussdhruvmanilapre-commit-ci[bot]
authoredMay 26, 2023
Add more ruff rules (TheAlgorithms#8767)
* Add more ruff rules * Add more ruff rules * pre-commit: Update ruff v0.0.269 -> v0.0.270 * Apply suggestions from code review * Fix doctest * Fix doctest (ignore whitespace) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Dhruv Manilawala <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent dd3b499 commit 4b79d77

File tree

67 files changed

+349
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+349
-223
lines changed
 

‎.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
- id: auto-walrus
1717

1818
- repo: https://github.com/charliermarsh/ruff-pre-commit
19-
rev: v0.0.269
19+
rev: v0.0.270
2020
hooks:
2121
- id: ruff
2222

‎arithmetic_analysis/jacobi_iteration_method.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ def jacobi_iteration_method(
4949
>>> constant = np.array([[2], [-6]])
5050
>>> init_val = [0.5, -0.5, -0.5]
5151
>>> iterations = 3
52-
>>> jacobi_iteration_method(coefficient, constant, init_val, iterations)
52+
>>> jacobi_iteration_method(
53+
... coefficient, constant, init_val, iterations
54+
... ) # doctest: +NORMALIZE_WHITESPACE
5355
Traceback (most recent call last):
5456
...
5557
ValueError: Coefficient and constant matrices dimensions must be nxn and nx1 but
@@ -59,7 +61,9 @@ def jacobi_iteration_method(
5961
>>> constant = np.array([[2], [-6], [-4]])
6062
>>> init_val = [0.5, -0.5]
6163
>>> iterations = 3
62-
>>> jacobi_iteration_method(coefficient, constant, init_val, iterations)
64+
>>> jacobi_iteration_method(
65+
... coefficient, constant, init_val, iterations
66+
... ) # doctest: +NORMALIZE_WHITESPACE
6367
Traceback (most recent call last):
6468
...
6569
ValueError: Number of initial values must be equal to number of rows in coefficient
@@ -79,24 +83,26 @@ def jacobi_iteration_method(
7983
rows2, cols2 = constant_matrix.shape
8084

8185
if rows1 != cols1:
82-
raise ValueError(
83-
f"Coefficient matrix dimensions must be nxn but received {rows1}x{cols1}"
84-
)
86+
msg = f"Coefficient matrix dimensions must be nxn but received {rows1}x{cols1}"
87+
raise ValueError(msg)
8588

8689
if cols2 != 1:
87-
raise ValueError(f"Constant matrix must be nx1 but received {rows2}x{cols2}")
90+
msg = f"Constant matrix must be nx1 but received {rows2}x{cols2}"
91+
raise ValueError(msg)
8892

8993
if rows1 != rows2:
90-
raise ValueError(
91-
f"""Coefficient and constant matrices dimensions must be nxn and nx1 but
92-
received {rows1}x{cols1} and {rows2}x{cols2}"""
94+
msg = (
95+
"Coefficient and constant matrices dimensions must be nxn and nx1 but "
96+
f"received {rows1}x{cols1} and {rows2}x{cols2}"
9397
)
98+
raise ValueError(msg)
9499

95100
if len(init_val) != rows1:
96-
raise ValueError(
97-
f"""Number of initial values must be equal to number of rows in coefficient
98-
matrix but received {len(init_val)} and {rows1}"""
101+
msg = (
102+
"Number of initial values must be equal to number of rows in coefficient "
103+
f"matrix but received {len(init_val)} and {rows1}"
99104
)
105+
raise ValueError(msg)
100106

101107
if iterations <= 0:
102108
raise ValueError("Iterations must be at least 1")

0 commit comments

Comments
 (0)
Please sign in to comment.