Skip to content

Commit 9ea6e36

Browse files
UP my solution
1 parent 4ee159f commit 9ea6e36

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

numpy_questions.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ def max_index(X):
3737
If the input is not a numpy array or
3838
if the shape is not 2D.
3939
"""
40-
4140
if not isinstance(X, np.ndarray):
4241
raise ValueError("Input must be a numpy array.")
43-
42+
4443
if X.ndim != 2:
4544
raise ValueError("Input must be a 2D numpy array.")
46-
45+
4746
if X.size == 0:
4847
raise ValueError("Input array must not be empty.")
49-
48+
5049
i, j = np.unravel_index(np.argmax(X), X.shape)
5150
return i, j
5251

@@ -71,4 +70,4 @@ def wallis_product(n_terms):
7170
pi = 1
7271
for i in range(1, n_terms + 1):
7372
pi *= (4 * i ** 2) / (4 * i ** 2 - 1)
74-
return 2 * pi
73+
return 2 * pi

0 commit comments

Comments
 (0)