Hello community, here is the log from the commit of package python-PeakUtils for openSUSE:Factory checked in at 2018-10-11 12:00:54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-PeakUtils (Old) and /work/SRC/openSUSE:Factory/.python-PeakUtils.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-PeakUtils" Thu Oct 11 12:00:54 2018 rev:2 rq:641189 version:1.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-PeakUtils/python-PeakUtils.changes 2018-05-29 10:29:10.875359384 +0200 +++ /work/SRC/openSUSE:Factory/.python-PeakUtils.new/python-PeakUtils.changes 2018-10-11 12:01:10.577586891 +0200 @@ -1,0 +2,18 @@ +Thu Oct 11 05:00:29 UTC 2018 - Arun Persaud <[email protected]> + +- specfile: + * remove devel from noarch + * be more specific in %files section + +- update to version 1.3.0: + * added plateau test to perf.py + * fixed failing test on indexes function + * improve handling of plateaus in indexing + +- changes from version 1.2.0: + * Add an option to use an absolute threshold, fixes Issue #28 + * Year bump + * Add doc requirements + * Update doc location + +------------------------------------------------------------------- @@ -14 +31,0 @@ - Old: ---- PeakUtils-1.1.1.tar.gz New: ---- PeakUtils-1.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-PeakUtils.spec ++++++ --- /var/tmp/diff_new_pack.uvUmHw/_old 2018-10-11 12:01:11.041586301 +0200 +++ /var/tmp/diff_new_pack.uvUmHw/_new 2018-10-11 12:01:11.045586295 +0200 @@ -12,30 +12,29 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-PeakUtils -Version: 1.1.1 +Version: 1.3.0 Release: 0 -License: MIT Summary: Peak detection utilities for 1D data -Url: https://bitbucket.org/lucashnegri/peakutils +License: MIT Group: Development/Languages/Python +URL: https://bitbucket.org/lucashnegri/peakutils Source: https://files.pythonhosted.org/packages/source/P/PeakUtils/PeakUtils-%{version}.tar.gz -BuildRequires: %{python_module devel} BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros +Requires: python-numpy +Requires: python-scipy +BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module numpy} BuildRequires: %{python_module scipy} # /SECTION -Requires: python-numpy -Requires: python-scipy -BuildArch: noarch - %python_subpackages %description @@ -61,6 +60,7 @@ %files %{python_files} %doc README.rst %license LICENSE.txt -%{python_sitelib}/* +%{python_sitelib}/peakutils +%{python_sitelib}/PeakUtils-%{version}-*.egg-info %changelog ++++++ PeakUtils-1.1.1.tar.gz -> PeakUtils-1.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/PKG-INFO new/PeakUtils-1.3.0/PKG-INFO --- old/PeakUtils-1.1.1/PKG-INFO 2018-02-13 14:45:27.000000000 +0100 +++ new/PeakUtils-1.3.0/PKG-INFO 2018-09-06 19:41:36.000000000 +0200 @@ -1,12 +1,11 @@ Metadata-Version: 1.1 Name: PeakUtils -Version: 1.1.1 +Version: 1.3.0 Summary: Peak detection utilities for 1D data Home-page: https://bitbucket.org/lucashnegri/peakutils Author: Lucas Hermann Negri Author-email: [email protected] License: MIT -Description-Content-Type: UNKNOWN Description: UNKNOWN Keywords: peak detection search gaussian centroid baseline maximum Platform: UNKNOWN diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/PeakUtils.egg-info/PKG-INFO new/PeakUtils-1.3.0/PeakUtils.egg-info/PKG-INFO --- old/PeakUtils-1.1.1/PeakUtils.egg-info/PKG-INFO 2018-02-13 14:45:27.000000000 +0100 +++ new/PeakUtils-1.3.0/PeakUtils.egg-info/PKG-INFO 2018-09-06 19:41:35.000000000 +0200 @@ -1,12 +1,11 @@ Metadata-Version: 1.1 Name: PeakUtils -Version: 1.1.1 +Version: 1.3.0 Summary: Peak detection utilities for 1D data Home-page: https://bitbucket.org/lucashnegri/peakutils Author: Lucas Hermann Negri Author-email: [email protected] License: MIT -Description-Content-Type: UNKNOWN Description: UNKNOWN Keywords: peak detection search gaussian centroid baseline maximum Platform: UNKNOWN diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/PeakUtils.egg-info/SOURCES.txt new/PeakUtils-1.3.0/PeakUtils.egg-info/SOURCES.txt --- old/PeakUtils-1.1.1/PeakUtils.egg-info/SOURCES.txt 2018-02-13 14:45:27.000000000 +0100 +++ new/PeakUtils-1.3.0/PeakUtils.egg-info/SOURCES.txt 2018-09-06 19:41:35.000000000 +0200 @@ -12,6 +12,7 @@ docs/index.rst docs/make.bat docs/reference.rst +docs/requirements.txt docs/tutorial_a.rst peakutils/__init__.py peakutils/baseline.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/README.rst new/PeakUtils-1.3.0/README.rst --- old/PeakUtils-1.1.1/README.rst 2017-09-08 18:58:22.000000000 +0200 +++ new/PeakUtils-1.3.0/README.rst 2018-02-13 15:11:05.000000000 +0100 @@ -9,7 +9,7 @@ and performing Gaussian fitting or centroid computation to further increase the resolution of the peak detection. -The documentation is available at http://pythonhosted.org/PeakUtils . +The documentation is available at http://peakutils.readthedocs.io/en/latest . Installation ------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/docs/conf.py new/PeakUtils-1.3.0/docs/conf.py --- old/PeakUtils-1.1.1/docs/conf.py 2017-03-30 01:20:46.000000000 +0200 +++ new/PeakUtils-1.3.0/docs/conf.py 2018-02-13 15:21:34.000000000 +0100 @@ -25,7 +25,7 @@ # General information about the project. project = 'PeakUtils' -copyright = '2014 - 2017, Lucas Hermann Negri' +copyright = '2014 - 2018, Lucas Hermann Negri' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/docs/requirements.txt new/PeakUtils-1.3.0/docs/requirements.txt --- old/PeakUtils-1.1.1/docs/requirements.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/PeakUtils-1.3.0/docs/requirements.txt 2018-02-13 15:17:19.000000000 +0100 @@ -0,0 +1 @@ +sphinx-better-theme diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/peakutils/__init__.py new/PeakUtils-1.3.0/peakutils/__init__.py --- old/PeakUtils-1.1.1/peakutils/__init__.py 2018-02-13 14:43:44.000000000 +0100 +++ new/PeakUtils-1.3.0/peakutils/__init__.py 2018-09-06 19:40:09.000000000 +0200 @@ -2,4 +2,4 @@ from .peak import * from .prepare import * -__version__ = '1.1.1' +__version__ = '1.3.0' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/peakutils/peak.py new/PeakUtils-1.3.0/peakutils/peak.py --- old/PeakUtils-1.1.1/peakutils/peak.py 2017-04-28 16:36:44.000000000 +0200 +++ new/PeakUtils-1.3.0/peakutils/peak.py 2018-09-06 19:38:11.000000000 +0200 @@ -8,7 +8,7 @@ eps = np.finfo(float).eps -def indexes(y, thres=0.3, min_dist=1): +def indexes(y, thres=0.3, min_dist=1, thres_abs=False): """Peak detection routine. Finds the numeric index of the peaks in *y* by taking its first order difference. By using @@ -25,6 +25,9 @@ min_dist : int Minimum distance between each detected peak. The peak with the highest amplitude is preferred to satisfy this constraint. + thres_abs: boolean + If True, the thres value will be interpreted as an absolute value, instead of + a normalized threshold. Returns ------- @@ -34,7 +37,9 @@ if isinstance(y, np.ndarray) and np.issubdtype(y.dtype, np.unsignedinteger): raise ValueError("y must be signed") - thres = thres * (np.max(y) - np.min(y)) + np.min(y) + if not thres_abs: + thres = thres * (np.max(y) - np.min(y)) + np.min(y) + min_dist = int(min_dist) # compute first order difference @@ -43,27 +48,40 @@ # propagate left and right values successively to fill all plateau pixels (0-value) zeros,=np.where(dy == 0) - # check if the singal is totally flat + # check if the signal is totally flat if len(zeros) == len(y) - 1: return np.array([]) - - while len(zeros): - # add pixels 2 by 2 to propagate left and right value onto the zero-value pixel - zerosr = np.hstack([dy[1:], 0.]) - zerosl = np.hstack([0., dy[:-1]]) - - # replace 0 with right value if non zero - dy[zeros]=zerosr[zeros] - zeros,=np.where(dy == 0) - - # replace 0 with left value if non zero - dy[zeros]=zerosl[zeros] - zeros,=np.where(dy == 0) + + if len(zeros): + # compute first order difference of zero indexes + zeros_diff = np.diff(zeros) + # check when zeros are not chained together + zeros_diff_not_one, = np.add(np.where(zeros_diff != 1), 1) + # make an array of the chained zero indexes + zero_plateaus = np.split(zeros, zeros_diff_not_one) + + # fix if leftmost value in dy is zero + if zero_plateaus[0][0] == 0: + dy[zero_plateaus[0]] = dy[zero_plateaus[0][-1] + 1] + zero_plateaus.pop(0) + + # fix if rightmost value of dy is zero + if len(zero_plateaus) and zero_plateaus[-1][-1] == len(dy) - 1: + dy[zero_plateaus[-1]] = dy[zero_plateaus[-1][0] - 1] + zero_plateaus.pop(-1) + + # for each chain of zero indexes + for plateau in zero_plateaus: + median = np.median(plateau) + # set leftmost values to leftmost non zero values + dy[plateau[plateau < median]] = dy[plateau[0] - 1] + # set rightmost and middle values to rightmost non zero values + dy[plateau[plateau >= median]] = dy[plateau[-1] + 1] # find the peaks by using the first order difference peaks = np.where((np.hstack([dy, 0.]) < 0.) & (np.hstack([0., dy]) > 0.) - & (y > thres))[0] + & (np.greater(y, thres)))[0] # handle multiple peaks, respecting the minimum distance if peaks.size > 1 and min_dist > 1: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/setup.py new/PeakUtils-1.3.0/setup.py --- old/PeakUtils-1.1.1/setup.py 2018-02-13 14:43:32.000000000 +0100 +++ new/PeakUtils-1.3.0/setup.py 2018-09-06 19:39:48.000000000 +0200 @@ -26,12 +26,13 @@ def finalize_options(self): pass + with open('README.rst') as readme: long_description = readme.read() setup( name='PeakUtils', - version='1.1.1', + version='1.3.0', description='Peak detection utilities for 1D data', author='Lucas Hermann Negri', author_email='[email protected]', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/tests/peakutils_test.py new/PeakUtils-1.3.0/tests/peakutils_test.py --- old/PeakUtils-1.1.1/tests/peakutils_test.py 2018-02-13 14:35:14.000000000 +0100 +++ new/PeakUtils-1.3.0/tests/peakutils_test.py 2018-06-08 19:27:31.000000000 +0200 @@ -72,6 +72,7 @@ numpy.random.random(x.size) * 0.2)).astype(dtype) filtered = scipy.signal.savgol_filter(y, 51, 3).astype(dtype) + idx = peakutils.indexes(filtered, thres=0.3, min_dist=100) peaks = peakutils.interpolate(x, y, idx, width=30) self.assertEqual(idx.size, len(centers)) @@ -109,6 +110,26 @@ out = peakutils.indexes(data, thres=0, min_dist=1) expected = numpy.array([1, 3]) assert_array_almost_equal(out, expected) + + def test_absolute_threshold(self): + x = [0, 5, 0, 8, 0, 15, 0] + out1 = peakutils.indexes(x, thres=3, thres_abs=True) + assert_array_almost_equal(out1, [1, 3, 5]) + + out2 = peakutils.indexes(x, thres=5, thres_abs=True) + assert_array_almost_equal(out2, [3, 5]) + + out3 = peakutils.indexes(x, thres=7, thres_abs=True) + assert_array_almost_equal(out3, [3, 5]) + + out4 = peakutils.indexes(x, thres=14, thres_abs=True) + assert_array_almost_equal(out4, [5]) + + out5 = peakutils.indexes(x, thres=15, thres_abs=True) + assert_array_almost_equal(out5, []) + + out6 = peakutils.indexes(x, thres=16, thres_abs=True) + assert_array_almost_equal(out6, []) class Baseline(unittest.TestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PeakUtils-1.1.1/tests/perf.py new/PeakUtils-1.3.0/tests/perf.py --- old/PeakUtils-1.1.1/tests/perf.py 2016-04-29 17:35:34.000000000 +0200 +++ new/PeakUtils-1.3.0/tests/perf.py 2018-09-06 19:38:11.000000000 +0200 @@ -2,6 +2,7 @@ import peakutils from timeit import default_timer as timer + def make_data(n, noise): x = np.linspace(0, 100, n) y = peakutils.gaussian(x, 5, 20, 10) + \ @@ -14,19 +15,22 @@ tests = [("Small - Low noise", make_data(200, 1.), 100), ("Small - High noise", make_data(200, 3.), 100), ("Big - Low noise", make_data(20000, 1), 5), - ("Big - High noise", make_data(20000, 2.), 5)] - + ("Big - High noise", make_data(20000, 2.), 5), + ("Plateaus", (0, np.insert(np.ones(20000-3), + [1000, 10000, -1000], 3)), 5)] for name, data, rep in tests: begin = timer() for _ in range(rep): y = data[1] - peakutils.baseline(data[1]) + if name is "Plateaus": y = data[1] i = peakutils.indexes(y, thres=0.4, min_dist=y.size // 5) end = timer() each = (end - begin) / rep print("*{}* test took {:.3f} seconds each rep".format(name, each)) + if __name__ == '__main__': np.random.seed(1997) benchit()
