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 d31f7ef commit 9c8ca83Copy full SHA for 9c8ca83
numpy_questions.py
@@ -40,8 +40,11 @@ def max_index(X):
40
i = 0
41
j = 0
42
43
- # TODO
44
-
+ if not isinstance(X, np.ndarray):
+ raise ValueError("X should be a numpy array")
45
+ if len(X.shape) != 2:
46
+ raise ValueError("X should be a 2D array")
47
+ i, j = np.unravel_index(np.argmax(X), X.shape)
48
return i, j
49
50
@@ -64,4 +67,10 @@ def wallis_product(n_terms):
64
67
"""
65
68
# XXX : The n_terms is an int that corresponds to the number of
66
69
# terms in the product. For example 10000.
70
+ pi = 1
71
+ for i in range(1, n_terms+1):
72
+ pi *= (4*i**2)/(4*i**2 - 1)
73
+ pi *= 2
74
+ return pi
75
+
76
return 0.
0 commit comments