File tree 1 file changed +24
-1
lines changed
1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,27 @@ 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
+ # Vérification de la validité de X
41
+ if X is None :
42
+ raise ValueError ("Input cannot be None." )
43
+
44
+ if not isinstance (X , np .ndarray ):
45
+ raise ValueError ("Input must be a numpy array." )
46
+
47
+ if X .ndim != 2 :
48
+ raise ValueError ("Input must be a 2D numpy array." )
49
+
40
50
i = 0
41
51
j = 0
42
52
53
+ n_samples , n_features = X .shape
54
+ max = 0
43
55
# TODO
56
+ for l in range (n_samples ):
57
+ for c in range (n_features ):
58
+ if X [l , c ] > max :
59
+ max = X [l , c ]
60
+ i , j = l , c
44
61
45
62
return i , j
46
63
@@ -64,4 +81,10 @@ def wallis_product(n_terms):
64
81
"""
65
82
# XXX : The n_terms is an int that corresponds to the number of
66
83
# terms in the product. For example 10000.
67
- return 0.
84
+ if n_terms == 0 :
85
+ return 2
86
+
87
+ aprox = 2
88
+ for n in range (1 , n_terms + 1 ):
89
+ aprox *= (4 * n ** 2 ) / (4 * n ** 2 - 1 )
90
+ return aprox
You can’t perform that action at this time.
0 commit comments