Skip to content

Fix the example in the README - #26

Merged
remlapmot merged 4 commits into
mainfrom
fix-example-typo
Dec 10, 2025
Merged

Fix the example in the README#26
remlapmot merged 4 commits into
mainfrom
fix-example-typo

Conversation

@remlapmot

Copy link
Copy Markdown
Contributor

In trying to use this on our short course practical I just noticed that the README example no longer runs.

Hopefully this is the fix.

@ryan-odearyan-odea left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for noticing!
I was just about to PR some vignettes and the readme update and you beat me to it! - I think load_data() needs to be load_data("SEQdata")

@remlapmot

Copy link
Copy Markdown
ContributorAuthor

Thanks Ryan, I've added that.

It was working without it as you have specified that as the default value of the argument in the function definition but I agree it makes it clearer with it.

@remlapmot
remlapmot merged commit 2e162a7 into mainDec 10, 2025
5 checks passed
@ryan-odea
ryan-odea deleted the fix-example-typo branch December 10, 2025 09:31
remlapmot added a commit that referenced this pull request Jun 9, 2026
The hazard ratio is computed by a g-formula Monte-Carlo simulation that needs the fitted outcome model, so running the bootstrap across a process pool requires those models to survive a pickle roundtrip. glum's _GlumFit
held a patsy DesignInfo, which raises NotImplementedError on pickle (patsy #26), so parallel=True and offload=True both crashed under glm_package="glum".
Three fixes make the process-pool route work:
- _GlumFit now records the formula and a small reference frame and rebuilds
its DesignInfo in __setstate__, instead of pickling the DesignInfo. Safe here because _cast_categories freezes categorical level order and the models use only stateless transforms (precomputed squares, explicit-knot splines). Roundtrip preserves params, bse, and predictions exactly.
- SEQuential.__getstate__ drops the glum-only _patsy_design_cache, which also holds (unpicklable) DesignInfo objects and otherwise rode along when the object crossed a process boundary.
- _bootstrap_worker now calls the raw, undecorated fit body via __wrapped__ rather than the @bootstrap_loop-wrapped method. Going through the wrapper re-entered bootstrap_loop and returned [model_dict] (a list) instead of model_dict, crashing the hazard/survival consumers that index outcome_model[i]["outcome"]. This was a pre-existing bug affecting both the statsmodels and glum backends.
parallel=True now bit-matches the serial hazard ratio + CI for both backends; offload=True + glum and fit(parallel=True) + glum both work.
Tests:
- test_glum.py: _GlumFit pickle roundtrip preserves params and predictions.
- test_parallel.py: parallel hazard matches serial (statsmodels and glum).
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@remlapmot@ryan-odea