Skip to content

Commit

Permalink
Merge branch 'main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
arvkevi authored Jun 4, 2024
2 parents 6d80768 + ea2f90f commit 5f6f370
Show file tree
Hide file tree
Showing 27 changed files with 365 additions and 273 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install build setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
16 changes: 8 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
name: Unit tests and coverage

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

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, macos-latest, windows-latest]
env:
OS: ${{ matrix.os }}
PYHTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install -r requirements.txt
pip install -e .
pip install -e .[testing]
- name: Generate coverage report
run: |
pytest --cov-report=xml
pytest --cov=kneed --cov-report=xml:coverage1.xml tests/test_sample.py
pip uninstall -y matplotlib
pytest --cov=kneed --cov-report=xml:coverage2.xml tests/test_no_matplotlib.py
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
env_vars: OS,PYTHON
fail_ci_if_error: true
Expand Down
15 changes: 4 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ I have tried to follow the `Kneedle` algorithm as best as I could interpret from
but the source code is far from perfect and could benefit from improvements.

- Submit a bug report or feature request on [GitHub Issues](https://github.com/arvkevi/kneed/issues).
- Contribute a Jupyter notebook to [notebooks](https://github.com/arvkevi/kneed/tree/master/notebooks).
- Contribute a Jupyter notebook to [notebooks](https://github.com/arvkevi/kneed/tree/main/notebooks).
- Documenting applications where `kneed` could be useful.
- Code refactors -- the code was refactored in `0.4.0` to be more human-readable. However I think the code could still be greatly improved
by breaking the `KneeLocator` class into a collection of methods. This would make the algorithm easier to unittest.
Expand Down Expand Up @@ -55,18 +55,11 @@ Once forked, use the following steps to get your development environment set up

3. Install dependencies.

Kneed's dependencies are in the `requirements.txt` document at the root of the repository. Open this file and uncomment the dependencies that are for development only. Then install the dependencies with `pip`:
Kneed's main dependencies are in the `requirements.txt` document at the root of the repository, however you will later also need to install testing dependencies.
Install them all with `pip`:

```
$ pip install -r requirements.txt
```

Note that there are dependencies required for testing, you can simply install them with `pip`. For example to install
the additional dependencies for building the documentation or to run the
test suite, use the `requirements.txt` files in those directories:

```
$ pip install -r tests/requirements.txt
$ pip install -e .[testing]
```

At this point you're ready to get started writing code!
Expand Down
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# kneed
Knee-point detection in Python

[![Downloads](https://pepy.tech/badge/kneed)](https://pepy.tech/project/kneed) [![Downloads](https://pepy.tech/badge/kneed/week)](https://pepy.tech/project/kneed) ![Dependents](https://badgen.net/github/dependents-repo/arvkevi/kneed/?icon=github) [![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/arvkevi/ikneed/main/ikneed.py) [![Build Status](https://travis-ci.com/arvkevi/kneed.svg?branch=master)](https://travis-ci.com/arvkevi/kneed) [![codecov](https://codecov.io/gh/arvkevi/kneed/branch/master/graph/badge.svg)](https://codecov.io/gh/arvkevi/kneed)[![DOI](https://zenodo.org/badge/113799037.svg)](https://zenodo.org/badge/latestdoi/113799037)
[![Downloads](https://pepy.tech/badge/kneed)](https://pepy.tech/project/kneed) [![Downloads](https://pepy.tech/badge/kneed/week)](https://pepy.tech/project/kneed) ![Dependents](https://badgen.net/github/dependents-repo/arvkevi/kneed/?icon=github) [![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/arvkevi/ikneed/main/ikneed.py) [![codecov](https://codecov.io/gh/arvkevi/kneed/branch/main/graph/badge.svg)](https://codecov.io/gh/arvkevi/kneed)[![DOI](https://zenodo.org/badge/113799037.svg)](https://zenodo.org/badge/latestdoi/113799037)


This repository is an attempt to implement the kneedle algorithm, published [here](https://www1.icsi.berkeley.edu/~barath/papers/kneedle-simplex11.pdf). Given a set of `x` and `y` values, `kneed` will return the knee point of the function. The knee point is the point of maximum curvature.

![](https://raw.githubusercontent.com/arvkevi/kneed/master/images/functions_args_summary.png)
![](https://raw.githubusercontent.com/arvkevi/kneed/main/images/functions_args_summary.png)

## Table of contents
- [Installation](#installation)
Expand All @@ -20,7 +20,7 @@ This repository is an attempt to implement the kneedle algorithm, published [her
- [Citation](#citation)

## Installation
`kneed` has been tested with Python 3.5, 3.6, 3.7, 3.8, 3.9, and 3.10.
`kneed` has been tested with Python 3.7, 3.8, 3.9, and 3.10.

**anaconda**
```bash
Expand All @@ -29,13 +29,14 @@ $ conda install -c conda-forge kneed

**pip**
```bash
$ pip install kneed
$ pip install kneed # To install only knee-detection algorithm
$ pip install kneed[plot] # To also install plotting functions for quick visualizations
```

**Clone from GitHub**
```bash
$ git clone https://github.com/arvkevi/kneed.git
$ python setup.py install
$ git clone https://github.com/arvkevi/kneed.git && cd kneed
$ pip install -e .
```

## Usage
Expand Down Expand Up @@ -85,14 +86,14 @@ The `KneeLocator` class also has two plotting functions for quick visualizations
kneedle.plot_knee_normalized()
```

![](https://raw.githubusercontent.com/arvkevi/kneed/master/images/figure2.knee.png)
![](https://raw.githubusercontent.com/arvkevi/kneed/main/images/figure2.knee.png)

```python
# Raw data and knee.
kneedle.plot_knee()
```

![](https://raw.githubusercontent.com/arvkevi/kneed/master/images/figure2.knee.raw.png)
![](https://raw.githubusercontent.com/arvkevi/kneed/main/images/figure2.knee.raw.png)

## Documentation
Documentation of the parameters and a full API reference can be found [here](https://kneed.readthedocs.io/).
Expand All @@ -109,7 +110,7 @@ You can also run your own version -- head over to the [source code for ikneed](h

## Contributing

Contributions are welcome, please refer to [CONTRIBUTING](https://github.com/arvkevi/kneed/blob/master/CONTRIBUTING.md)
Contributions are welcome, please refer to [CONTRIBUTING](https://github.com/arvkevi/kneed/blob/main/CONTRIBUTING.md)
to learn more about how to contribute.

## Citation
Expand Down
24 changes: 0 additions & 24 deletions codecov.yml

This file was deleted.

36 changes: 22 additions & 14 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

import kneed


# -- Project information -----------------------------------------------------

project = 'kneed'
copyright = '2020, Kevin Arvai'
author = 'Kevin Arvai'
project = "kneed"
copyright = "2020, Kevin Arvai"
author = "Kevin Arvai"

# The full version, including alpha/beta/rc tags
release = '0.6.0'
release = kneed.__version__

version = kneed.__version__


# -- General configuration ---------------------------------------------------
Expand All @@ -31,19 +36,22 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.coverage',
'sphinx.ext.napoleon',
'sphinx_rtd_theme'
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
"sphinx.ext.napoleon",
"sphinx_rtd_theme",
]

pygments_style = "sphinx"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------
Expand All @@ -56,8 +64,8 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = []

autoclass_content = 'both'
autoclass_content = "both"

master_doc = 'index'
master_doc = "index"
7 changes: 4 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ Welcome to kneed's documentation!

This is the documentation for the `kneed <https://github.com/arvkevi/kneed>`__ Python package.
Given `x` and `y` arrays, `kneed` attempts to identify the knee/elbow point of a line fit to the data.
The knee/elbow is defined as the point of the line with maximum curvature. For more information about how each of
the parameters affect identification of knee points, check out :ref:`parameters`. For a full reference of the API,
head over to the :ref:`api`.
The knee/elbow is defined as the point of the line with maximum curvature.

For more information about how each of the parameters affect identification of knee points, check out :ref:`parameters`.
For a full reference of the API, head over to the :ref:`api`.

.. toctree::
parameters
Expand Down
4 changes: 1 addition & 3 deletions docs/interactive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ Interactive Streamlit App
=========================

An interactive streamlit app was developed to help users explore the effect of tuning the parameters.
There are two sites where you can test out kneed by copy-pasting your own data:

1. https://share.streamlit.io/arvkevi/ikneed/main/ikneed.py
2. https://ikneed.herokuapp.com/
https://share.streamlit.io/arvkevi/ikneed/main/ikneed.py

You can also run your own version -- head over to the source code for ikneed_.

Expand Down
4 changes: 2 additions & 2 deletions docs/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ Any `S`>200 will result in a knee at 482 (0.48, normalized) in the plot above.
online
------

The knee point can be corrected if the parameter online is `True` (default). This mode will step through each element
The knee point can be corrected if the parameter online is `True`. This mode will step through each element
in x.
In contrast, if online is False, kneed will run in offline mode and return the first knee point identified.
In contrast, if online is `False` (default), kneed will run in offline mode and return the first knee point identified.
When `online=False` the first knee point identified is returned regardless of whether it's the local maxima on the
difference curve or the global maxima.
So the algorithm stops early. When `online=True`, kneed runs in online mode and "corrects" itself by continuing to
Expand Down
9 changes: 9 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sphinx==6.2.1
sphinx_rtd_theme==1.2.2
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
3 changes: 1 addition & 2 deletions kneed/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .data_generator import DataGenerator
from .knee_locator import KneeLocator
from .shape_detector import find_shape

from .version import __version__
from ._version import __version__
1 change: 1 addition & 0 deletions kneed/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.8.5"
Loading

0 comments on commit 5f6f370

Please sign in to comment.