@@ -1969,7 +1969,7 @@ def _prep_ratio_data(
19691969 The indices of the rows where the ratio is above the threshold.
19701970 """
19711971 # Work with a copy of the dataframe
1972- df = df .copy ()
1972+ df : pd . DataFrame = df .copy () # noqa
19731973
19741974 # check that ratio_thresh is a number
19751975 if not isinstance (ratio_thresh , (int , float , type (None ))):
@@ -1999,20 +1999,13 @@ def _prep_ratio_data(
19991999 df ["SigCat" ] = "not significant" # default value
20002000 if ratio_thresh is not None :
20012001 if col_name2 is None :
2002- # significantly up
2003- df .loc [df [col_name1 ] > ratio_thresh , "SigCat" ] = "ratio_thresh"
2004- # significantly down
2005- df .loc [df [col_name1 ] < ratio_thresh * - 1 , "SigCat" ] = "ratio_thresh"
2002+ # significantly up or down
2003+ df .loc [df [col_name1 ].abs () > ratio_thresh , "SigCat" ] = "ratio_thresh"
20062004 else :
2007- # significantly up
2008- df .loc [
2009- (df [col_name1 ] > ratio_thresh ) & (df [col_name2 ] > ratio_thresh ),
2010- "SigCat" ,
2011- ] = "ratio_thresh"
2012- # significantly down
2005+ # significantly up or down in both
20132006 df .loc [
2014- (df [col_name1 ] < ratio_thresh * - 1 )
2015- & (df [col_name2 ] < ratio_thresh * - 1 ),
2007+ (df [col_name1 ]. abs () > ratio_thresh )
2008+ & (df [col_name2 ]. abs () > ratio_thresh ),
20162009 "SigCat" ,
20172010 ] = "ratio_thresh"
20182011
@@ -2023,7 +2016,7 @@ def _prep_ratio_data(
20232016
20242017
20252018def _ratio_plot_style_axes (
2026- ax : plt .Axes , ratio_thresh_x : float or None , ratio_thresh_y : float or None
2019+ ax : plt .Axes , ratio_thresh_x : float | None , ratio_thresh_y : float | None
20272020):
20282021 if ratio_thresh_x is not None :
20292022 ax .axvline (x = ratio_thresh_x , color = "grey" , linestyle = "--" , alpha = 0.8 )
0 commit comments