Skip to content

Use soft thresholding for an infinite firm upper threshold - #888

Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
PyWavelets:mainfrom
AHMETHAKANBEZIR1:fix/firm-infinite-upper-threshold
Open

AHMETHAKANBEZIR1 wants to merge 1 commit into
PyWavelets:mainfrom
AHMETHAKANBEZIR1:fix/firm-infinite-upper-threshold

Conversation

@AHMETHAKANBEZIR1

Copy link
Copy Markdown

threshold_firm documents that an infinite upper threshold gives soft-thresholding, but threshold_firm([-3., 0., 3.], 2., np.inf) currently returns [nan, 0., nan] instead of [-1., 0., 1.]. The finite expression computes an inf / inf scale.

Use the existing soft-thresholding implementation for an infinite upper threshold, after the existing threshold validation. No change to the finite firm-threshold formula is needed.

Validation on Python 3.12.14/NumPy 2.5.4/Windows MSVC build:

  • Eight new cases cover float32/float64/complex64/complex128, lower thresholds zero and two, zeros, dtype behavior and unchanged inputs. Against the byte-identical main thresholding module in the baseline wheel, all eight fail; four existing tests selected by -k infinite pass.
  • Real-image example: the built-in camera image, wavedec2(..., 'db2', level=2), and the first horizontal detail subband of shape (130,130), with lower threshold20 and upper thresholdinf. Main produces 16,900 NaNs; the fixed function produces zero NaNs and exactly matches soft-thresholding. This is a locally constructed image-processing reproducer, not a claimed production incident.
  • Rebuilt and installed the fixed wheel. Full compiled package tests: 1,060 passed, 2 skipped.
  • Applicable configured prek hooks and git diff --check pass.

Existing open #881 and #883 address equal thresholds and hard-region indexing respectively. Their changes do not cover the documented infinite-upper-threshold path. The baseline numerical module matched main c9b542b; its wheel included the independent version-metadata adjustment from #887. This PR is based directly on main and does not depend on #887.

Other platforms were not tested. Codex prepared and validated this AI-assisted contribution autonomously; no independent human review is claimed.

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

Successfully merging this pull request may close these issues.

1 participant