diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 33df3b1..a6c059a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/README.md b/README.md index 4c4799f..4bf47ea 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -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) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..747ffb7 --- /dev/null +++ b/docs/make.bat @@ -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 diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..944a592 --- /dev/null +++ b/docs/source/conf.py @@ -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'] + diff --git a/docs/source/gen_surv.rst b/docs/source/gen_surv.rst new file mode 100644 index 0000000..34d6528 --- /dev/null +++ b/docs/source/gen_surv.rst @@ -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: diff --git a/docs/source/index.md b/docs/source/index.md new file mode 100644 index 0000000..7da4b49 --- /dev/null +++ b/docs/source/index.md @@ -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) diff --git a/docs/source/modules.md b/docs/source/modules.md new file mode 100644 index 0000000..a038506 --- /dev/null +++ b/docs/source/modules.md @@ -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 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 4d00c4a..13d36d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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