annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/site-packages/numpy/dual.py @ 68:5028fdace37b

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