@@ -349,8 +349,8 @@ def _create_alpha_correction(
349349 self .approx_bayes_factors : np .ndarray = np .array ([])
350350 self .xt : np .ndarray = np .array ([])
351351 self .levels : np .ndarray = np .array ([])
352- self .uniform_distribution : bool = False
353- self .uniformity_p_value : float = np . nan
352+ self .uniform_distribution : Optional [ bool ] = None
353+ self .uniformity_p_value : Optional [ float ] = None
354354
355355 def format_data (
356356 self , xt : Union [np .ndarray , list ], levels : Optional [np .ndarray ] = None
@@ -459,16 +459,18 @@ def fit(
459459 [approximate_bayes_factor (p_value ) for p_value in p_values ], dtype = float
460460 )
461461
462- uniformity_p_value = np . nan
463- uniform_distribution = False
462+ uniformity_p_value : Optional [ float ] = None
463+ uniform_distribution : Optional [ bool ] = None
464464 if self .definition == "peak_based" and np .sum (xt ) > 0 :
465465 uniformity_p_value = float (chisquare (xt ).pvalue )
466+ uniform_distribution = bool (
467+ np .isfinite (uniformity_p_value ) and uniformity_p_value > 0.05
468+ )
466469 # Match R behavior: fixed 0.05 threshold for the Pearson chi-square test.
467- if np . isfinite ( uniformity_p_value ) and uniformity_p_value > 0.05 :
470+ if uniform_distribution :
468471 modes = np .array ([], dtype = int )
469472 p_values = np .array ([], dtype = float )
470473 approx_bayes_factors = np .array ([], dtype = float )
471- uniform_distribution = True
472474
473475 if len (levels ) == 0 :
474476 self .levels = np .arange (len (xt ))
0 commit comments