Contributing Guidelines#

This page explains how you can contribute to the development of scikit-survival. There are a lot of ways you can contribute:

  • Writing new code, e.g. implementations of new algorithms, or examples.

  • Fixing bugs.

  • Improving documentation.

  • Reviewing open pull requests.

scikit-survival is developed on GitHub using the Git version control system. The preferred way to contribute to scikit-survival is to fork the main repository on GitHub, then submit a pull request (PR).

Talk to Us First#

We highly recommend saying “Hi!” to us before you start working on scikit-survival. There are two main reasons for this:

  1. We might already have designs or plans related to your idea.

  2. We can support you during the idea stage, which is much more effective than providing feedback after you’ve already written the code.

Just post a message in GitHub Discussions. If you’re not sure what to write, here’s a helpful template:

Hey, my name is {your name}, and I would love to work on {your idea}.

Use of Generative AI#

Contributors using generative AI tools (for example Claude Code) to prepare contributions must follow the Guidelines for using AI tools and declare such use in the AI Disclosure section of the pull request template.

Creating a Fork#

These are the steps you need to take to create a copy of the scikit-survival repository on your computer.

  1. Create an account on GitHub if you do not already have one.

  2. Fork the scikit-survival repository.

  3. Clone your fork of the scikit-survival repository from your GitHub account to your local disk. You have to execute from the command line:

    git clone --recurse-submodules git@github.com:YourLogin/scikit-survival.git
    cd scikit-survival
    

Setting up a Development Environment#

After you created a copy of our main repository on GitHub, you need to setup a local development environment. We strongly recommend to create a separate virtual environment containing all dependencies.

You can use conda or uv to create a new virtual environment and install scikit-survival in development mode.

python ci/render-requirements.py ci/deps/requirements.yaml.tmpl > dev-environment.yaml
conda env create -n sksurv --file dev-environment.yaml
conda run -n sksurv pip install --group dev -e .
uv sync

Making Changes to the Code#

For a pull request to be accepted, your changes must meet the below requirements.

  1. All changes related to one feature must belong to one branch. Each branch must be self-contained, with a single new feature or bug fix. Create a new feature branch by executing:

    git checkout -b my-new-feature
    
  2. All code must follow the standard Python guidelines for code style, PEP8. To check that your code conforms to PEP8, you can install tox and run:

    tox -e lint
    

    Alternatively, you can use pre-commit to check your code on every commit automatically:

    pre-commit install
    
  3. Each function, class, method, and attribute needs to be documented using doc strings. scikit-survival conforms to the numpy docstring standard.

  4. Code submissions must always include unit tests. We are using pytest. All tests must be part of the tests directory. You can run the test suite locally by executing:

    pytest
    

    Tests will also be executed automatically once you submit a pull request.

Submitting a Pull Request#

  1. When you are done coding in your feature branch, add changed or new files:

    git add path/to/modified_file
    
  2. Create a commit message describing what you changed. Commit messages should be clear and concise. The first line should contain the subject of the commit and not exceed 80 characters in length. If necessary, add a blank line after the subject followed by a commit message body with more details:

    git commit
    
  3. Push the changes to GitHub:

    git push -u origin my_feature
    
  4. Create a pull request.

Building the Documentation#

The documentation resides in the doc/ folder and is written in reStructuredText. HTML files of the documentation can be generated using Sphinx. The easiest way to build the documentation is to install tox and run:

tox -e docs

Generated files will be located in doc/_build/html. To open the main page of the documentation, run:

xdg-open _build/html/index.html

Building Cython Code#

Part of the code base is written in Cython. To rebuild this code after making changes, please re-run the install command from the Setting up a Development Environment section.

If you are new to Cython you may find the project’s documentation on debugging and profiling helpful.