check if there is no p values to correct
@@ -12,6 +12,9 @@ def benjamini_hochberg(false_discovery_rate, original_p_values):
:return: new critical value (i.e. the corrected alpha)
:rtype: float
"""
+ if not original_p_values:
+ raise ValueError("empty array of p values to analyse")
+
p_values_sorted = np.sort(np.asarray(original_p_values))
number_tests = len(original_p_values)
significant_ranks = [i for i, val in enumerate(p_values_sorted, 1) if val <= i * false_discovery_rate / number_tests]
@@ -30,4 +33,7 @@ def bonferroni(false_positive_rate, original_p_values):
:return: new critical value (i.e. the corrected alpha)
:rtype: float
"""
+ if not original_p_values:
+ raise ValueError("empty array of p values to analyse")
+
return false_positive_rate / len(original_p_values)
