Thanks to visit codestin.com
Credit goes to github.com

Skip to content

peak_picking with smooth parameter as a NumPy array crashes #247

@carlthome

Description

@carlthome

The docstring states:

smooth : int or numpy array
    Smooth the activation function with the kernel (size).

However, the following crashes:

import numpy as np
from madmom.features.onsets import peak_picking

activations = np.random.random_sample((3, 2))
xs, ys = peak_picking(activations, threshold=0.5, smooth=np.array([0, 3]))

The error has to do with the NumPy array:

ValueError                                Traceback (most recent call last)
<ipython-input-66-9fad6d78cba8> in <module>()
      1 activations = np.random.random_sample((3, 2))
----> 2 xs, ys = peak_picking(activations, threshold=0.5, smooth=np.array([0, 3]))

/home/carl/anaconda3/lib/python3.6/site-packages/madmom/features/onsets.py in peak_picking(activations, threshold, smooth, pre_avg, post_avg, pre_max, post_max)
    919     """
    920     # smooth activations
--> 921     if smooth not in (None, 0):
    922         activations = smooth_signal(activations, smooth)
    923     # compute a moving average

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Am I misunderstanding the documentation or is this a bug? Or is it only allowed to pass a 1D array with a single element? Then maybe that should be removed from the docstring entirely, as it's a bit confusing IMO.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions