|
309 | 309 | use the classes to create a reusable function instead.
|
310 | 310 |
|
311 | 311 | """
|
312 |
| -import warnings |
313 |
| -import inspect |
314 | 312 |
|
315 | 313 | from . import _sigtools, windows
|
316 | 314 | from ._waveforms import *
|
|
345 | 343 | spectral, signaltools, waveforms, wavelets, spline
|
346 | 344 | )
|
347 | 345 |
|
348 |
| -# deal with * -> windows.* doc-only soft-deprecation |
349 |
| -deprecated_windows = ('boxcar', 'triang', 'parzen', 'bohman', 'blackman', |
350 |
| - 'nuttall', 'blackmanharris', 'flattop', 'bartlett', |
351 |
| - 'barthann', 'hamming', 'kaiser', 'gaussian', |
352 |
| - 'general_gaussian', 'chebwin', 'cosine', |
353 |
| - 'hann', 'exponential', 'tukey') |
354 |
| - |
355 |
| - |
356 |
| -def deco(name): |
357 |
| - f = getattr(windows, name) |
358 |
| - # Add deprecation to docstring |
359 |
| - |
360 |
| - def wrapped(*args, **kwargs): |
361 |
| - warnings.warn(f"Importing {name} from 'scipy.signal' is deprecated " |
362 |
| - f"since SciPy 1.1.0 and will raise an error in SciPy 1.13.0. " |
363 |
| - f"Please use 'scipy.signal.windows.{name}' or the convenience " |
364 |
| - f"function 'scipy.signal.get_window' instead.", |
365 |
| - DeprecationWarning, stacklevel=2) |
366 |
| - return f(*args, **kwargs) |
367 |
| - |
368 |
| - wrapped.__name__ = name |
369 |
| - wrapped.__module__ = 'scipy.signal' |
370 |
| - wrapped.__signature__ = inspect.signature(f) # noqa: F821 |
371 |
| - if hasattr(f, '__qualname__'): |
372 |
| - wrapped.__qualname__ = f.__qualname__ |
373 |
| - |
374 |
| - if f.__doc__: |
375 |
| - lines = f.__doc__.splitlines() |
376 |
| - for li, line in enumerate(lines): |
377 |
| - if line.strip() == 'Parameters': |
378 |
| - break |
379 |
| - else: |
380 |
| - raise RuntimeError('dev error: badly formatted doc') |
381 |
| - spacing = ' ' * line.find('P') |
382 |
| - lines.insert(li, ('{0}.. warning:: `scipy.signal.{1}` is deprecated since\n' |
383 |
| - '{0} SciPy 1.1.0 and will be removed in 1.13.0\n' |
384 |
| - '{0} use `scipy.signal.windows.{1}`' |
385 |
| - 'instead.\n'.format(spacing, name))) |
386 |
| - wrapped.__doc__ = '\n'.join(lines) |
387 |
| - |
388 |
| - return wrapped |
389 |
| - |
390 |
| - |
391 |
| -for name in deprecated_windows: |
392 |
| - locals()[name] = deco(name) |
393 |
| - |
394 |
| -del deprecated_windows, name, deco |
395 |
| - |
396 | 346 | __all__ = [
|
397 |
| - s for s in dir() if not s.startswith("_") and s not in {"warnings", "inspect"} |
| 347 | + s for s in dir() if not s.startswith("_") |
398 | 348 | ]
|
399 | 349 |
|
400 | 350 | from scipy._lib._testutils import PytestTester
|
401 | 351 | test = PytestTester(__name__)
|
402 |
| -del PytestTester, inspect |
| 352 | +del PytestTester |
0 commit comments