Skip to content

Commit d9455c0

Browse files
committed
Fixes the problem where the Cohen's h was not being calculated correctly
for the case where the sample contains nonbinary variables. It is fixed by replacing try/except with if/else in the calculation function.
1 parent 0a13d57 commit d9455c0

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

dabest/_stats_tools/effsize.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,8 @@ def cohens_h(control, test):
256256
import pandas as pd
257257

258258
# Check whether dataframe contains only 0s and 1s.
259-
try:
260-
pd.unique(control)==np.array([0,1]).all()==False and (pd.unique(test)==np.array([0,1])).all()==False
261-
except:
262-
return None
259+
if pd.unique(control)==np.array([0,1]).all()==False and (pd.unique(test)==np.array([0,1])).all()==False:
260+
raise ValueError("Input data must be binary.")
263261

264262
# Convert to numpy arrays for speed.
265263
# NaNs are automatically dropped.

0 commit comments

Comments
 (0)