8000 Fix mlab fallback for 32-bit systems by QuLogic · Pull Request #30273 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix mlab fallback for 32-bit systems #30273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/matplotlib/mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,10 @@
x = np.asarray(x)

_api.check_isinstance(Integral, n=n, noverlap=noverlap)
if not (1 <= n <= x.size and n < noverlap):
raise ValueError(f'n ({n}) and noverlap ({noverlap}) must be positive integers '
f'with n < noverlap and n <= x.size ({x.size})')

if n == 1 and noverlap == 0:
return x[np.newaxis]
if not (0 <= noverlap < n <= x.size):
raise ValueError(

Check warning on line 219 in lib/matplotlib/mlab.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/mlab.py#L219

Added line #L219 was not covered by tests
f'n ({n}), noverlap ({noverlap}), and x.size ({x.size}) must satisfy '
f'0 <= noverlap < n <= x.size')

step = n - noverlap
shape = (n, (x.shape[-1]-noverlap)//step)
Expand Down Expand Up @@ -257,7 +255,7 @@
if NFFT is None:
NFFT = 256

if noverlap >= NFFT:
if not (0 <= noverlap < NFFT):
raise ValueError('noverlap must be less than NFFT')

if mode is None or mode == 'default':
Expand Down
13 changes: 12 additions & 1 deletion lib/matplotlib/tests/test_mlab.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

from numpy.testing import (assert_allclose, assert_almost_equal,
7997 assert_array_equal, assert_array_almost_equal_nulp)
import numpy as np
Expand Down Expand Up @@ -429,7 +431,16 @@ def test_spectral_helper_psd(self, mode, case):
assert spec.shape[0] == freqs.shape[0]
assert spec.shape[1] == getattr(self, f"t_{case}").shape[0]

def test_csd(self):
@pytest.mark.parametrize('bitsize', [
pytest.param(None, id='default'),
pytest.param(32,
marks=pytest.mark.skipif(sys.maxsize <= 2**32,
reason='System is already 32-bit'),
id='32-bit')
])
def test_csd(self, bitsize, monkeypatch):
if bitsize is not None:
monkeypatch.setattr(sys, 'maxsize', 2**bitsize)
freqs = self.freqs_density
spec, fsp = mlab.csd(x=self.y, y=self.y+1,
NFFT=self.NFFT_density,
Expand Down
0