Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.13 #28

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Binary file modified .coverage
Binary file not shown.
29 changes: 29 additions & 0 deletions .github/workflows/241215_old_github_actions
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: dcurves

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
curl -sSL https://install.python-poetry.org | python -
poetry install
- name: Lint with pylint
run: |
poetry run pylint --fail-under 5 dcurves/*.py
- name: Test with pytest
run: |
poetry run pytest --cov=dcurves --cov-report html

22 changes: 14 additions & 8 deletions .github/workflows/github-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,32 @@ on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libopenblas-dev liblapack-dev gfortran
- name: Install Poetry
run: |
python -m pip install --upgrade pip
curl -sSL https://install.python-poetry.org | python -
poetry install
poetry --version
- name: Install dependencies
run: |
poetry config virtualenvs.create true
poetry install
- name: Lint with pylint
run: |
poetry run pylint --fail-under 5 dcurves/*.py
- name: Test with pytest
run: |
poetry run pytest --cov=dcurves --cov-report html

poetry run pytest --cov=dcurves --cov-report html
2 changes: 1 addition & 1 deletion .tox/py310/.tox-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
0
],
"executable": "/opt/homebrew/Cellar/[email protected]/3.10.14_1/Frameworks/Python.framework/Versions/3.10/bin/python3.10",
"virtualenv version": "20.27.1"
"virtualenv version": "20.19.0"
},
"PythonRun": {
"deps": {
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@ This tutorial will guide you through installing and using the `dcurves` package
```bash
# Install dcurves for DCA
pip install dcurves

# Install other required packages
pip install pandas numpy statsmodels lifelines
```

### DCA Example

```python
# Import Libraries
from dcurves import dca, plot_graphs, load_test_data
import pandas as pd
import numpy as np

# Load Package Simulation Data
df_binary = load_test_data.load_binary_df()
Expand Down
1 change: 0 additions & 1 deletion dcurves/risks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import sys
from typing import Optional, Union
import pandas as pd
import numpy as np
import statsmodels.api as sm
import lifelines

Expand Down
15 changes: 15 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project are documented here.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.2] - 2024-12-15

### Added
- Support for Python 3.13.
- Compatibility updates for Black formatting tool.

### Changed
- Updated project configuration to include Python 3.13 testing environment.
- Removed unnecessary dependencies and imports.
- Fixed broken link in project description.

### Fixed
- Resolved configuration issues for Python 3.13 compatibility.
- Updated tox configuration and project dependencies.

## [1.1.1] - 2024-10-25

### Added
Expand Down
Empty file removed docs/NEWS.md
Empty file.
1,400 changes: 528 additions & 872 deletions poetry.lock

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "dcurves"
version = "1.1.1"
description = "A Python package for Decision Curve Analysis to evaluate prediction models, molecular markers, and diagnostic tests. For RELEASE NOTES, check RELEASE.md here: https://github.com/MSKCC-Epi-Bio/dcurves/RELEASE.md"
version = "1.1.2"
description = "A Python package for Decision Curve Analysis to evaluate prediction models, molecular markers, and diagnostic tests. For RELEASE NOTES, check: https://github.com/MSKCC-Epi-Bio/dcurves/blob/main/docs/CHANGELOG.md"
authors = ["shaunporwal <[email protected]>", "rohansingh <[email protected]>"]
readme = "README.md"

Expand All @@ -12,17 +12,14 @@ matplotlib = "^3.7.1"
pandas = ">=1.5.3,<3.0.0"
statsmodels = "0.14.4"
typing = "~3.7.4.3"
mkdocs = "^1.4.2"
mkdocstrings = {extras = ["python"], version = "^0.20.0"}
mkdocs-material = "^9.0.14"
setuptools = "^68.1.2"
setuptools = "^75.6.0"

[tool.poetry.group.dev.dependencies]
pytest = "~7.2.1"
jupyterlab = "~3.6.1"
tox = "^4.4.6"
pytest-cov = "^4.0.0"
black = "^23.1.0"
black = "^24.10.0"
pylint = "^3.3.1"
pytest-mock = "^3.11.1"
tomli = "^2.0.1"
Expand Down Expand Up @@ -50,7 +47,7 @@ filterwarnings = [

[tool.black]
line-length = 100
target-version = ['py39', 'py310', 'py311', 'py312']
target-version = ['py39', 'py310', 'py311', 'py312', 'py313']
include = '\.pyi?$'
extend-exclude = '''
/(
Expand Down
20 changes: 12 additions & 8 deletions tests/test_dca_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ def test_python_joint():
)

df_cancer_dx["conditional"] = df_cancer_dx.apply(
lambda x: 1
if x["risk_group"] == "high"
or (x["risk_group"] == "intermediate" and x["cancerpredmarker"] > 0.15)
else 0,
lambda x: (
1
if x["risk_group"] == "high"
or (x["risk_group"] == "intermediate" and x["cancerpredmarker"] > 0.15)
else 0
),
axis=1,
)

Expand All @@ -153,10 +155,12 @@ def test_python_dca_joint():
)

df_cancer_dx["conditional"] = df_cancer_dx.apply(
lambda x: 1
if x["risk_group"] == "high"
or (x["risk_group"] == "intermediate" and x["cancerpredmarker"] > 0.15)
else 0,
lambda x: (
1
if x["risk_group"] == "high"
or (x["risk_group"] == "intermediate" and x["cancerpredmarker"] > 0.15)
else 0
),
axis=1,
)

Expand Down
1 change: 1 addition & 0 deletions tests/test_optional_gridlines.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module contains tests for optional gridlines in plot functions.
"""

import pytest
import pandas as pd
from dcurves.plot_graphs import _plot_net_benefit, _plot_net_intervention_avoided
Expand Down
25 changes: 15 additions & 10 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ def test_plot_net_benefit_mismatched_color_names():
def test_plot_net_benefit_grid_enabled():
"""Test plot net benefit with grid enabled."""
plt.ioff() # Turn off interactive mode
with patch("matplotlib.pyplot.grid") as mock_grid, patch(
"matplotlib.pyplot.show"
with (
patch("matplotlib.pyplot.grid") as mock_grid,
patch("matplotlib.pyplot.show"),
): # Mock plt.show() to prevent plot display
_plot_net_benefit(
SAMPLE_DATA_DF,
Expand All @@ -211,8 +212,9 @@ def test_plot_net_benefit_grid_enabled():
def test_plot_net_benefit_show_legend_enabled():
"""Test plot net benefit with legend enabled."""
plt.ioff() # Turn off interactive mode
with patch("matplotlib.pyplot.legend") as mock_legend, patch(
"matplotlib.pyplot.show"
with (
patch("matplotlib.pyplot.legend") as mock_legend,
patch("matplotlib.pyplot.show"),
): # Mock plt.show() to prevent plot display
_plot_net_benefit(
SAMPLE_DATA_DF,
Expand All @@ -226,8 +228,9 @@ def test_plot_net_benefit_show_legend_enabled():
def test_plot_net_benefit_show_legend_disabled():
"""Test plot net benefit with legend disabled."""
plt.ioff() # Turn off interactive mode
with patch("matplotlib.pyplot.legend") as mock_legend, patch(
"matplotlib.pyplot.show"
with (
patch("matplotlib.pyplot.legend") as mock_legend,
patch("matplotlib.pyplot.show"),
): # Mock plt.show() to prevent plot display
_plot_net_benefit(
SAMPLE_DATA_DF,
Expand All @@ -241,8 +244,9 @@ def test_plot_net_benefit_show_legend_disabled():
def test_plot_net_intervention_avoided_show_legend_enabled():
"""Test plot net intervention avoided with legend enabled."""
plt.ioff() # Turn off interactive mode
with patch("matplotlib.pyplot.legend") as mock_legend, patch(
"matplotlib.pyplot.show"
with (
patch("matplotlib.pyplot.legend") as mock_legend,
patch("matplotlib.pyplot.show"),
): # Mock plt.show() to prevent plot display
_plot_net_intervention_avoided(
SAMPLE_DATA_DF,
Expand All @@ -256,8 +260,9 @@ def test_plot_net_intervention_avoided_show_legend_enabled():
def test_plot_net_intervention_avoided_show_legend_disabled():
"""Test plot net intervention avoided with legend disabled."""
plt.ioff() # Turn off interactive mode
with patch("matplotlib.pyplot.legend") as mock_legend, patch(
"matplotlib.pyplot.show"
with (
patch("matplotlib.pyplot.legend") as mock_legend,
patch("matplotlib.pyplot.show"),
): # Mock plt.show() to prevent plot display
_plot_net_intervention_avoided(
SAMPLE_DATA_DF,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_surv_consequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def calculate_risk_rate_for_model(model):
r_benchmark_results["risk_rate_among_test_pos"] = (
r_benchmark_results.tp_rate / r_benchmark_results.test_pos_rate
)
r_benchmark_results.loc[
r_benchmark_results.variable == "none", "risk_rate_among_test_pos"
] = float(0)
r_benchmark_results.loc[r_benchmark_results.variable == "none", "risk_rate_among_test_pos"] = (
float(0)
)

# Validate results against benchmarks
for model in ["all", "none", "cancerpredmarker"]:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
isolated_build = True
envlist = py{39,310,311,312}, lint
envlist = py{39,310,311,312,313}, lint

[testenv]
allowlist_externals = poetry
Expand Down
Loading