Skip to content

Installation

From PyPI

pip install gen-surv

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:

pip install scikit-survival

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

git clone https://github.com/DiogoRibeiro7/genSurvPy.git
cd genSurvPy
poetry install

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

import gen_surv

print(gen_surv.__version__)
print(len(gen_surv.__all__), "public names")

Or from the shell:

gen_surv --help
gen_surv dataset cphm --n 5

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.