Skip to content

Scope warning suppression to avoid globally silencing warnings - #696

Merged
khider merged 1 commit into
masterfrom
fix/scoped-warning-suppression
Aug 14, 2026
Merged

khider merged 1 commit into
masterfrom
fix/scoped-warning-suppression

Conversation

@CommonClimate

Copy link
Copy Markdown
Collaborator

warnings.filterwarnings("ignore") at import time in ensembleseries.py and warnings.simplefilter('ignore') in Series.spectral/wavelet/ wavelet_coherence mutated the global warnings filter state and never restored it, permanently silencing all Python warnings for the rest of the session after a single verbose=Falsecall. This also caused wavelet_coherence to silently swallow its own warning about interpolating data onto a common time axis.

This fix now restricts suppression within warnings.catch_warnings() around the relevant numerical computations, and the common_time() interpolation notice is raised as a new DataConformationWarning to mark it as a warning that should always reach the user regardless of verbose.

Fixes #695

warnings.filterwarnings("ignore") at import time in ensembleseries.py
and warnings.simplefilter('ignore') in Series.spectral/wavelet/
wavelet_coherence mutated the global warnings filter state and never
restored it, permanently silencing all Python warnings for the rest
of the session after a single verbose=False call. This also caused
wavelet_coherence to silently swallow its own warning about
reinterpolating data onto a common time axis.

Suppression is now scoped with warnings.catch_warnings() around just
the underlying numerical computation, and the common_time()
reinterpolation notice is raised as a new DataConformationWarning to
mark it as a warning that should always reach the user regardless of
verbose.

Fixes #695

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@CommonClimate
CommonClimate requested a review from khider August 14, 2026 00:46

@khider khider left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving this as a I agree that we shouldn't be hiding that we are doing this but the question I have is why we are doing it in the first place. If the method requires evenly spaced data, we should raise an error and suggest the use of interp().

@khider
khider merged commit 8b2781f into master Aug 14, 2026
1 check passed
@khider
khider deleted the fix/scoped-warning-suppression branch August 14, 2026 01:47
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.

Excessively silent warnings

2 participants