We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4ee159f commit 9ea6e36Copy full SHA for 9ea6e36
numpy_questions.py
@@ -37,16 +37,15 @@ def max_index(X):
37
If the input is not a numpy array or
38
if the shape is not 2D.
39
"""
40
-
41
if not isinstance(X, np.ndarray):
42
raise ValueError("Input must be a numpy array.")
43
+
44
if X.ndim != 2:
45
raise ValueError("Input must be a 2D numpy array.")
46
47
if X.size == 0:
48
raise ValueError("Input array must not be empty.")
49
50
i, j = np.unravel_index(np.argmax(X), X.shape)
51
return i, j
52
@@ -71,4 +70,4 @@ def wallis_product(n_terms):
71
70
pi = 1
72
for i in range(1, n_terms + 1):
73
pi *= (4 * i ** 2) / (4 * i ** 2 - 1)
74
- return 2 * pi
+ return 2 * pi
0 commit comments