Skip to content

Commit 7418199

Browse files
committed
format code properly
1 parent 59b893f commit 7418199

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

numpy_questions.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ def max_index(X):
4040
i = 0
4141
j = 0
4242

43-
if not isinstance(X, np.ndarray) :
43+
if not isinstance(X, np.ndarray):
4444
raise ValueError
45-
if len(X.shape) != 2 :
45+
if len(X.shape) != 2:
4646
raise ValueError
47-
47+
4848
index_linked = np.argmax(X).ravel()
49-
49+
5050
i, j = np.unravel_index(index_linked, X.shape)
5151

5252
return i, j
@@ -71,10 +71,11 @@ def wallis_product(n_terms):
7171
"""
7272
# XXX : The n_terms is an int that corresponds to the number of
7373
# terms in the product. For example 10000.
74-
if (n_terms==0) :
74+
if (n_terms == 0):
7575
pi = 1
76-
else :
77-
n = np.arange(1, n_terms +1, dtype=np.float64) # Generate n = 1, 2, ..., n_terms
76+
else:
77+
# Generate n = 1, 2, ..., n_terms
78+
n = np.arange(1, n_terms + 1, dtype=np.float64)
7879
ratios = (4 * n**2) / ((2 * n - 1) * (2 * n + 1))
7980
pi = np.prod(ratios)
8081
return pi*2

0 commit comments

Comments
 (0)