FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix mlab fallback for 32-bit systems by QuLogic · Pull Request #30273 · matplotlib/matplotlib · GitHub

Repository navigation

Fix mlab fallback for 32-bit systems - #30273

Merged
QuLogic merged 1 commit into
matplotlib:mainfrom
QuLogic:mlab32
Jul 31, 2025
Merged

QuLogic merged 1 commit into
matplotlib:mainfrom
QuLogic:mlab32

Conversation

QuLogic commented Jul 8, 2025

Copy link
Copy Markdown
Member

PR summary

Unfortunately, I applied the change from
#29115 (comment) directly without noticing the typo, or running full tests.

So fix the swapped condition, and add a test (for csd only, which should be enough since everything goes though _spectral_helper.) This test should work on 64-bit systems as well, but I also double-checked on WASM.

PR checklist

QuLogic added this to the v3.11.0 milestone Jul 8, 2025
Comment thread lib/matplotlib/mlab.py Outdated
Comment thread lib/matplotlib/mlab.py Outdated

if n == 1 and noverlap == 0:
return x[np.newaxis]
f'with noverlap < n and n <= x.size ({x.size})')

anntzer Jul 9, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Given that I had read the original check wrong, this can be further simplified to something like if not 0 <= noverlap < n <= x.size: raise ValueError(f"n ({n}), noverlap ({noverlap}), and x.size ({x.size}) must satisfy 0 <= noverlap < n <= x.size")
Sorry for the very piecemeal review.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hmm, technically, noverlap doesn't need to be non-negative in the non-fallback/64-bit case. Maybe we should move this check up there earlier?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good point that noverlap can be negative here. Probably the semantically meaningful check should be to replace, in _spectral_helper, erroring when noverlap >= NFFT by erroring when not 0 <= noverlap < NFFT.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Did that then.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Wasn't your point that _stride_windows doesn't require anything regarding noverlap and only requires 0 < n <= x.size (so the test in _stride_windows still needs to be relaxed), whereas _spectral_helper requires 0 <= noverlap < NFFT (which you have correctly changed?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Well, _stride_windows is only called by _spectral_helper in the 32-bit case, and no other functions do. So I guess it doesn't matter much, and it can be dropped here.

QuLogic force-pushed the mlab32 branch 2 times, most recently from b68335d to a5c273b Compare July 12, 2025 03:51

anntzer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Still a minor point (#30273 (comment)) but it's not crucial and can be simplified later.

Unfortunately, I applied the change from
matplotlib#29115 (comment)
directly without noticing the typo, or running full tests.

So fix the swapped condition, and add a test (for `csd` only, which
should be enough since everything goes though `_spectral_helper`.)
QuLogic merged commit b19a68a into matplotlib:main Jul 31, 2025
QuLogic deleted the mlab32 branch July 31, 2025 22:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL