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
18 changes: 11 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: CI

on: [push, pull_request]
on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
Expand All @@ -14,27 +17,28 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install ruff mypy pytest
python -m pip install ".[test]"

- name: Lint with ruff
run: |
ruff .
continue-on-error: true
python -m ruff check remode tests

- name: Check types with mypy
run: |
mypy remode/remode.py
python -m mypy remode/remode.py

- name: Run tests with pytest
run: |
pytest
python -m pytest -q
7 changes: 6 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Upload Python Package
on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: read
Expand All @@ -17,15 +18,19 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip

- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build
python -m pip install build twine

- name: Build package
run: python -m build

- name: Validate package metadata
run: python -m twine check dist/*

- name: Publish package
uses: pypa/gh-action-pypi-publish@db8f07d3871a0a180efa06b95d467625c19d5d5f
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

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

# Create an instance of ReMoDe
detector = ReMoDe()
detector = ReMoDe(alpha_correction="descriptive_peaks") # default

# Fit model
results = detector.fit(xt_count)
# results contains:
# - nr_of_modes
# - modes
# - p_values
# - approx_bayes_factors

# Plot the results
detector.plot_maxima()

# Perform stability analysis
stability_info = detector.evaluate_stability(percentage_steps=50)
stability_info = detector.remode_stability(percentage_steps=50)

```


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


### Citation

Please cite the following paper:
Expand Down
20 changes: 9 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"setuptools_scm[toml]>=6.0"
]
requires = ["setuptools>=61", "setuptools-scm>=8", "wheel"]
build-backend = "setuptools.build_meta"

[project]
Expand Down Expand Up @@ -31,7 +27,6 @@ dynamic = ["version"]


classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -41,16 +36,19 @@ classifiers = [
"Operating System :: OS Independent",
]


[tool.setuptools_scm]
write_to = "remode/_version.py"


[project.optional-dependencies]
test = [
"ruff", "pytest", "mypy"
]

[tool.setuptools_scm]
write_to = "remode/_version.py"
tag_regex = "^(?:v)?(?P<version>\\d+\\.\\d+(?:\\.\\d+)?)$"
local_scheme = "no-local-version"

[tool.setuptools.packages.find]
include = ["remode*"]

[project.urls]
homepage = "https://github.com/sodascience/remode"
repository = "https://github.com/sodascience/remode"
Expand Down
12 changes: 11 additions & 1 deletion remode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
"""Import ReMoDe class and statistical tests."""

__all__ = ['ReMoDe', 'perform_fisher_test', 'perform_binomial_test']
from importlib.metadata import PackageNotFoundError, version

__all__ = ['ReMoDe', 'perform_fisher_test', 'perform_binomial_test', '__version__']

from .remode import ReMoDe, perform_fisher_test, perform_binomial_test

try:
__version__ = version('ReMoDe')
except PackageNotFoundError:
try:
from ._version import version as __version__
except ImportError:
__version__ = '0+unknown'
Loading