Skip to content

Commit 879b396

Browse files
committed
UP my solution
1 parent 22026a3 commit 879b396

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

numpy_questions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def max_index(X):
4848
return i, j
4949

5050

51-
5251
def wallis_product(n_terms):
5352
"""Implement the Wallis product to compute an approximation of pi.
5453
@@ -72,7 +71,7 @@ def wallis_product(n_terms):
7271
if n_terms < 0:
7372
raise ValueError("n_terms should be a positive integer")
7473
if n_terms == 0:
75-
return 1.
74+
return 2.
7675

7776
pi = 1.
7877
for i in range(1, n_terms+1):

test_numpy_questions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from numpy_questions import wallis_product, max_index
1111

12+
1213
def test_max_index():
1314
X = np.array([[0, 1], [2, 0]])
1415
assert max_index(X) == (1, 0)
@@ -29,7 +30,7 @@ def test_max_index():
2930

3031
def test_wallis_product():
3132
pi_approx = wallis_product(0)
32-
assert pi_approx == 1.
33+
assert pi_approx == 2.
3334

3435
pi_approx = wallis_product(1)
3536
assert pi_approx == 8 / 3

0 commit comments

Comments
 (0)