Skip to content

Commit 241195c

Browse files
Pauline ZhouPauline Zhou
Pauline Zhou
authored and
Pauline Zhou
committed
UP my solution
1 parent ee8d1e3 commit 241195c

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

numpy_questions.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,18 @@ def max_index(X):
3939
"""
4040
i = 0
4141
j = 0
42-
43-
if isinstance(X, np.ndarray) == False:
42+
if isinstance(X, np.ndarray) is False:
4443
raise ValueError("The input is not a numpy array")
45-
4644
elif X.ndim != 2:
4745
raise ValueError("The shape is not 2D")
48-
4946
else:
5047
for row in range(X.shape[0]):
5148
for col in range(X.shape[1]):
5249
if X[row, col] > X[i, j]:
5350
i = row
5451
j = col
55-
5652
return i, j
5753

58-
# X = np.array([[1,2],[3,4]])
59-
# print("X", max_index(X))
60-
6154

6255
def wallis_product(n_terms):
6356
"""Implement the Wallis product to compute an approximation of pi.
@@ -76,7 +69,4 @@ def wallis_product(n_terms):
7669
pi : float
7770
The approximation of order `n_terms` of pi using the Wallis product.
7871
"""
79-
# XXX : The n_terms is an int that corresponds to the number of
80-
# terms in the product. For example 10000.
81-
8272
return 2 * np.prod([(4 * i**2) / (4 * i**2 - 1) for i in range(1, n_terms + 1)])

0 commit comments

Comments
 (0)