Skip to content

Commit

Permalink
Merge pull request #6 from derb12/development
Browse files Browse the repository at this point in the history
Merge Development for v0.4.0
  • Loading branch information
derb12 committed May 30, 2021
2 parents 043aa78 + 89c8476 commit eddc550
Show file tree
Hide file tree
Showing 42 changed files with 1,137 additions and 491 deletions.
16 changes: 16 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[bumpversion]
current_version = 0.4.0
commit = False
tag = False

[bumpversion:file:setup.cfg]
search = version = {current_version}
replace = version = {new_version}

[bumpversion:file:pybaselines/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'

[bumpversion:file:docs/conf.py]
search = version = '{current_version}'
replace = version = '{new_version}'
66 changes: 66 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,72 @@
Changelog
=========

Version 0.4.0 (2021-05-30)
--------------------------

This is a minor version with new features, bug fixes, and deprecations.

New Features
~~~~~~~~~~~~

* Significantly reduced both the calculation time and memory usage of polynomial.loess.
For example, getting the baseline for a dataset with 20,000 points now takes ~12 seconds
and ~0.7 Gb of memory compared to ~55 seconds and ~3 Gb of memory in version 0.3.
* Added a `conserve_memory` parameter to polynomial.loess that will recalculate the distance
kernels each iteration, which is slower than the default but uses very little memory. For
example, using loess with `conserve_memory` set to True on a dataset with 20,000 points
takes ~18 seconds while using ~0 Gb of memory.
* Allow more user inputs for optimizers.optimize_extended_range to allow specifying the range
of `lam`/`poly_order` values to test and to have more control over the added lines and
Gaussians on the sides.
* Added a constant called PERMC_SPEC (accessed from pybaselines.utils.PERMC_SPEC),
which is used by SciPy's sparse solver when using Whittaker-smoothing-based algorithms.
Changed the default value to "NATURAL", which reduced the computation time of all
Whittaker-smoothing-based algorithms by ~5-35% compared to other permc_spec options
on the tested system.
* misc.interp_pts (formerly manual.linear_interp) now allows specifying any interpolation
method supported by scipy.interpolate.interp1d, allowing for methods such as spline
interpolation.

Bug Fixes
~~~~~~~~~

* Fixed poly_order calculation for optimizers.adaptive_minmax when poly_order was a
single item within a container.
* Potential fix for namespace error with utils; accessing pybaselines.utils gave an
attribute error in very specific envinronments, so changed the import order in
pybaselines.__init__ to potentially fix it. Updated the quick start example in case
the fix is not correct so that the example will still work.
* Increased minimum NumPy version to 1.14 to use rcond=None with numpy.linalg.lstsq.

Other Changes
~~~~~~~~~~~~~

* polynomial.loess now allows inputting weights, specifying a `use_original` keyword for
thresholding to match the modpoly and imodpoly functions, and specifying a `return_coef`
keyword to allow returning the polynomial coefficients for each x-value to recreate
the fitted polynomial, to match all other polynomial functions.
* Changed the default `smooth_half_window` value in window.noise_median, window.snip, and
morphological.mormol to None, rather than being fixed values. Each function sets its default
slightly different but still follows the behavior in previous versions, except for
window.noise_median as noted below.
* Changed default `smooth_half_window` value for window.noise_median to match specified
`half_window` value rather than 1.
* Changed default `sigma` value for window.noise_median to scale with the specified
`smooth_half_window`, rather than being a fixed value.

Deprecations/Breaking Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Renamed pybaselines.manual to pybaselines.misc to allow for adding any future
miscellaneous algorithms that will not fit elsewhere.
* Renamed the manual.linear_interp function to misc.interp_pts to reflect its more
general interpolation usage.
* The parameter dictionary returned from Whittaker-smoothing-based functions
no longer includes 'roughness' and 'fidelity' values since the values were not used
elsewhere.


Version 0.3.0 (2021-04-29)
--------------------------

Expand Down
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
include LICENSE.txt
include README.rst
include LICENSES_bundled.txt
include CHANGELOG.rst

exclude .readthedocs.yaml
exclude .gitattributes
exclude .gitignore
exclude .*

recursive-exclude .git *
recursive-exclude .github *
Expand Down
27 changes: 14 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pybaselines
:alt: BSD 3-clause license


pybaselines is a collection of baseline algorithms for fitting experimental data.
pybaselines is a collection of algorithms for estimating the baseline of experimental data.

* For Python 3.6+
* Open Source: BSD 3-Clause License
Expand Down Expand Up @@ -83,9 +83,9 @@ e) Optimizers (pybaselines.optimizers)
2) optimize_extended_range
3) adaptive_minmax (Adaptive MinMax)

f) Manual methods (pybaselines.manual)
f) Miscellaneous methods (pybaselines.misc)

1) linear_interp (Linear interpolation between points)
1) interp_pts (Interpolation between points)


Installation
Expand All @@ -97,8 +97,8 @@ Dependencies
pybaselines requires `Python <https://python.org>`_ version 3.6 or later
and the following libraries:

* `NumPy <https://numpy.org>`_ (>= 1.9)
* `SciPy <https://www.scipy.org/scipylib/index.html>`_
* `NumPy <https://numpy.org>`_ (>= 1.14)
* `SciPy <https://www.scipy.org/scipylib/index.html>`_ (>= 0.11)


All of the required libraries should be automatically installed when
Expand Down Expand Up @@ -136,7 +136,7 @@ Once the repository is downloaded, it can be installed with:
.. code-block:: console
cd pybaselines
python setup.py install
pip install .
.. _Github repo: https://github.com/derb12/pybaselines
Expand All @@ -160,23 +160,24 @@ A simple example is shown below.

.. code-block:: python
import pybaselines
import matplotlib.pyplot as plt
import numpy as np
import pybaselines
from pybaselines import utils
x = np.linspace(100, 4200, 1000)
# a measured signal containing several Gaussian peaks
signal = (
pybaselines.utils.gaussian(x, 2, 700, 50)
+ pybaselines.utils.gaussian(x, 3, 1200, 150)
+ pybaselines.utils.gaussian(x, 5, 1600, 100)
+ pybaselines.utils.gaussian(x, 4, 2500, 50)
+ pybaselines.utils.gaussian(x, 7, 3300, 100)
utils.gaussian(x, 2, 700, 50)
+ utils.gaussian(x, 3, 1200, 150)
+ utils.gaussian(x, 5, 1600, 100)
+ utils.gaussian(x, 4, 2500, 50)
+ utils.gaussian(x, 7, 3300, 100)
)
# baseline is a polynomial plus a broad gaussian
true_baseline = (
10 + 0.001 * x
+ pybaselines.utils.gaussian(x, 6, 2000, 2000)
+ utils.gaussian(x, 6, 2000, 2000)
)
noise = np.random.default_rng(1).normal(0, 0.2, x.size)
Expand Down
6 changes: 0 additions & 6 deletions docs/_templates/autoapi/python/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@

.. py:module:: {{ obj.name }}
{% if obj.docstring %}
.. autoapi-nested-parse::

{{ obj.docstring|prepare_docstring|indent(3) }}

{% endif %}
{% block subpackages %}
{% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
Expand Down
100 changes: 100 additions & 0 deletions docs/_templates/autoapi/python/package.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{% if not obj.display %}
:orphan:

{% endif %}
{{ obj.name }}
{{ "=" * obj.name|length }}

.. py:module:: {{ obj.name }}
{% if obj.docstring %}
.. autoapi-nested-parse::

{{ obj.docstring|prepare_docstring|indent(3) }}

{% endif %}

{% block subpackages %}
{% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
{% if visible_subpackages %}
Subpackages
-----------
.. toctree::
:titlesonly:
:maxdepth: 3

{% for subpackage in visible_subpackages %}
{{ subpackage.short_name }}/index.rst
{% endfor %}


{% endif %}
{% endblock %}
{% block submodules %}
{% set visible_submodules = obj.submodules|selectattr("display")|list %}
{% if visible_submodules %}
Submodules
----------

.. toctree::
:titlesonly:
:maxdepth: 1

{% for submodule in visible_submodules %}
{{ submodule.short_name }}/index.rst
{% endfor %}


{% endif %}
{% endblock %}
{% block content %}
{% if obj.all is not none %}
{% set visible_children = obj.children|selectattr("short_name", "in", obj.all)|list %}
{% elif obj.type is equalto("package") %}
{% set visible_children = obj.children|selectattr("display")|list %}
{% else %}
{% set visible_children = obj.children|selectattr("display")|rejectattr("imported")|list %}
{% endif %}
{% if visible_children %}
{{ obj.type|title }} Contents
{{ "-" * obj.type|length }}---------

{% set visible_classes = visible_children|selectattr("type", "equalto", "class")|list %}
{% set visible_functions = visible_children|selectattr("type", "equalto", "function")|list %}
{% if "show-module-summary" in autoapi_options and (visible_classes or visible_functions) %}
{% block classes scoped %}
{% if visible_classes %}
Classes
~~~~~~~

.. autoapisummary::

{% for klass in visible_classes %}
{{ klass.id }}
{% endfor %}


{% endif %}
{% endblock %}

{% block functions scoped %}
{% if visible_functions %}
Functions
~~~~~~~~~

.. autoapisummary::
:nosignatures:

{% for function in visible_functions %}
{{ function.id }}
{% endfor %}


{% endif %}
{% endblock %}
{% endif %}
{% for obj_item in visible_children %}
{{ obj_item.rendered|indent(0) }}
{% endfor %}
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion docs/algorithms/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ are not fully optimized for the data).
morphological
window
optimizers
manual
misc
14 changes: 0 additions & 14 deletions docs/algorithms/manual.rst

This file was deleted.

16 changes: 16 additions & 0 deletions docs/algorithms/misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=======================
Miscellaneous Baselines
=======================

The contents of :mod:`pybaselines.misc` contain miscellaneous baseline algorithms
that do not fit in other categories.

Algorithms
----------

interp_pts (Interpolation between points)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Interpolates between input points using line segments or splines of
different orders. Mainly intended for usage with user interfaces and
is not encouraged otherwise.
2 changes: 1 addition & 1 deletion docs/algorithms/whittaker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ in pybaselines to distinguish them from polynomial techniques that also take
advantage of weighted least squares (like :func:`.loess`) and penalized least
squares (like :func:`.penalized_poly`).

The general idea behnind WSB algorithms is to make the baseline match the measured
The general idea behind WSB algorithms is to make the baseline match the measured
data as well as it can while also penalizing the roughness of the baseline. The
resulting general function that is minimized to determine the baseline is then

Expand Down
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#
import os
import sys


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

# -- General configuration ---------------------------------------------
Expand Down Expand Up @@ -64,7 +66,7 @@
# the built documents.
#
# The short X.Y version.
version = '0.3.0'
version = '0.4.0'
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
Binary file modified docs/images/optimizers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pybaselines Documentation
=========================

pybaselines is a collection of algorithms for fitting the baseline of experimental data.
pybaselines is a collection of algorithms for estimating the baseline of experimental data.

* For Python 3.6+
* Open Source: BSD 3-Clause License
Expand Down
6 changes: 3 additions & 3 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Dependencies

pybaselines requires `Python <https://python.org>`_ version 3.6 or later and the following libraries:

* `NumPy <https://numpy.org>`_ (>= 1.9)
* `SciPy <https://www.scipy.org/scipylib/index.html>`_
* `NumPy <https://numpy.org>`_ (>= 1.14)
* `SciPy <https://www.scipy.org/scipylib/index.html>`_ (>= 0.11)


All of the required libraries should be automatically installed when installing pybaselines
Expand Down Expand Up @@ -51,4 +51,4 @@ Once the repository is downloaded, it can be installed with:
.. code-block:: console
cd pybaselines
python setup.py install
pip install .
4 changes: 2 additions & 2 deletions docs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ e) Optimizers (:mod:`pybaselines.optimizers`)
2) optimize_extended_range
3) adaptive_minmax (Adaptive MinMax)

f) Manual methods (:mod:`pybaselines.manual`)
f) Miscellaneous methods (:mod:`pybaselines.misc`)

1) linear_interp (Linear interpolation between points)
1) interp_pts (Interpolation between points)
Loading

0 comments on commit eddc550

Please sign in to comment.