annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/site-packages/numpy/dual.py @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 """
jpayne@69 2 .. deprecated:: 1.20
jpayne@69 3
jpayne@69 4 *This module is deprecated. Instead of importing functions from*
jpayne@69 5 ``numpy.dual``, *the functions should be imported directly from NumPy
jpayne@69 6 or SciPy*.
jpayne@69 7
jpayne@69 8 Aliases for functions which may be accelerated by SciPy.
jpayne@69 9
jpayne@69 10 SciPy_ can be built to use accelerated or otherwise improved libraries
jpayne@69 11 for FFTs, linear algebra, and special functions. This module allows
jpayne@69 12 developers to transparently support these accelerated functions when
jpayne@69 13 SciPy is available but still support users who have only installed
jpayne@69 14 NumPy.
jpayne@69 15
jpayne@69 16 .. _SciPy : https://www.scipy.org
jpayne@69 17
jpayne@69 18 """
jpayne@69 19 import warnings
jpayne@69 20
jpayne@69 21
jpayne@69 22 warnings.warn('The module numpy.dual is deprecated. Instead of using dual, '
jpayne@69 23 'use the functions directly from numpy or scipy.',
jpayne@69 24 category=DeprecationWarning,
jpayne@69 25 stacklevel=2)
jpayne@69 26
jpayne@69 27 # This module should be used for functions both in numpy and scipy if
jpayne@69 28 # you want to use the numpy version if available but the scipy version
jpayne@69 29 # otherwise.
jpayne@69 30 # Usage --- from numpy.dual import fft, inv
jpayne@69 31
jpayne@69 32 __all__ = ['fft', 'ifft', 'fftn', 'ifftn', 'fft2', 'ifft2',
jpayne@69 33 'norm', 'inv', 'svd', 'solve', 'det', 'eig', 'eigvals',
jpayne@69 34 'eigh', 'eigvalsh', 'lstsq', 'pinv', 'cholesky', 'i0']
jpayne@69 35
jpayne@69 36 import numpy.linalg as linpkg
jpayne@69 37 import numpy.fft as fftpkg
jpayne@69 38 from numpy.lib import i0
jpayne@69 39 import sys
jpayne@69 40
jpayne@69 41
jpayne@69 42 fft = fftpkg.fft
jpayne@69 43 ifft = fftpkg.ifft
jpayne@69 44 fftn = fftpkg.fftn
jpayne@69 45 ifftn = fftpkg.ifftn
jpayne@69 46 fft2 = fftpkg.fft2
jpayne@69 47 ifft2 = fftpkg.ifft2
jpayne@69 48
jpayne@69 49 norm = linpkg.norm
jpayne@69 50 inv = linpkg.inv
jpayne@69 51 svd = linpkg.svd
jpayne@69 52 solve = linpkg.solve
jpayne@69 53 det = linpkg.det
jpayne@69 54 eig = linpkg.eig
jpayne@69 55 eigvals = linpkg.eigvals
jpayne@69 56 eigh = linpkg.eigh
jpayne@69 57 eigvalsh = linpkg.eigvalsh
jpayne@69 58 lstsq = linpkg.lstsq
jpayne@69 59 pinv = linpkg.pinv
jpayne@69 60 cholesky = linpkg.cholesky
jpayne@69 61
jpayne@69 62 _restore_dict = {}
jpayne@69 63
jpayne@69 64 def register_func(name, func):
jpayne@69 65 if name not in __all__:
jpayne@69 66 raise ValueError("{} not a dual function.".format(name))
jpayne@69 67 f = sys._getframe(0).f_globals
jpayne@69 68 _restore_dict[name] = f[name]
jpayne@69 69 f[name] = func
jpayne@69 70
jpayne@69 71 def restore_func(name):
jpayne@69 72 if name not in __all__:
jpayne@69 73 raise ValueError("{} not a dual function.".format(name))
jpayne@69 74 try:
jpayne@69 75 val = _restore_dict[name]
jpayne@69 76 except KeyError:
jpayne@69 77 return
jpayne@69 78 else:
jpayne@69 79 sys._getframe(0).f_globals[name] = val
jpayne@69 80
jpayne@69 81 def restore_all():
jpayne@69 82 for name in _restore_dict.keys():
jpayne@69 83 restore_func(name)