@@ -77,7 +77,7 @@ def __init__(self, p_value, test_statistic, name=None, test_name=None, **kwargs)
7777 kwargs ["test_name" ] = test_name
7878 self ._kwargs = kwargs
7979
80- def _print_specific_style (self , style , ** kwargs ):
80+ def _print_specific_style (self , style , decimals = 2 , ** kwargs ):
8181 """
8282 Parameters
8383 -----------
@@ -87,11 +87,11 @@ def _print_specific_style(self, style, **kwargs):
8787
8888 """
8989 if style == "html" :
90- return self ._html_print (** kwargs )
90+ return self ._html_print (decimals = decimals , ** kwargs )
9191 elif style == "ascii" :
92- return self ._ascii_print (** kwargs )
92+ return self ._ascii_print (decimals = decimals , ** kwargs )
9393 elif style == "latex" :
94- return self ._latex_print (** kwargs )
94+ return self ._latex_print (decimals = decimals , ** kwargs )
9595 else :
9696 raise ValueError ("style not available." )
9797
@@ -110,27 +110,26 @@ def print_summary(self, decimals=2, style=None, **kwargs):
110110 multiple outputs.
111111
112112 """
113- self .decimals = decimals
114113 if style is not None :
115- self ._print_specific_style (style )
114+ self ._print_specific_style (style , decimals = decimals , ** kwargs )
116115 else :
117116 try :
118117 from IPython .display import display
119118
120119 display (self )
121120 except ImportError :
122- self ._ascii_print ()
121+ self ._ascii_print (decimals = decimals , ** kwargs )
123122
124- def _html_print (self , ** kwargs ):
125- print (self .to_html (** kwargs ))
123+ def _html_print (self , decimals = 2 , ** kwargs ):
124+ print (self .to_html (decimals , ** kwargs ))
126125
127- def _latex_print (self , ** kwargs ):
128- print (self .to_latex (** kwargs ))
126+ def _latex_print (self , decimals = 2 , ** kwargs ):
127+ print (self .to_latex (decimals , ** kwargs ))
129128
130- def _ascii_print (self , ** kwargs ):
131- print (self .to_ascii (** kwargs ))
129+ def _ascii_print (self , decimals = 2 , ** kwargs ):
130+ print (self .to_ascii (decimals , ** kwargs ))
132131
133- def to_html (self , ** kwargs ):
132+ def to_html (self , decimals = 2 , ** kwargs ):
134133 extra_kwargs = dict (list (self ._kwargs .items ()) + list (kwargs .items ()))
135134 summary_df = self .summary
136135
@@ -141,14 +140,14 @@ def to_html(self, **kwargs):
141140 header_df = pd .DataFrame .from_records (headers ).set_index (0 )
142141 header_html = header_df .to_html (header = False , notebook = True , index_names = False )
143142
144- summary_html = summary_df .to_html (float_format = format_floats (self . decimals ), formatters = {** {"p" : format_p_value (self . decimals )}})
143+ summary_html = summary_df .to_html (float_format = format_floats (decimals ), formatters = {** {"p" : format_p_value (decimals )}})
145144
146145 return header_html + summary_html
147146
148- def to_latex (self , ** kwargs ):
147+ def to_latex (self , decimals = 2 , ** kwargs ):
149148 # This is using the new Style object in Pandas. Previously df.to_latex was giving a warning.
150149 s = self .summary .style
151- s = s .format (precision = self . decimals )
150+ s = s .format (precision = decimals )
152151 return s .to_latex ()
153152
154153 @property
@@ -173,7 +172,7 @@ def summary(self):
173172 df ["-log2(p)" ] = - utils .quiet_log2 (df ["p" ])
174173 return df
175174
176- def to_ascii (self , ** kwargs ):
175+ def to_ascii (self , decimals = 2 , ** kwargs ):
177176 extra_kwargs = dict (list (self ._kwargs .items ()) + list (kwargs .items ()))
178177 meta_data = self ._stringify_meta_data (extra_kwargs )
179178
@@ -183,7 +182,7 @@ def to_ascii(self, **kwargs):
183182 s += "\n " + meta_data + "\n "
184183 s += "---\n "
185184 s += df .to_string (
186- float_format = format_floats (self . decimals ), index = self .name is not None , formatters = {"p" : format_p_value (self . decimals )}
185+ float_format = format_floats (decimals ), index = self .name is not None , formatters = {"p" : format_p_value (decimals )}
187186 )
188187
189188 return s
@@ -836,7 +835,7 @@ def multivariate_logrank_test(
836835 assert abs (Z_j .sum ()) < 10e-8 , "Sum is not zero." # this should move to a test eventually.
837836
838837 # compute covariance matrix
839- factor = (((n_i - d_i ) / (n_i - 1 )).replace ([np .inf , np .nan ], 1 )) * d_i / n_i ** 2
838+ factor = (((n_i - d_i ) / (n_i - 1 )).replace ([np .inf , np .nan ], 1 )) * d_i / n_i ** 2
840839 n_ij ["_" ] = n_i .values
841840 V_ = (n_ij .mul (w_i , axis = 0 )).mul (np .sqrt (factor ), axis = "index" ).fillna (0 ) # weighted V_
842841 V = - np .dot (V_ .T , V_ )
@@ -924,7 +923,7 @@ def proportional_hazard_test(
924923 def compute_statistic (times , resids , n_deaths ):
925924 demeaned_times = times - times .mean ()
926925 T = (demeaned_times .values [:, None ] * resids .values ).sum (0 ) ** 2 / (
927- n_deaths * (fitted_cox_model .standard_errors_ ** 2 ) * (demeaned_times ** 2 ).sum ()
926+ n_deaths * (fitted_cox_model .standard_errors_ ** 2 ) * (demeaned_times ** 2 ).sum ()
928927 )
929928 return T
930929
0 commit comments