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
2 changes: 2 additions & 0 deletions .github/workflows/python-test-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
Expand Down
41 changes: 35 additions & 6 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# fetch-depth: '0' is needed to fetch tags for hatch-vcs (and thus setuptools-scm)
# to generate the version correctly; only really needed for jobs that would build and
# upload to pypi, so ignore it since fetching the entire git history can take much longer
# than the default of fetching just the last commit
#with:
#fetch-depth: '0'
with:
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
Expand Down Expand Up @@ -81,6 +77,8 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
Expand Down Expand Up @@ -113,6 +111,8 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
Expand All @@ -124,3 +124,32 @@ jobs:

- name: Lint
run: ruff check .

doctest:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# only test earliest and latest supported Python versions since the examples should
# be fairly simple
python-version: ['3.9', '3.13']

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

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

- name: Install dependencies
# TODO will need to think of how to handle doctests when they rely on optional dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ".[test, doctest]"

- name: Run doctests
run: pytest pybaselines --doctest-modules
18 changes: 18 additions & 0 deletions docs/algorithms/classification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ method. The plot below shows such an example.

.. plot::
:align: center
:include-source: False
:show-source-link: True

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -75,6 +77,8 @@ points, and then iteratively fitting a polynomial to the interpolated baseline.
.. plot::
:align: center
:context: reset
:include-source: False
:show-source-link: True

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -206,6 +210,8 @@ the noise's standard deviation as belonging to the baseline.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down Expand Up @@ -234,6 +240,8 @@ of the median of the noise's standard deviation distribution.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down Expand Up @@ -263,6 +271,8 @@ threshold, and peak regions are iteratively interpolated until the baseline is b
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down Expand Up @@ -291,6 +301,8 @@ other points have a weight of 0.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

scales = np.arange(2, 40)
# to see contents of create_data function, look at the top-most algorithm's code
Expand Down Expand Up @@ -327,6 +339,8 @@ a weight of 0.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down Expand Up @@ -369,6 +383,8 @@ peak positions.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down Expand Up @@ -397,6 +413,8 @@ slightly reduced, as seen below.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down
6 changes: 6 additions & 0 deletions docs/algorithms/misc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ with user interfaces and is not encouraged otherwise.

.. plot::
:align: center
:include-source: False
:show-source-link: True

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -81,6 +83,8 @@ as sparse.
.. plot::
:align: center
:context: reset
:include-source: False
:show-source-link: True

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -205,6 +209,8 @@ of the beads function.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the second-to-top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down
28 changes: 26 additions & 2 deletions docs/algorithms/morphological.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ below. The algorithms in this section use these operations to estimate the basel
.. plot::
:align: center
:context: reset
:include-source: False
:show-source-link: True

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -80,6 +82,8 @@ method.
.. plot::
:align: center
:context: reset
:include-source: False
:show-source-link: True

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -212,6 +216,8 @@ erosion and dilation of the opening to create the baseline.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand All @@ -235,6 +241,8 @@ create the baseline.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand All @@ -252,6 +260,8 @@ kernel, to produce a smooth baseline.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand All @@ -276,6 +286,8 @@ and opening of either the data (first iteration) or previous iteration's baselin
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand All @@ -294,6 +306,8 @@ resembles rolling a ball across the data.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand All @@ -315,6 +329,8 @@ then smooths the result with a moving average.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand All @@ -340,6 +356,8 @@ tophat (Top-hat Transformation)
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down Expand Up @@ -367,6 +385,8 @@ Finally, a penalized spline is fit to the smoothed data with the assigned weight
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down Expand Up @@ -419,11 +439,11 @@ linear equations:

.. math::

(I + 2 \gamma D_d^{\top} D_d) s^n = y - v^{n-1}
(I + 2 \gamma D_d^{\mathsf{T}} D_d) s^n = y - v^{n-1}

.. math::

(I + 2 \alpha I + 2 \beta D_d^{\top} D_d) v^n = y - s^n + 2 \alpha Op
(I + 2 \alpha I + 2 \beta D_d^{\mathsf{T}} D_d) v^n = y - s^n + 2 \alpha Op

where :math:`I` is the identity matrix and :math:`D_d` is the matrix version
of :math:`\Delta^d`, which is also the d-th derivative of the identity matrix.
Expand All @@ -433,6 +453,8 @@ multipliers.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand All @@ -452,6 +474,8 @@ of the jbcd function.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the second-to-top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down
8 changes: 8 additions & 0 deletions docs/algorithms/optimizers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ An example of data with added baseline and Gaussian peaks is shown below.

.. plot::
:align: center
:include-source: False
:show-source-link: True

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -88,6 +90,8 @@ added linear regions is selected as the optimal parameter.
.. plot::
:align: center
:context: reset
:include-source: False
:show-source-link: True

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -225,6 +229,8 @@ algorithm versus the individual baselines from the mpls method.
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

x = np.linspace(1, 1000, 500)
signal = (
Expand Down Expand Up @@ -283,6 +289,8 @@ the name).
.. plot::
:align: center
:context: close-figs
:include-source: False
:show-source-link: True

# to see contents of create_data function, look at the top-most algorithm's code
figure, axes, handles = create_plots(data, baselines)
Expand Down
Loading
Loading