File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -40,8 +40,11 @@ def max_index(X):
40
40
i = 0
41
41
j = 0
42
42
43
- # TODO
44
-
43
+ if not isinstance (X , np .ndarray ):
44
+ raise ValueError ("The input should be a numpy array." )
45
+ if len (X .shape ) != 2 :
46
+ raise ValueError ("The input should be a 2D numpy array." )
47
+ i , j = np .unravel_index (np .argmax (X ), X .shape )
45
48
return i , j
46
49
47
50
@@ -64,4 +67,12 @@ def wallis_product(n_terms):
64
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
+
71
+ if not isinstance (n_terms , int ):
72
+ raise ValueError ("The input should be an integer." )
73
+ if n_terms < 0 :
74
+ raise ValueError ("The input should be a positive integer." )
75
+ pi = 1
76
+ for i in range (1 , n_terms + 1 ):
77
+ pi *= (4 * i ** 2 )/ (4 * i ** 2 - 1 )
78
+ return 2 * pi
You can’t perform that action at this time.
0 commit comments