Return the axis from AalenJohansenFitter.plot_cumulative_density - #1700
Open
VenishPaneliya wants to merge 1 commit into
Open
VenishPaneliya wants to merge 1 commit into
VenishPaneliya wants to merge 1 commit into
Conversation
The method documents "Returns: ax - a pyplot axis object" but called _plot_estimate(...) without returning it, so it handed back None. Every sibling plot method returns _plot_estimate(...), e.g. KaplanMeierFitter.plot_cumulative_density returns an Axes, so `ax = ajf.plot_cumulative_density(); ax.set_title(...)` failed only here. Added the return and a regression test in TestAalenJohansenFitter. Also corrected two documented defaults in CoxTimeVaryingFitter that disagree with the code: - fit(robust=False) was documented as "(default: True)". Every other fitter documents robust as "(default=False)"; this one claimed robust Huber sandwich errors were on by default when they are not. - _newton_raphson_for_efron_model(show_progress=False) was documented as "(default: True)".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AalenJohansenFitter.plot_cumulative_densityreturnsNoneThe method documents:
but the body ends with a bare call:
Every sibling plot method returns that call —
return _plot_estimate(self, estimate=..., **kwargs)— so this is the only one that drops the axis:so
ax = ajf.plot_cumulative_density(); ax.set_title(...)raisesAttributeError. Added thereturn.Regression test:
TestAalenJohansenFitter::test_plot_cumulative_density_returns_axis. It fails onmasterand passes with the fix. I put it intest_estimation.pyrather thantest_plotting.pydeliberately — theTestPlottingclass isskipif("DISPLAY" not in os.environ), so a test there wouldn't run in headless CI.Two documented defaults in
CoxTimeVaryingFitterfit(robust=False)was documented as(default: True). Every other fitter documentsrobust: bool, optional (default=False), so this one was the outlier — and it's a meaningful one, since it told users the Huber sandwich (Wei–Lin) robust standard errors were on by default when they aren't. I matched the house wording._newton_raphson_for_efron_model(show_progress=False)was documented as(default: True).I left
BreslowFlemingHarringtonFitter.fit'salpha: float, optional (default=0.05)alone even though the signature isalpha=None— that wording is used foralphain 20 places across the fitters to describe the effective default, so it's a convention rather than a mistake.Tests
TestAalenJohansenFitterandTestCoxTimeVaryingFittertogether: 45 passed with the change against 44 onmaster— the difference is the new test.black --line-length 130 --checkreports the three touched files as needing reformatting, but it does so identically on an unmodified checkout, so I didn't reformat unrelated code.