Skip to content

Use RuntimeWarning when unpatching more than patching#295

Merged
ndgrigorian merged 3 commits intomasterfrom
use-warning-in-patch
Mar 19, 2026
Merged

Use RuntimeWarning when unpatching more than patching#295
ndgrigorian merged 3 commits intomasterfrom
use-warning-in-patch

Conversation

@ndgrigorian
Copy link
Collaborator

This PR moves the printed message (only in verbose mode) for unpatching more than patching in a thread to a warning, which seems more appropriate

Copilot AI review requested due to automatic review settings March 18, 2026 20:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the NumPy patch/unpatch helper to emit a RuntimeWarning when restore_numpy_fft() is called more times than patch_numpy_fft() within a thread, replacing the prior verbose-only print message.

Changes:

  • Import warnings and replace the verbose-only print with warnings.warn(..., RuntimeWarning, stacklevel=2) in _GlobalPatch.do_restore().

You can also share your feedback on Copilot code review. Take the survey.

@antonwolfy antonwolfy added this to the 2.2.0 release milestone Mar 19, 2026
@ndgrigorian ndgrigorian requested a review from antonwolfy March 19, 2026 15:31
Copy link
Collaborator

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

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

Thank you @ndgrigorian, the only last nit is to populate the changelog, if you don't mind.

@ndgrigorian
Copy link
Collaborator Author

@antonwolfy
done, as no release was made with the patching yet, I've just added it as a follow-up to the patching PR

@ndgrigorian ndgrigorian merged commit 5ae4bf4 into master Mar 19, 2026
82 of 84 checks passed
@ndgrigorian ndgrigorian deleted the use-warning-in-patch branch March 19, 2026 15:55
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.

3 participants