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