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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 2 additions & 10 deletions lib/matplotlib/mlab.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,8 @@ def detrend_linear(y):


def _stride_windows(x, n, noverlap=0):
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]

x = np.asarray(x)
step = n - noverlap
shape = (n, (x.shape[-1]-noverlap)//step)
strides = (x.strides[0], step*x.strides[0])
Expand Down Expand Up @@ -257,7 +249,7 @@ def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None,
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
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
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,
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

Back | FazBrowse Home | New Git URL