Skip to content

Commit 6a067e0

Browse files
docs: refresh readme (#90)
1 parent cca0cb8 commit 6a067e0

File tree

10 files changed

+238
-184
lines changed

10 files changed

+238
-184
lines changed

.github/workflows/version-check.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ Thank you for taking the time to contribute to **gen_surv**! This document provi
1414
4. Ensure the test suite passes with `poetry run pytest`.
1515
5. If you add a feature or fix a bug, update `CHANGELOG.md` accordingly.
1616

17-
## Version Consistency
18-
19-
Releases are tagged in Git. Before creating a release, verify that the version declared in `pyproject.toml` matches the latest Git tag:
20-
21-
```bash
22-
python scripts/check_version_match.py
23-
```
24-
25-
The CI workflow `version-check.yml` runs this same script on pull requests to `main`.
26-
2717
## Submitting Changes
2818

2919
1. Commit your changes with clear messages.

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
[ci-link]: https://github.com/DiogoRibeiro7/genSurvPy/actions/workflows/ci.yml
1717
[py-badge]: https://img.shields.io/pypi/pyversions/gen_surv
1818

19-
**gen_surv** is a Python library for simulating survival data under a wide range of statistical models. Inspired by the R package [genSurv](https://cran.r-project.org/package=genSurv), it offers a unified interface for generating realistic datasets for research, teaching and benchmarking.
19+
**gen_surv** is a Python library for simulating survival data and producing visualizations under a wide range of statistical models. Inspired by the R package [genSurv](https://cran.r-project.org/package=genSurv), it offers a unified interface for generating realistic datasets for research, teaching and benchmarking.
2020

2121
---
2222

@@ -29,10 +29,10 @@
2929
- Time-homogeneous hidden Markov model (THMM)
3030
- Mixture cure and piecewise exponential models
3131
- Competing risks generators (constant and Weibull hazards)
32-
- Visualization utilities for simulated datasets
32+
- Visualization helpers built on matplotlib and lifelines
3333
- Scikit-learn compatible data generator
34-
- Conversion helpers for scikit-survival and lifelines
35-
- Command-line interface and export utilities
34+
- Conversion utilities for scikit-survival
35+
- Command-line interface for dataset creation and visualization
3636

3737
## Installation
3838

@@ -44,29 +44,34 @@ Install the latest release from PyPI:
4444
pip install gen-surv
4545
```
4646

47+
`gen_surv` installs matplotlib and lifelines for visualization. Support for scikit-survival is optional; install it to enable integration with the scikit-survival ecosystem or to run the full test suite:
48+
49+
```bash
50+
pip install gen-surv[dev]
51+
```
52+
4753
To develop locally with all extras:
4854

4955
```bash
5056
git clone https://github.com/DiogoRibeiro7/genSurvPy.git
5157
cd genSurvPy
52-
# Install runtime and development dependencies
53-
# (scikit-survival is optional but required for integration tests).
54-
# On Debian/Ubuntu you may need `build-essential gfortran libopenblas-dev` to
55-
# build scikit-survival.
5658
poetry install --with dev
5759
```
5860

59-
Integration tests that rely on scikit-survival are automatically skipped if the package is not installed.
61+
On Debian/Ubuntu you may need `build-essential gfortran libopenblas-dev` to build scikit-survival.
6062

61-
## Development Setup
63+
## Development
6264

63-
Before committing changes, install the pre-commit hooks:
65+
Before committing changes, install the pre-commit hooks and run the tests:
6466

6567
```bash
6668
pre-commit install
6769
pre-commit run --all-files
70+
pytest
6871
```
6972

73+
Tests that depend on optional packages such as scikit-survival are skipped automatically when those packages are missing.
74+
7075
## Usage
7176

7277
### Python API
@@ -75,7 +80,6 @@ pre-commit run --all-files
7580
from gen_surv import generate, export_dataset, to_sksurv
7681
from gen_surv.visualization import plot_survival_curve
7782

78-
# basic Cox proportional hazards data
7983
sim = generate(
8084
model="cphm",
8185
n=100,
@@ -96,12 +100,16 @@ See the [usage guide](https://gensurvpy.readthedocs.io/en/latest/getting_started
96100

97101
### Command Line
98102

99-
Datasets can be generated without writing Python code:
103+
Generate datasets and plots without writing Python code:
100104

101105
```bash
102106
python -m gen_surv dataset cphm --n 1000 -o survival.csv
107+
108+
python -m gen_surv visualize survival.csv --output survival_plot.png
103109
```
104110

111+
`visualize` accepts custom column names via `--time-col` and `--status-col` and can stratify by group with `--group-col`.
112+
105113
## Supported Models
106114

107115
| Model | Description |
@@ -145,3 +153,4 @@ If you use **gen_surv** in your research, please cite the project using the meta
145153
- ORCID: <https://orcid.org/0009-0001-2022-7072>
146154
- Professional email: <[email protected]>
147155
- Personal email: <[email protected]>
156+
- GitHub: [@DiogoRibeiro7](https://github.com/DiogoRibeiro7)

gen_surv/integration.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,15 @@ def to_sksurv(
3535
except ImportError as exc: # pragma: no cover - optional dependency
3636
raise ImportError("scikit-survival is required for this feature.") from exc
3737

38-
return Surv.from_dataframe(event_col, time_col, df)
38+
# ``Surv.from_dataframe`` expects the event indicator to be boolean.
39+
# Validate the column is binary before casting to avoid silently
40+
# accepting unexpected values (e.g., NaNs or numbers other than 0/1).
41+
df_copy = df.copy()
42+
events = df_copy[event_col]
43+
if events.isna().any():
44+
raise ValueError("event indicator contains missing values")
45+
if not events.isin([0, 1, False, True]).all():
46+
raise ValueError("event indicator must be binary")
47+
df_copy[event_col] = events.astype(bool)
48+
49+
return Surv.from_dataframe(event_col, time_col, df_copy)

scripts/check_version_match.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

tasks.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,6 @@ def test(c: Context) -> None:
4949
print(stderr_output)
5050

5151

52-
@task
53-
def checkversion(c: Context) -> None:
54-
"""Check that ``pyproject.toml`` matches the latest Git tag.
55-
56-
This task executes ``scripts/check_version_match.py`` to ensure the version
57-
declared in ``pyproject.toml`` agrees with the most recent tag.
58-
59-
Args:
60-
c: Invoke context used to run shell commands.
61-
62-
Raises:
63-
TypeError: If ``c`` is not an Invoke :class:`Context`.
64-
"""
65-
if not isinstance(c, Context):
66-
raise TypeError(f"Expected Invoke Context, got {type(c).__name__!r}")
67-
68-
# Execute the version check script with Poetry.
69-
cmd = "poetry run python scripts/check_version_match.py"
70-
result = c.run(cmd, warn=True, pty=False)
71-
72-
# Report based on the exit code from the script.
73-
if result.ok:
74-
print("✔️ pyproject version matches the latest git tag.")
75-
else:
76-
print("❌ Version mismatch detected.")
77-
print(result.stderr)
78-
79-
8052
@task
8153
def docs(c: Context) -> None:
8254
"""Build the Sphinx documentation.

0 commit comments

Comments
 (0)