@@ -64,7 +64,7 @@ def two_group_difference(control:list|tuple|np.ndarray, #Accepts lists, tuples,
6464 if effect_size == "mean_diff" :
6565 return func_difference (control , test , np .mean , is_paired )
6666
67- elif effect_size == "median_diff" :
67+ if effect_size == "median_diff" :
6868 mes1 = "Using median as the statistic in bootstrapping may " + \
6969 "result in a biased estimate and cause problems with " + \
7070 "BCa confidence intervals. Consider using a different statistic, such as the mean.\n "
@@ -74,21 +74,21 @@ def two_group_difference(control:list|tuple|np.ndarray, #Accepts lists, tuples,
7474 warnings .warn (message = mes1 + mes2 , category = UserWarning )
7575 return func_difference (control , test , np .median , is_paired )
7676
77- elif effect_size == "cohens_d" :
77+ if effect_size == "cohens_d" :
7878 return cohens_d (control , test , is_paired )
7979
80- elif effect_size == "cohens_h" :
80+ if effect_size == "cohens_h" :
8181 return cohens_h (control , test )
8282
83- elif effect_size == "hedges_g" or effect_size == "delta_g" :
83+ if effect_size == "hedges_g" or effect_size == "delta_g" :
8484 return hedges_g (control , test , is_paired )
8585
86- elif effect_size == "cliffs_delta" :
86+ if effect_size == "cliffs_delta" :
8787 if is_paired :
8888 err1 = "`is_paired` is not None; therefore Cliff's delta is not defined."
8989 raise ValueError (err1 )
90- else :
91- return cliffs_delta (control , test )
90+
91+ return cliffs_delta (control , test )
9292
9393
9494# %% ../../nbs/API/effsize.ipynb 6
@@ -129,10 +129,10 @@ def func_difference(control:list|tuple|np.ndarray, # NaNs are automatically disc
129129
130130 return func (test - control )
131131
132- else :
133- control = control [~ np .isnan (control )]
134- test = test [~ np .isnan (test )]
135- return func (test ) - func (control )
132+
133+ control = control [~ np .isnan (control )]
134+ test = test [~ np .isnan (test )]
135+ return func (test ) - func (control )
136136
137137
138138# %% ../../nbs/API/effsize.ipynb 7
@@ -209,7 +209,8 @@ def cohens_d(control:list|tuple|np.ndarray,
209209 else :
210210 M = np .mean (test ) - np .mean (control )
211211 divisor = pooled_sd
212-
212+
213+ # TODO what if divisor = 0?
213214 return M / divisor
214215
215216# %% ../../nbs/API/effsize.ipynb 8
@@ -289,7 +290,6 @@ def cliffs_delta(control:list|tuple|np.ndarray,
289290 See [here](https://en.wikipedia.org/wiki/Effect_size#Effect_size_for_ordinal_data)
290291 """
291292
292-
293293 # Convert to numpy arrays for speed.
294294 # NaNs are automatically dropped.
295295 if ~ isinstance (control , np .ndarray ):
@@ -307,7 +307,6 @@ def cliffs_delta(control:list|tuple|np.ndarray,
307307 U , _ = mannwhitneyu (t , c , alternative = 'two-sided' )
308308 cliffs_delta = ((2 * U ) / (control_n * test_n )) - 1
309309
310-
311310 return cliffs_delta
312311
313312
@@ -332,7 +331,7 @@ def _compute_standardizers(control, test):
332331 # For paired standardized mean difference.
333332 average = np .sqrt ((control_var + test_var ) / 2 )
334333
335- return pooled , average # indent if you implement above code chunk.
334+ return pooled , average
336335
337336# %% ../../nbs/API/effsize.ipynb 12
338337def _compute_hedges_correction_factor (n1 ,
0 commit comments