File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ def max_index(X):
29
29
Returns
30
30
-------
31
31
(i, j) : tuple(int)
32
- The row and columnd index of the maximum.
32
+ The row and column index of the maximum.
33
33
34
34
Raises
35
35
------
@@ -39,9 +39,11 @@ def max_index(X):
39
39
"""
40
40
i = 0
41
41
j = 0
42
-
43
- # TODO
44
-
42
+ if type (X ) is not np .ndarray :
43
+ raise ValueError
44
+ if len (X .shape ) != 2 :
45
+ raise ValueError
46
+ i , j = np .unravel_index (np .argmax (X ), X .shape )
45
47
return i , j
46
48
47
49
@@ -62,6 +64,12 @@ def wallis_product(n_terms):
62
64
pi : float
63
65
The approximation of order `n_terms` of pi using the Wallis product.
64
66
"""
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.
67
- return 0.
70
+ if type (n_terms ) is not int :
71
+ raise TypeError
72
+ product = 1
73
+ for n in range (0 , n_terms ):
74
+ product = product * ((4 * ((n + 1 )** 2 ))/ (4 * ((n + 1 )** 2 )- 1 ))
75
+ return product * 2
You can’t perform that action at this time.
0 commit comments