Skip to content

Commit 84eeec1

Browse files
authored
Merge pull request #2 from sodascience/new_r_functionality
Align Python ReMoDe with R outputs and update packaging/CI
2 parents 4bfe8aa + 0368775 commit 84eeec1

9 files changed

Lines changed: 351 additions & 150 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
47

58
jobs:
69
build:
@@ -14,27 +17,28 @@ jobs:
1417
steps:
1518
- name: Check out repository
1619
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
1722

1823
- name: Set up Python ${{ matrix.python-version }}
1924
uses: actions/setup-python@v5
2025
with:
2126
python-version: ${{ matrix.python-version }}
27+
cache: pip
2228

2329
- name: Install dependencies
2430
run: |
2531
python -m pip install --upgrade pip
26-
pip install .
27-
pip install ruff mypy pytest
32+
python -m pip install ".[test]"
2833
2934
- name: Lint with ruff
3035
run: |
31-
ruff .
32-
continue-on-error: true
36+
python -m ruff check remode tests
3337
3438
- name: Check types with mypy
3539
run: |
36-
mypy remode/remode.py
40+
python -m mypy remode/remode.py
3741
3842
- name: Run tests with pytest
3943
run: |
40-
pytest
44+
python -m pytest -q

.github/workflows/python-publish.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Upload Python Package
33
on:
44
release:
55
types: [published]
6+
workflow_dispatch:
67

78
permissions:
89
contents: read
@@ -17,15 +18,19 @@ jobs:
1718
uses: actions/setup-python@v5
1819
with:
1920
python-version: '3.x'
21+
cache: pip
2022

2123
- name: Install build tools
2224
run: |
2325
python -m pip install --upgrade pip
24-
pip install build
26+
python -m pip install build twine
2527
2628
- name: Build package
2729
run: python -m build
2830

31+
- name: Validate package metadata
32+
run: python -m twine check dist/*
33+
2934
- name: Publish package
3035
uses: pypa/gh-action-pypi-publish@db8f07d3871a0a180efa06b95d467625c19d5d5f
3136
with:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,6 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161+
162+
# macOS
163+
.DS_Store

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Features
66
- Mode Detection: Identifies all potential local maxima in the dataset.
77
- Statistical Tests: Implements Fisher's exact test and binomial tests to validate modes.
8+
- Mode Statistics: Returns per-mode p-values and approximate Bayes factors.
89
- Data Formatting: Converts raw data into histogram format for analysis.
910
- Stability Analysis: Includes functionality to assess the stability of detected modes using jackknife resampling.
1011
- Visualization: Provides methods to plot the histogram of data along with identified modes.
@@ -26,21 +27,28 @@ from remode import ReMoDe
2627
xt_count = [8, 20, 5, 2, 6, 2, 30]
2728

2829
# Create an instance of ReMoDe
29-
detector = ReMoDe()
30+
detector = ReMoDe(alpha_correction="descriptive_peaks") # default
3031

3132
# Fit model
3233
results = detector.fit(xt_count)
34+
# results contains:
35+
# - nr_of_modes
36+
# - modes
37+
# - p_values
38+
# - approx_bayes_factors
3339

3440
# Plot the results
3541
detector.plot_maxima()
3642

3743
# Perform stability analysis
38-
stability_info = detector.evaluate_stability(percentage_steps=50)
44+
stability_info = detector.remode_stability(percentage_steps=50)
3945

4046
```
4147

48+
4249
See also the tutorial [here](https://github.com/sodascience/remode/blob/main/tutorial.ipynb).
4350

51+
4452
### Citation
4553

4654
Please cite the following paper:

pyproject.toml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
[build-system]
2-
requires = [
3-
"setuptools>=42",
4-
"wheel",
5-
"setuptools_scm[toml]>=6.0"
6-
]
2+
requires = ["setuptools>=61", "setuptools-scm>=8", "wheel"]
73
build-backend = "setuptools.build_meta"
84

95
[project]
@@ -31,7 +27,6 @@ dynamic = ["version"]
3127

3228

3329
classifiers = [
34-
"License :: OSI Approved :: MIT License",
3530
"Programming Language :: Python :: 3",
3631
"Programming Language :: Python :: 3.8",
3732
"Programming Language :: Python :: 3.9",
@@ -41,16 +36,19 @@ classifiers = [
4136
"Operating System :: OS Independent",
4237
]
4338

44-
45-
[tool.setuptools_scm]
46-
write_to = "remode/_version.py"
47-
48-
4939
[project.optional-dependencies]
5040
test = [
5141
"ruff", "pytest", "mypy"
5242
]
5343

44+
[tool.setuptools_scm]
45+
write_to = "remode/_version.py"
46+
tag_regex = "^(?:v)?(?P<version>\\d+\\.\\d+(?:\\.\\d+)?)$"
47+
local_scheme = "no-local-version"
48+
49+
[tool.setuptools.packages.find]
50+
include = ["remode*"]
51+
5452
[project.urls]
5553
homepage = "https://github.com/sodascience/remode"
5654
repository = "https://github.com/sodascience/remode"

remode/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
"""Import ReMoDe class and statistical tests."""
22

3-
__all__ = ['ReMoDe', 'perform_fisher_test', 'perform_binomial_test']
3+
from importlib.metadata import PackageNotFoundError, version
4+
5+
__all__ = ['ReMoDe', 'perform_fisher_test', 'perform_binomial_test', '__version__']
46

57
from .remode import ReMoDe, perform_fisher_test, perform_binomial_test
8+
9+
try:
10+
__version__ = version('ReMoDe')
11+
except PackageNotFoundError:
12+
try:
13+
from ._version import version as __version__
14+
except ImportError:
15+
__version__ = '0+unknown'

0 commit comments

Comments
 (0)