File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,22 @@ def max_index(X):
37
37
If the input is not a numpy array or
38
38
if the shape is not 2D.
39
39
"""
40
+ if X is None :
41
+ raise ValueError ('None not allowed' )
42
+ if not isinstance (X , np .ndarray ):
43
+ raise ValueError ('input must be numy array' )
44
+ if X .ndim != 2 :
45
+ raise ValueError ('must be 2D' )
40
46
i = 0
41
47
j = 0
42
-
43
- # TODO
48
+ max_ = X [i ][j ]
49
+ n_samples = len (X )
50
+ n_features = len (X [0 ])
51
+ for sample in range (n_samples ):
52
+ for feature in range (n_features ):
53
+ if X [sample ][feature ] > max_ :
54
+ max_ = X [sample ][feature ]
55
+ i , j = sample , feature
44
56
45
57
return i , j
46
58
@@ -64,4 +76,7 @@ def wallis_product(n_terms):
64
76
"""
65
77
# XXX : The n_terms is an int that corresponds to the number of
66
78
# terms in the product. For example 10000.
67
- return 0.
79
+ product = 1.
80
+ for i in range (1 , n_terms + 1 ):
81
+ product *= (4 * (i ** 2 ))/ (4 * (i ** 2 )- 1 )
82
+ return product * 2
You can’t perform that action at this time.
0 commit comments