File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,19 @@ def max_index(X):
41
41
j = 0
42
42
43
43
# TODO
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 array must be 2-dimensional." )
49
+
50
+ max_value = X [i , j ]
51
+
52
+ for x in range (X .shape [0 ]):
53
+ for y in range (X .shape [1 ]):
54
+ if X [x , y ] > max_value :
55
+ max_value = X [x , y ]
56
+ i , j = x , y
44
57
45
58
return i , j
46
59
@@ -64,4 +77,16 @@ def wallis_product(n_terms):
64
77
"""
65
78
# XXX : The n_terms is an int that corresponds to the number of
66
79
# terms in the product. For example 10000.
67
- return 0.
80
+
81
+ if n_terms < 0 :
82
+ raise ValueError ("n_term cannot be negative" )
83
+
84
+ product = 1
85
+
86
+ if n_terms == 0 :
87
+ return product * 2
88
+
89
+ for i in range (1 , n_terms + 1 ):
90
+ product *= (4 * i ** 2 ) / (4 * i ** 2 - 1 )
91
+
92
+ return product * 2
Original file line number Diff line number Diff line change 2
2
scipy
3
3
scikit-learn
4
4
pandas
5
+ pytest
6
+ flake8
You can’t perform that action at this time.
0 commit comments