@@ -49,7 +49,9 @@ def jacobi_iteration_method(
49
49
>>> constant = np.array([[2], [-6]])
50
50
>>> init_val = [0.5, -0.5, -0.5]
51
51
>>> 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
53
55
Traceback (most recent call last):
54
56
...
55
57
ValueError: Coefficient and constant matrices dimensions must be nxn and nx1 but
@@ -59,7 +61,9 @@ def jacobi_iteration_method(
59
61
>>> constant = np.array([[2], [-6], [-4]])
60
62
>>> init_val = [0.5, -0.5]
61
63
>>> 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
63
67
Traceback (most recent call last):
64
68
...
65
69
ValueError: Number of initial values must be equal to number of rows in coefficient
@@ -79,24 +83,26 @@ def jacobi_iteration_method(
79
83
rows2 , cols2 = constant_matrix .shape
80
84
81
85
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 )
85
88
86
89
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 )
88
92
89
93
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 } "
93
97
)
98
+ raise ValueError (msg )
94
99
95
100
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 } "
99
104
)
105
+ raise ValueError (msg )
100
106
101
107
if iterations <= 0 :
102
108
raise ValueError ("Iterations must be at least 1" )
0 commit comments