Skip to content
Merged

Test #53

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: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "funcnodes-span"
version = "1.0.0"
version = "1.0.1"
description = "SPectral ANalysis (SPAN) for funcnodes"
readme = "README.md"
classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",]
Expand Down
2 changes: 1 addition & 1 deletion src/funcnodes_span/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from funcnodes_lmfit import NODE_SHELF as LMFIT_NODE_SHELF
from .curves import CURVES_NODE_SHELF

__version__ = "1.0.0"
__version__ = "1.0.1"

NODE_SHELF = fn.Shelf(
name="Spectral Analysis",
Expand Down
21 changes: 21 additions & 0 deletions src/funcnodes_span/peak_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,27 @@ def peak_finder(
if y[peak] > height:
peak_lst.append([left_min, peak, right_min])

# Optionally re-center peak indices based on selected source
if len(peak_lst) > 0:
for k, (i_idx, idx, f_idx) in enumerate(peak_lst):
i = max(0, int(i_idx))
f = min(len(_y) - 1, int(f_idx))
if f <= i:
continue
if index_source == "original" and on is not None:

Copilot AI Sep 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks on is not None but the variable on is not defined in the visible scope. This will raise a NameError when index_source == "original".

Suggested change
if index_source == "original" and on is not None:
if index_source == "original":

Copilot uses AI. Check for mistakes.
# Use argmax on the original (or differently processed) signal within bounds
local_argmax = int(np.argmax(_y[i : f + 1])) + i

Copilot AI Sep 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using _y for argmax calculation when the comment mentions 'original signal', but _y appears to be the processed signal. The variable name and logic don't match the intended behavior described in the comment.

Suggested change
local_argmax = int(np.argmax(_y[i : f + 1])) + i
local_argmax = int(np.argmax(on[i : f + 1])) + i

Copilot uses AI. Check for mistakes.
peak_lst[k] = [i_idx, local_argmax, f_idx]
elif index_source == "centroid":
# Center-of-mass within bounds on original signal
yy = _y[i : f + 1]
w = yy - np.min(yy)
w = np.maximum(w, 0)
if np.sum(w) > 0:
cm = int(np.round(np.average(np.arange(i, f + 1), weights=w)))
cm = int(np.clip(cm, i, f))
peak_lst[k] = [i_idx, cm, f_idx]

peak_properties_list = []

for peak_nr, peak in enumerate(peak_lst):
Expand Down
Loading