Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method=topology fails in 2.5.5. #27

Closed
mmarras opened this issue Nov 6, 2023 · 1 comment
Closed

method=topology fails in 2.5.5. #27

mmarras opened this issue Nov 6, 2023 · 1 comment

Comments

@mmarras
Copy link

mmarras commented Nov 6, 2023

This update broke my working app. I was on 2.5.3 before. I also tested successfully with 2.5.4.

So after upgrading 2.5.4. -> 2.5.5 "topology" method breaks. For spurious reasons it wants to store a vector of Y.shape = (20,2), albeit X is of X.shape = (20,) . This breaks the method as it expects a 1D-vector.

from the official examples:

# Load library
from findpeaks import findpeaks
# Data
X = [10,11,9,23,21,11,45,20,11,12]
# Initialize
fp = findpeaks(method='peakdetect', lookahead=1)
results = fp.fit(X)
# Plot
fp.plot()

fp = findpeaks(method='topology', lookahead=1)
results = fp.fit(X)
fp.plot()
fp.plot_persistence()

Running the above on Python 3.10, with uptodate pandas:

Traceback (most recent call last):
  File "/home/ubuntu/miniconda3/envs/datamore/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3790, in get_loc
    return self._engine.get_loc(casted_key)
  File "index.pyx", line 152, in pandas._libs.index.IndexEngine.get_loc
  File "index.pyx", line 181, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'rank'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/miniconda3/envs/datamore/lib/python3.10/site-packages/pandas/core/frame.py", line 4261, in _set_item_mgr
    loc = self._info_axis.get_loc(key)
  File "/home/ubuntu/miniconda3/envs/datamore/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3797, in get_loc
    raise KeyError(key) from err
KeyError: 'rank'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/ubuntu/miniconda3/envs/datamore/lib/python3.10/site-packages/findpeaks/findpeaks.py", line 256, in fit
    results = self.peaks1d(X, x=x, method=self.method)
  File "/home/ubuntu/miniconda3/envs/datamore/lib/python3.10/site-packages/findpeaks/findpeaks.py", line 348, in peaks1d
    self.results, self.args = self._store1d(X, Xraw, x, result)
  File "/home/ubuntu/miniconda3/envs/datamore/lib/python3.10/site-packages/findpeaks/findpeaks.py", line 375, in _store1d
    dfint['rank'] = result['Xranked']
  File "/home/ubuntu/miniconda3/envs/datamore/lib/python3.10/site-packages/pandas/core/frame.py", line 4091, in __setitem__
    self._set_item(key, value)
  File "/home/ubuntu/miniconda3/envs/datamore/lib/python3.10/site-packages/pandas/core/frame.py", line 4314, in _set_item
    self._set_item_mgr(key, value, refs)
  File "/home/ubuntu/miniconda3/envs/datamore/lib/python3.10/site-packages/pandas/core/frame.py", line 4264, in _set_item_mgr
    self._mgr.insert(len(self._info_axis), key, value, refs)
  File "/home/ubuntu/miniconda3/envs/datamore/lib/python3.10/site-packages/pandas/core/internals/managers.py", line 1328, in insert
    raise ValueError(
ValueError: Expected a 1D array, got an array with shape (148, 2)
puglet5 added a commit to puglet5/hsdb_sdp that referenced this issue Nov 10, 2023
@erdogant
Copy link
Owner

erdogant commented Nov 10, 2023

Thank you for posting this bug issue! I fixed the bug and updated a new release.
Update to the latest version with:
pip install -U findpeaks

https://github.com/erdogant/findpeaks/releases/tag/2.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants