Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ jobs:

- name: Run tests
run: poetry run pytest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # optional if public repo
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# gen_surv

![Coverage](https://codecov.io/gh/DiogoRibeiro7/genSurvPy/branch/main/graph/badge.svg)

**gen_surv** is a Python package for simulating survival data under a variety of models, inspired by the R package [`genSurv`](https://cran.r-project.org/package=genSurv). It supports data generation for:

- Cox Proportional Hazards Models (CPHM)
Expand Down Expand Up @@ -48,19 +50,30 @@ print(df.head())

```text
genSurvPy/
gen_surv/
├── cphm.py
├── cmm.py
├── tdcm.py
├── thmm.py
├── censoring.py
├── validate.py
examples/
├── run_cphm.py
├── run_cmm.py
├── run_tdcm.py
├── run_thmm.py
└── utils.py # optional for shared config (e.g. seeding)
├── gen_surv/ # Pacote principal
│ ├── __main__.py # Interface CLI via python -m
│ ├── cphm.py
│ ├── cmm.py
│ ├── tdcm.py
│ ├── thmm.py
│ ├── censoring.py
│ ├── bivariate.py
│ ├── validate.py
├── tests/ # Testes automatizados
│ ├── test_cphm.py
│ ├── test_cmm.py
│ ├── test_tdcm.py
│ ├── test_thmm.py
├── examples/ # Exemplos de uso
│ ├── run_cphm.py
│ ├── ...
├── pyproject.toml # Configurado com Poetry
├── README.md
├── LICENSE
├── .gitignore
```

## 🧠 License
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
37 changes: 37 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
import os
import sys
sys.path.insert(0, os.path.abspath('../../gen_surv'))

project = 'gen_suvr'
copyright = '2025, Diogo Ribeiro'
author = 'Diogo Ribeiro'
release = '0.2.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"myst_parser",
]

# Point to index.md or index.rst as the root document
master_doc = "index"

templates_path = ['_templates']
exclude_patterns = []

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']

69 changes: 69 additions & 0 deletions docs/source/gen_surv.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
gen\_surv package
=================

Submodules
----------

gen\_surv.bivariate module
--------------------------

.. automodule:: gen_surv.bivariate
:members:
:undoc-members:
:show-inheritance:

gen\_surv.censoring module
--------------------------

.. automodule:: gen_surv.censoring
:members:
:undoc-members:
:show-inheritance:

gen\_surv.cmm module
--------------------

.. automodule:: gen_surv.cmm
:members:
:undoc-members:
:show-inheritance:

gen\_surv.cphm module
---------------------

.. automodule:: gen_surv.cphm
:members:
:undoc-members:
:show-inheritance:

gen\_surv.tdcm module
---------------------

.. automodule:: gen_surv.tdcm
:members:
:undoc-members:
:show-inheritance:

gen\_surv.thmm module
---------------------

.. automodule:: gen_surv.thmm
:members:
:undoc-members:
:show-inheritance:

gen\_surv.validate module
-------------------------

.. automodule:: gen_surv.validate
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: gen_surv
:members:
:undoc-members:
:show-inheritance:
36 changes: 36 additions & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# gen_surv

**gen_surv** is a Python package for simulating survival data under various models, inspired by the R package `genSurv`.

It includes generators for:

- **Cox Proportional Hazards Models (CPHM)**
- **Continuous-Time Markov Models (CMM)**
- **Time-Dependent Covariate Models (TDCM)**
- **Time-Homogeneous Hidden Markov Models (THMM)**

---

## 📚 Modules

```{toctree}
:maxdepth: 2
:caption: Contents

modules
```


# 🚀 Usage Example

```python
from gen_surv.cphm import gen_cphm

df = gen_cphm(n=100, model_cens="uniform", cens_par=1.0, beta=0.5, covar=2.0)
print(df.head())
```

## 🔗 Project Links

- [Source Code](https://github.com/DiogoRibeiro7/genSurvPy)
- [License](https://github.com/DiogoRibeiro7/genSurvPy/blob/main/LICENSE)
21 changes: 21 additions & 0 deletions docs/source/modules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# API Reference

::: gen_surv.cphm
options:
members: true
undoc-members: true

::: gen_surv.cmm
options:
members: true
undoc-members: true

::: gen_surv.tdcm
options:
members: true
undoc-members: true

::: gen_surv.thmm
options:
members: true
undoc-members: true
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ pytest-cov = "^6.1.1"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.5"
python-semantic-release = "^9.21.0"


[tool.poetry.group.docs.dependencies]
myst-parser = "<4.0.0"

[tool.semantic_release]
version_source = "tag"
version_variable = ["pyproject.toml:project.version"]
version_variable = ["pyproject.toml:tool.poetry.version"]
commit_version_number = true
changelog_file = "CHANGELOG.md"
upload_to_repository = false
Expand Down