Skip to content

Commit

Permalink
Update rtd
Browse files Browse the repository at this point in the history
  • Loading branch information
arvkevi committed Jul 8, 2023
1 parent cff906a commit 588bcc2
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 90 deletions.
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx==6.2.1
sphinx_rtd_theme==1.2.2
178 changes: 88 additions & 90 deletions kneed/knee_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class KneeLocator(object):
:type x: 1D array of shape (`number_of_y_values`,) or list
:param y: y values, must be the same length as x.
:type y: 1D array of shape (`number_of_y_values`,) or list
:param S: Sensitivity, original paper suggests default of 1.0
:param S: Sensitivity, the number of minimum number of data points below the local distance maximum before calling a knee. The original paper suggests default of 1.0
:type S: float
:param curve: If 'concave', algorithm will detect knees. If 'convex', it
will detect elbows.
Expand All @@ -37,6 +37,93 @@ class KneeLocator(object):
:type online: bool
:param polynomial_degree: The degree of the fitting polynomial. Only used when interp_method="polynomial". This argument is passed to numpy polyfit `deg` parameter.
:type polynomial_degree: int
:ivar x: x values.
:vartype x: array-like
:ivar y: y values.
:vartype y: array-like
:ivar S: Sensitivity, original paper suggests default of 1.0
:vartype S: integer
:ivar curve: If 'concave', algorithm will detect knees. If 'convex', it
will detect elbows.
:vartype curve: str
:ivar direction: one of {"increasing", "decreasing"}
:vartype direction: str
:ivar interp_method: one of {"interp1d", "polynomial"}
:vartype interp_method: str
:ivar online: kneed will correct old knee points if True, will return first knee if False
:vartype online: str
:ivar polynomial_degree: The degree of the fitting polynomial. Only used when interp_method="polynomial". This argument is passed to numpy polyfit `deg` parameter.
:vartype polynomial_degree: int
:ivar N: The number of `x` values in the
:vartype N: integer
:ivar all_knees: A set containing all the x values of the identified knee points.
:vartype all_knees: set
:ivar all_norm_knees: A set containing all the normalized x values of the identified knee points.
:vartype all_norm_knees: set
:ivar all_knees_y: A list containing all the y values of the identified knee points.
:vartype all_knees_y: list
:ivar all_norm_knees_y: A list containing all the normalized y values of the identified knee points.
:vartype all_norm_knees_y: list
:ivar Ds_y: The y values from the fitted spline.
:vartype Ds_y: numpy array
:ivar x_normalized: The normalized x values.
:vartype x_normalized: numpy array
:ivar y_normalized: The normalized y values.
:vartype y_normalized: numpy array
:ivar x_difference: The x values of the difference curve.
:vartype x_difference: numpy array
:ivar y_difference: The y values of the difference curve.
:vartype y_difference: numpy array
:ivar maxima_indices: The indices of each of the maxima on the difference curve.
:vartype maxima_indices: numpy array
:ivar maxima_indices: The indices of each of the maxima on the difference curve.
:vartype maxima_indices: numpy array
:ivar x_difference_maxima: The x values from the difference curve where the local maxima are located.
:vartype x_difference_maxima: numpy array
:ivar y_difference_maxima: The y values from the difference curve where the local maxima are located.
:vartype y_difference_maxima: numpy array
:ivar minima_indices: The indices of each of the minima on the difference curve.
:vartype minima_indices: numpy array
:ivar minima_indices: The indices of each of the minima on the difference curve.
:vartype maxima_indices: numpy array
:ivar x_difference_minima: The x values from the difference curve where the local minima are located.
:vartype x_difference_minima: numpy array
:ivar y_difference_minima: The y values from the difference curve where the local minima are located.
:vartype y_difference_minima: numpy array
:ivar Tmx: The y values that correspond to the thresholds on the difference curve for determining the knee point.
:vartype Tmx: numpy array
:ivar knee: The x value of the knee point.
:vartype knee: float
:ivar knee_y: The y value of the knee point.
:vartype knee_y: float
:ivar norm_knee: The normalized x value of the knee point.
:vartype norm_knee: float
:ivar norm_knee_y: The normalized y value of the knee point.
:vartype norm_knee_y: float
:ivar all_knees: The x values of all the identified knee points.
:vartype all_knees: set
:ivar all_knees_y: The y values of all the identified knee points.
:vartype all_knees: set
:ivar all_norm_knees: The normalized x values of all the identified knee points.
:vartype all_norm_knees: set
:ivar all_norm_knees_y: The normalized y values of all the identified knee points.
:vartype all_norm_knees: set
:ivar elbow: The x value of the elbow point (elbow and knee are interchangeable).
:vartype elbow: float
:ivar elbow_y: The y value of the knee point (elbow and knee are interchangeable).
:vartype elbow_y: float
:ivar norm_elbow: The normalized x value of the knee point (elbow and knee are interchangeable).
:vartype norm_knee: float
:ivar norm_elbow_y: The normalized y value of the knee point (elbow and knee are interchangeable).
:vartype norm_elbow_y: float
:ivar all_elbows: The x values of all the identified knee points (elbow and knee are interchangeable).
:vartype all_elbows: set
:ivar all_elbows_y: The y values of all the identified knee points (elbow and knee are interchangeable).
:vartype all_elbows: set
:ivar all_norm_elbows: The normalized x values of all the identified knee points (elbow and knee are interchangeable).
:vartype all_norm_elbows: set
:ivar all_norm_elbowss_y: The normalized y values of all the identified knee points (elbow and knee are interchangeable).
:vartype all_norm_elbows: set
"""

def __init__(
Expand All @@ -50,95 +137,6 @@ def __init__(
online: bool = False,
polynomial_degree: int = 7,
):
"""
:ivar x: x values.
:vartype x: array-like
:ivar y: y values.
:vartype y: array-like
:ivar S: Sensitivity, original paper suggests default of 1.0
:vartype S: integer
:ivar curve: If 'concave', algorithm will detect knees. If 'convex', it
will detect elbows.
:vartype curve: str
:ivar direction: one of {"increasing", "decreasing"}
:vartype direction: str
:ivar interp_method: one of {"interp1d", "polynomial"}
:vartype interp_method: str
:ivar online: kneed will correct old knee points if True, will return first knee if False
:vartype online: str
:ivar polynomial_degree: The degree of the fitting polynomial. Only used when interp_method="polynomial". This argument is passed to numpy polyfit `deg` parameter.
:vartype polynomial_degree: int
:ivar N: The number of `x` values in the
:vartype N: integer
:ivar all_knees: A set containing all the x values of the identified knee points.
:vartype all_knees: set
:ivar all_norm_knees: A set containing all the normalized x values of the identified knee points.
:vartype all_norm_knees: set
:ivar all_knees_y: A list containing all the y values of the identified knee points.
:vartype all_knees_y: list
:ivar all_norm_knees_y: A list containing all the normalized y values of the identified knee points.
:vartype all_norm_knees_y: list
:ivar Ds_y: The y values from the fitted spline.
:vartype Ds_y: numpy array
:ivar x_normalized: The normalized x values.
:vartype x_normalized: numpy array
:ivar y_normalized: The normalized y values.
:vartype y_normalized: numpy array
:ivar x_difference: The x values of the difference curve.
:vartype x_difference: numpy array
:ivar y_difference: The y values of the difference curve.
:vartype y_difference: numpy array
:ivar maxima_indices: The indices of each of the maxima on the difference curve.
:vartype maxima_indices: numpy array
:ivar maxima_indices: The indices of each of the maxima on the difference curve.
:vartype maxima_indices: numpy array
:ivar x_difference_maxima: The x values from the difference curve where the local maxima are located.
:vartype x_difference_maxima: numpy array
:ivar y_difference_maxima: The y values from the difference curve where the local maxima are located.
:vartype y_difference_maxima: numpy array
:ivar minima_indices: The indices of each of the minima on the difference curve.
:vartype minima_indices: numpy array
:ivar minima_indices: The indices of each of the minima on the difference curve.
:vartype maxima_indices: numpy array
:ivar x_difference_minima: The x values from the difference curve where the local minima are located.
:vartype x_difference_minima: numpy array
:ivar y_difference_minima: The y values from the difference curve where the local minima are located.
:vartype y_difference_minima: numpy array
:ivar Tmx: The y values that correspond to the thresholds on the difference curve for determining the knee point.
:vartype Tmx: numpy array
:ivar knee: The x value of the knee point.
:vartype knee: float
:ivar knee_y: The y value of the knee point.
:vartype knee_y: float
:ivar norm_knee: The normalized x value of the knee point.
:vartype norm_knee: float
:ivar norm_knee_y: The normalized y value of the knee point.
:vartype norm_knee_y: float
:ivar all_knees: The x values of all the identified knee points.
:vartype all_knees: set
:ivar all_knees_y: The y values of all the identified knee points.
:vartype all_knees: set
:ivar all_norm_knees: The normalized x values of all the identified knee points.
:vartype all_norm_knees: set
:ivar all_norm_knees_y: The normalized y values of all the identified knee points.
:vartype all_norm_knees: set
:ivar elbow: The x value of the elbow point (elbow and knee are interchangeable).
:vartype elbow: float
:ivar elbow_y: The y value of the knee point (elbow and knee are interchangeable).
:vartype elbow_y: float
:ivar norm_elbow: The normalized x value of the knee point (elbow and knee are interchangeable).
:vartype norm_knee: float
:ivar norm_elbow_y: The normalized y value of the knee point (elbow and knee are interchangeable).
:vartype norm_elbow_y: float
:ivar all_elbows: The x values of all the identified knee points (elbow and knee are interchangeable).
:vartype all_elbows: set
:ivar all_elbows_y: The y values of all the identified knee points (elbow and knee are interchangeable).
:vartype all_elbows: set
:ivar all_norm_elbows: The normalized x values of all the identified knee points (elbow and knee are interchangeable).
:vartype all_norm_elbows: set
:ivar all_norm_elbowss_y: The normalized y values of all the identified knee points (elbow and knee are interchangeable).
:vartype all_norm_elbows: set
"""
# Step 0: Raw Input
self.x = np.array(x)
self.y = np.array(y)
Expand Down
22 changes: 22 additions & 0 deletions readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# We recommend specifying your dependencies to enable reproducible builds:
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt

0 comments on commit 588bcc2

Please sign in to comment.