Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita866298

Browse files
committed
Fix mlab fallback for 32-bit systems
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, whichshould be enough since everything goes though `_spectral_helper`.)
1 parent4c345b4 commita866298

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

‎lib/matplotlib/mlab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ def _stride_windows(x, n, noverlap=0):
215215
x=np.asarray(x)
216216

217217
_api.check_isinstance(Integral,n=n,noverlap=noverlap)
218-
ifnot (1<=n<=x.sizeandn<noverlap):
218+
ifnot (1<=n<=x.sizeandnoverlap<n):
219219
raiseValueError(f'n ({n}) and noverlap ({noverlap}) must be positive integers '
220-
f'withn <noverlap and n <= x.size ({x.size})')
220+
f'withnoverlap <n and n <= x.size ({x.size})')
221221

222222
ifn==1andnoverlap==0:
223223
returnx[np.newaxis]

‎lib/matplotlib/tests/test_mlab.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
importsys
2+
13
fromnumpy.testingimport (assert_allclose,assert_almost_equal,
24
assert_array_equal,assert_array_almost_equal_nulp)
35
importnumpyasnp
@@ -429,7 +431,16 @@ def test_spectral_helper_psd(self, mode, case):
429431
assertspec.shape[0]==freqs.shape[0]
430432
assertspec.shape[1]==getattr(self,f"t_{case}").shape[0]
431433

432-
deftest_csd(self):
434+
@pytest.mark.parametrize('bitsize', [
435+
pytest.param(None,id='default'),
436+
pytest.param(32,
437+
marks=pytest.mark.skipif(sys.maxsize<=2**32,
438+
reason='System is already 32-bit'),
439+
id='32-bit')
440+
])
441+
deftest_csd(self,bitsize,monkeypatch):
442+
ifbitsizeisnotNone:
443+
monkeypatch.setattr(sys,'maxsize',2**bitsize)
433444
freqs=self.freqs_density
434445
spec,fsp=mlab.csd(x=self.y,y=self.y+1,
435446
NFFT=self.NFFT_density,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp