The print_summary method in the lifelines.statistics.StatisticalResult class was not correctly handling the decimals argument when no explicit style was provided. This led to the output table displaying the default precision of 2 decimals, even if a different value was specified.
Problem: the value of the 'decimals' argument did not propagate properly in the class.
Solution: set self.decimals so that the value is shared properly by all the methods of the class.
Impact: this fix ensures that the desired decimal precision is respected in the output table, even when no specific style is chosen.
For example, the issue was reproduced using the provided example with the results of the logrank_test without explicit 'style' argument, resulting in a incorrect table with a precision of 2 decimals (the default) instead of 10:
from lifelines import statistics as stats
from lifelines.datasets import load_rossi
rossi = load_rossi()
results = stats.logrank_test(
durations_A=rossi.loc[rossi['fin']==0, 'week'],
durations_B=rossi.loc[rossi['fin']==1,'week'],
event_observed_A=rossi.loc[rossi['fin']==0, 'arrest'],
event_observed_B=rossi.loc[rossi['fin']==1,'arrest'],
)
results.print_summary(decimals=10)
The
print_summary
method in thelifelines.statistics.StatisticalResult
class was not correctly handling thedecimals
argument when no explicitstyle
was provided. This led to the output table displaying the default precision of 2 decimals, even if a different value was specified.self.decimals
so that the value is shared properly by all the methods of the class.For example, the issue was reproduced using the provided example with the results of the
logrank_test
without explicit 'style' argument, resulting in a incorrect table with a precision of 2 decimals (the default) instead of 10:This happened only without explicit 'style' was provided, as the following worked well:
With the correction, the call
results.print_summary(decimals=4)
now results in the expected table:Other fitters and regression tables (Cox PH, Weibull, etc.) were not affected by this bug and continue to function as expected.