Skip to content

threshold_firm returns NaN at the threshold when value_low == value_high #880

Description

@whyvineet

pywt.threshold_firm returns NaN for input values whose magnitude is exactly equal to the threshold in the case where value_low is equal to value_high. This is unexpected because the function's docstring clearly states that when value_high equals value_low, threshold_firm is equivalent to hard thresholding.

If ``value_high == value_low`` this function becomes hard-thresholding.

Reproducer

import numpy as np
import pywt

data = np.array([1.0, 2.0, -2.0, 3.0])

print(pywt.threshold_firm(data, 2.0, 2.0))

Current result:

[ 0. nan nan  3.]

Expected result:

[ 0.  2. -2.  3.]

which is the same result as:

pywt.threshold(data, 2.0, mode="hard")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions