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 ae60533Copy full SHA for ae60533
numpy_questions.py
@@ -42,6 +42,15 @@ def max_index(X):
42
43
# TODO
44
45
+ if not isinstance(X, np.ndarray):
46
+ raise ValueError("Input must be a numpy array.")
47
+ if X.ndim != 2:
48
+ raise ValueError("Input array must be 2D.")
49
+
50
+ max_idx = np.argmax(X)
51
52
+ i, j = divmod(max_idx, X.shape[1])
53
54
return i, j
55
56
@@ -64,4 +73,7 @@ def wallis_product(n_terms):
64
73
"""
65
74
# XXX : The n_terms is an int that corresponds to the number of
66
75
# terms in the product. For example 10000.
67
- return 0.
76
+ pi = 1
77
+ for i in range(1, n_terms + 1):
78
+ pi = pi * (4 * (i**2) / (4 * (i**2) - 1))
79
+ return pi * 2
0 commit comments