Installation¶
From PyPI¶
That is everything you need. The generators, the plotting helpers and the command line tool all work from this single install.
Python support
gen_surv requires Python 3.11, 3.12 or 3.13. It is tested on all
three on every commit.
What comes with it¶
These are hard dependencies, installed for you:
| Package | Used for |
|---|---|
numpy |
random number generation and the sampling routines |
pandas |
every generator returns a DataFrame |
scipy |
distribution functions used by several models |
matplotlib |
the plotting helpers in gen_surv.visualization |
lifelines |
Kaplan-Meier and hazard estimation behind those plots |
typer / click |
the gen_surv command line tool |
pyarrow |
Feather export |
pyreadr |
RDS export, for handing data to R |
The one optional extra¶
scikit-survival is not installed
by default. You need it only for the two conversion helpers,
to_sksurv and
from_sksurv:
Without it, import gen_surv still succeeds — the package detects the missing
dependency and simply does not expose those two names.
scikit-survival needs a compiler on some platforms
It builds against C extensions. If pip struggles, conda-forge ships
prebuilt wheels: conda install -c conda-forge scikit-survival.
From source¶
Add the groups you need:
poetry install --with dev # pytest, mypy, black, isort, flake8, hypothesis, scikit-survival
poetry install --with docs # mkdocs-material and mkdocstrings, to build this site
Verifying the install¶
Or from the shell:
Type checking¶
The package ships a py.typed marker, so a type checker reads the annotations
on every public function instead of treating the package as untyped:
from gen_surv import gen_cphm
gen_cphm(n="not an integer", beta=0.5, covariate_range=2.0,
model_cens="uniform", cens_par=1.0)
snippet.py:3: error: Argument "n" to "gen_cphm" has incompatible type "str"; expected "int" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Before 3.0.0 the marker was missing, so a type checker reported
Cannot find implementation or library stub for module named "gen_surv" and
accepted the call above without comment.
Building the documentation¶
This site is built with MkDocs and Material for MkDocs:
poetry install --with docs
poetry run mkdocs serve # live-reloading preview on http://127.0.0.1:8000
poetry run mkdocs build # static site into ./site
The published site is rebuilt automatically whenever a release is published, so it always documents the version that is on PyPI.