Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- ckpts/universal/global_step40/zero/23.mlp.dense_h_to_4h_swiglu.weight/fp32.pt +3 -0
- ckpts/universal/global_step40/zero/26.attention.dense.weight/exp_avg.pt +3 -0
- ckpts/universal/global_step40/zero/26.attention.query_key_value.weight/exp_avg_sq.pt +3 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/__init__.py +103 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/_basic.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/_helper.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/_pseudo_diffs.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/_realtransforms.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/basic.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/helper.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/pseudo_diffs.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/realtransforms.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/_basic.py +428 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/_helper.py +115 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/_pseudo_diffs.py +551 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/_realtransforms.py +598 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/basic.py +20 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/convolve.cpython-310-x86_64-linux-gnu.so +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/helper.py +19 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/pseudo_diffs.py +22 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/realtransforms.py +19 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/tests/__init__.py +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/tests/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/tests/__pycache__/test_helper.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/tests/__pycache__/test_pseudo_diffs.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/tests/test_basic.py +873 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/tests/test_helper.py +54 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/tests/test_import.py +31 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/tests/test_pseudo_diffs.py +380 -0
- venv/lib/python3.10/site-packages/scipy/fftpack/tests/test_real_transforms.py +815 -0
- venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/_geometric_slerp.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/_kdtree.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/_plotutils.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/_procrustes.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/_spherical_voronoi.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/ckdtree.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/distance.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/kdtree.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/qhull.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/tests/data/cdist-X1.txt +10 -0
- venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-boolean-inp.txt +20 -0
- venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-chebyshev-ml-iris.txt +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-chebyshev-ml.txt +1 -0
- venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cityblock-ml-iris.txt +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cityblock-ml.txt +1 -0
- venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-correlation-ml-iris.txt +0 -0
- venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-correlation-ml.txt +1 -0
- venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cosine-ml-iris.txt +0 -0
ckpts/universal/global_step40/zero/23.mlp.dense_h_to_4h_swiglu.weight/fp32.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9c902155bf2ee95287a64d4ebcc42bdf22a314c5d6a8cfdc249bc4fda856f3d1
|
3 |
+
size 33555533
|
ckpts/universal/global_step40/zero/26.attention.dense.weight/exp_avg.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c5901348575838e3a91b87ca754ccd44b2c6fe66e3ce9ad73072b08eeb1f1645
|
3 |
+
size 16778396
|
ckpts/universal/global_step40/zero/26.attention.query_key_value.weight/exp_avg_sq.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:36e83711ec19cb35270045e2c2f920ea25df89b8b41ebfdf41e5e876abea4a25
|
3 |
+
size 50332843
|
venv/lib/python3.10/site-packages/scipy/fftpack/__init__.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
=========================================================
|
3 |
+
Legacy discrete Fourier transforms (:mod:`scipy.fftpack`)
|
4 |
+
=========================================================
|
5 |
+
|
6 |
+
.. legacy::
|
7 |
+
|
8 |
+
New code should use :mod:`scipy.fft`.
|
9 |
+
|
10 |
+
Fast Fourier Transforms (FFTs)
|
11 |
+
==============================
|
12 |
+
|
13 |
+
.. autosummary::
|
14 |
+
:toctree: generated/
|
15 |
+
|
16 |
+
fft - Fast (discrete) Fourier Transform (FFT)
|
17 |
+
ifft - Inverse FFT
|
18 |
+
fft2 - 2-D FFT
|
19 |
+
ifft2 - 2-D inverse FFT
|
20 |
+
fftn - N-D FFT
|
21 |
+
ifftn - N-D inverse FFT
|
22 |
+
rfft - FFT of strictly real-valued sequence
|
23 |
+
irfft - Inverse of rfft
|
24 |
+
dct - Discrete cosine transform
|
25 |
+
idct - Inverse discrete cosine transform
|
26 |
+
dctn - N-D Discrete cosine transform
|
27 |
+
idctn - N-D Inverse discrete cosine transform
|
28 |
+
dst - Discrete sine transform
|
29 |
+
idst - Inverse discrete sine transform
|
30 |
+
dstn - N-D Discrete sine transform
|
31 |
+
idstn - N-D Inverse discrete sine transform
|
32 |
+
|
33 |
+
Differential and pseudo-differential operators
|
34 |
+
==============================================
|
35 |
+
|
36 |
+
.. autosummary::
|
37 |
+
:toctree: generated/
|
38 |
+
|
39 |
+
diff - Differentiation and integration of periodic sequences
|
40 |
+
tilbert - Tilbert transform: cs_diff(x,h,h)
|
41 |
+
itilbert - Inverse Tilbert transform: sc_diff(x,h,h)
|
42 |
+
hilbert - Hilbert transform: cs_diff(x,inf,inf)
|
43 |
+
ihilbert - Inverse Hilbert transform: sc_diff(x,inf,inf)
|
44 |
+
cs_diff - cosh/sinh pseudo-derivative of periodic sequences
|
45 |
+
sc_diff - sinh/cosh pseudo-derivative of periodic sequences
|
46 |
+
ss_diff - sinh/sinh pseudo-derivative of periodic sequences
|
47 |
+
cc_diff - cosh/cosh pseudo-derivative of periodic sequences
|
48 |
+
shift - Shift periodic sequences
|
49 |
+
|
50 |
+
Helper functions
|
51 |
+
================
|
52 |
+
|
53 |
+
.. autosummary::
|
54 |
+
:toctree: generated/
|
55 |
+
|
56 |
+
fftshift - Shift the zero-frequency component to the center of the spectrum
|
57 |
+
ifftshift - The inverse of `fftshift`
|
58 |
+
fftfreq - Return the Discrete Fourier Transform sample frequencies
|
59 |
+
rfftfreq - DFT sample frequencies (for usage with rfft, irfft)
|
60 |
+
next_fast_len - Find the optimal length to zero-pad an FFT for speed
|
61 |
+
|
62 |
+
Note that ``fftshift``, ``ifftshift`` and ``fftfreq`` are numpy functions
|
63 |
+
exposed by ``fftpack``; importing them from ``numpy`` should be preferred.
|
64 |
+
|
65 |
+
Convolutions (:mod:`scipy.fftpack.convolve`)
|
66 |
+
============================================
|
67 |
+
|
68 |
+
.. module:: scipy.fftpack.convolve
|
69 |
+
|
70 |
+
.. autosummary::
|
71 |
+
:toctree: generated/
|
72 |
+
|
73 |
+
convolve
|
74 |
+
convolve_z
|
75 |
+
init_convolution_kernel
|
76 |
+
destroy_convolve_cache
|
77 |
+
|
78 |
+
"""
|
79 |
+
|
80 |
+
|
81 |
+
__all__ = ['fft','ifft','fftn','ifftn','rfft','irfft',
|
82 |
+
'fft2','ifft2',
|
83 |
+
'diff',
|
84 |
+
'tilbert','itilbert','hilbert','ihilbert',
|
85 |
+
'sc_diff','cs_diff','cc_diff','ss_diff',
|
86 |
+
'shift',
|
87 |
+
'fftfreq', 'rfftfreq',
|
88 |
+
'fftshift', 'ifftshift',
|
89 |
+
'next_fast_len',
|
90 |
+
'dct', 'idct', 'dst', 'idst', 'dctn', 'idctn', 'dstn', 'idstn'
|
91 |
+
]
|
92 |
+
|
93 |
+
from ._basic import *
|
94 |
+
from ._pseudo_diffs import *
|
95 |
+
from ._helper import *
|
96 |
+
from ._realtransforms import *
|
97 |
+
|
98 |
+
# Deprecated namespaces, to be removed in v2.0.0
|
99 |
+
from . import basic, helper, pseudo_diffs, realtransforms
|
100 |
+
|
101 |
+
from scipy._lib._testutils import PytestTester
|
102 |
+
test = PytestTester(__name__)
|
103 |
+
del PytestTester
|
venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (3.17 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/_basic.cpython-310.pyc
ADDED
Binary file (13.2 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/_helper.cpython-310.pyc
ADDED
Binary file (3.59 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/_pseudo_diffs.cpython-310.pyc
ADDED
Binary file (12.3 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/_realtransforms.cpython-310.pyc
ADDED
Binary file (19.1 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/basic.cpython-310.pyc
ADDED
Binary file (641 Bytes). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/helper.cpython-310.pyc
ADDED
Binary file (649 Bytes). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/pseudo_diffs.cpython-310.pyc
ADDED
Binary file (723 Bytes). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/__pycache__/realtransforms.cpython-310.pyc
ADDED
Binary file (666 Bytes). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/_basic.py
ADDED
@@ -0,0 +1,428 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Discrete Fourier Transforms - _basic.py
|
3 |
+
"""
|
4 |
+
# Created by Pearu Peterson, August,September 2002
|
5 |
+
__all__ = ['fft','ifft','fftn','ifftn','rfft','irfft',
|
6 |
+
'fft2','ifft2']
|
7 |
+
|
8 |
+
from scipy.fft import _pocketfft
|
9 |
+
from ._helper import _good_shape
|
10 |
+
|
11 |
+
|
12 |
+
def fft(x, n=None, axis=-1, overwrite_x=False):
|
13 |
+
"""
|
14 |
+
Return discrete Fourier transform of real or complex sequence.
|
15 |
+
|
16 |
+
The returned complex array contains ``y(0), y(1),..., y(n-1)``, where
|
17 |
+
|
18 |
+
``y(j) = (x * exp(-2*pi*sqrt(-1)*j*np.arange(n)/n)).sum()``.
|
19 |
+
|
20 |
+
Parameters
|
21 |
+
----------
|
22 |
+
x : array_like
|
23 |
+
Array to Fourier transform.
|
24 |
+
n : int, optional
|
25 |
+
Length of the Fourier transform. If ``n < x.shape[axis]``, `x` is
|
26 |
+
truncated. If ``n > x.shape[axis]``, `x` is zero-padded. The
|
27 |
+
default results in ``n = x.shape[axis]``.
|
28 |
+
axis : int, optional
|
29 |
+
Axis along which the fft's are computed; the default is over the
|
30 |
+
last axis (i.e., ``axis=-1``).
|
31 |
+
overwrite_x : bool, optional
|
32 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
33 |
+
|
34 |
+
Returns
|
35 |
+
-------
|
36 |
+
z : complex ndarray
|
37 |
+
with the elements::
|
38 |
+
|
39 |
+
[y(0),y(1),..,y(n/2),y(1-n/2),...,y(-1)] if n is even
|
40 |
+
[y(0),y(1),..,y((n-1)/2),y(-(n-1)/2),...,y(-1)] if n is odd
|
41 |
+
|
42 |
+
where::
|
43 |
+
|
44 |
+
y(j) = sum[k=0..n-1] x[k] * exp(-sqrt(-1)*j*k* 2*pi/n), j = 0..n-1
|
45 |
+
|
46 |
+
See Also
|
47 |
+
--------
|
48 |
+
ifft : Inverse FFT
|
49 |
+
rfft : FFT of a real sequence
|
50 |
+
|
51 |
+
Notes
|
52 |
+
-----
|
53 |
+
The packing of the result is "standard": If ``A = fft(a, n)``, then
|
54 |
+
``A[0]`` contains the zero-frequency term, ``A[1:n/2]`` contains the
|
55 |
+
positive-frequency terms, and ``A[n/2:]`` contains the negative-frequency
|
56 |
+
terms, in order of decreasingly negative frequency. So ,for an 8-point
|
57 |
+
transform, the frequencies of the result are [0, 1, 2, 3, -4, -3, -2, -1].
|
58 |
+
To rearrange the fft output so that the zero-frequency component is
|
59 |
+
centered, like [-4, -3, -2, -1, 0, 1, 2, 3], use `fftshift`.
|
60 |
+
|
61 |
+
Both single and double precision routines are implemented. Half precision
|
62 |
+
inputs will be converted to single precision. Non-floating-point inputs
|
63 |
+
will be converted to double precision. Long-double precision inputs are
|
64 |
+
not supported.
|
65 |
+
|
66 |
+
This function is most efficient when `n` is a power of two, and least
|
67 |
+
efficient when `n` is prime.
|
68 |
+
|
69 |
+
Note that if ``x`` is real-valued, then ``A[j] == A[n-j].conjugate()``.
|
70 |
+
If ``x`` is real-valued and ``n`` is even, then ``A[n/2]`` is real.
|
71 |
+
|
72 |
+
If the data type of `x` is real, a "real FFT" algorithm is automatically
|
73 |
+
used, which roughly halves the computation time. To increase efficiency
|
74 |
+
a little further, use `rfft`, which does the same calculation, but only
|
75 |
+
outputs half of the symmetrical spectrum. If the data is both real and
|
76 |
+
symmetrical, the `dct` can again double the efficiency by generating
|
77 |
+
half of the spectrum from half of the signal.
|
78 |
+
|
79 |
+
Examples
|
80 |
+
--------
|
81 |
+
>>> import numpy as np
|
82 |
+
>>> from scipy.fftpack import fft, ifft
|
83 |
+
>>> x = np.arange(5)
|
84 |
+
>>> np.allclose(fft(ifft(x)), x, atol=1e-15) # within numerical accuracy.
|
85 |
+
True
|
86 |
+
|
87 |
+
"""
|
88 |
+
return _pocketfft.fft(x, n, axis, None, overwrite_x)
|
89 |
+
|
90 |
+
|
91 |
+
def ifft(x, n=None, axis=-1, overwrite_x=False):
|
92 |
+
"""
|
93 |
+
Return discrete inverse Fourier transform of real or complex sequence.
|
94 |
+
|
95 |
+
The returned complex array contains ``y(0), y(1),..., y(n-1)``, where
|
96 |
+
|
97 |
+
``y(j) = (x * exp(2*pi*sqrt(-1)*j*np.arange(n)/n)).mean()``.
|
98 |
+
|
99 |
+
Parameters
|
100 |
+
----------
|
101 |
+
x : array_like
|
102 |
+
Transformed data to invert.
|
103 |
+
n : int, optional
|
104 |
+
Length of the inverse Fourier transform. If ``n < x.shape[axis]``,
|
105 |
+
`x` is truncated. If ``n > x.shape[axis]``, `x` is zero-padded.
|
106 |
+
The default results in ``n = x.shape[axis]``.
|
107 |
+
axis : int, optional
|
108 |
+
Axis along which the ifft's are computed; the default is over the
|
109 |
+
last axis (i.e., ``axis=-1``).
|
110 |
+
overwrite_x : bool, optional
|
111 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
112 |
+
|
113 |
+
Returns
|
114 |
+
-------
|
115 |
+
ifft : ndarray of floats
|
116 |
+
The inverse discrete Fourier transform.
|
117 |
+
|
118 |
+
See Also
|
119 |
+
--------
|
120 |
+
fft : Forward FFT
|
121 |
+
|
122 |
+
Notes
|
123 |
+
-----
|
124 |
+
Both single and double precision routines are implemented. Half precision
|
125 |
+
inputs will be converted to single precision. Non-floating-point inputs
|
126 |
+
will be converted to double precision. Long-double precision inputs are
|
127 |
+
not supported.
|
128 |
+
|
129 |
+
This function is most efficient when `n` is a power of two, and least
|
130 |
+
efficient when `n` is prime.
|
131 |
+
|
132 |
+
If the data type of `x` is real, a "real IFFT" algorithm is automatically
|
133 |
+
used, which roughly halves the computation time.
|
134 |
+
|
135 |
+
Examples
|
136 |
+
--------
|
137 |
+
>>> from scipy.fftpack import fft, ifft
|
138 |
+
>>> import numpy as np
|
139 |
+
>>> x = np.arange(5)
|
140 |
+
>>> np.allclose(ifft(fft(x)), x, atol=1e-15) # within numerical accuracy.
|
141 |
+
True
|
142 |
+
|
143 |
+
"""
|
144 |
+
return _pocketfft.ifft(x, n, axis, None, overwrite_x)
|
145 |
+
|
146 |
+
|
147 |
+
def rfft(x, n=None, axis=-1, overwrite_x=False):
|
148 |
+
"""
|
149 |
+
Discrete Fourier transform of a real sequence.
|
150 |
+
|
151 |
+
Parameters
|
152 |
+
----------
|
153 |
+
x : array_like, real-valued
|
154 |
+
The data to transform.
|
155 |
+
n : int, optional
|
156 |
+
Defines the length of the Fourier transform. If `n` is not specified
|
157 |
+
(the default) then ``n = x.shape[axis]``. If ``n < x.shape[axis]``,
|
158 |
+
`x` is truncated, if ``n > x.shape[axis]``, `x` is zero-padded.
|
159 |
+
axis : int, optional
|
160 |
+
The axis along which the transform is applied. The default is the
|
161 |
+
last axis.
|
162 |
+
overwrite_x : bool, optional
|
163 |
+
If set to true, the contents of `x` can be overwritten. Default is
|
164 |
+
False.
|
165 |
+
|
166 |
+
Returns
|
167 |
+
-------
|
168 |
+
z : real ndarray
|
169 |
+
The returned real array contains::
|
170 |
+
|
171 |
+
[y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2))] if n is even
|
172 |
+
[y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2)),Im(y(n/2))] if n is odd
|
173 |
+
|
174 |
+
where::
|
175 |
+
|
176 |
+
y(j) = sum[k=0..n-1] x[k] * exp(-sqrt(-1)*j*k*2*pi/n)
|
177 |
+
j = 0..n-1
|
178 |
+
|
179 |
+
See Also
|
180 |
+
--------
|
181 |
+
fft, irfft, scipy.fft.rfft
|
182 |
+
|
183 |
+
Notes
|
184 |
+
-----
|
185 |
+
Within numerical accuracy, ``y == rfft(irfft(y))``.
|
186 |
+
|
187 |
+
Both single and double precision routines are implemented. Half precision
|
188 |
+
inputs will be converted to single precision. Non-floating-point inputs
|
189 |
+
will be converted to double precision. Long-double precision inputs are
|
190 |
+
not supported.
|
191 |
+
|
192 |
+
To get an output with a complex datatype, consider using the newer
|
193 |
+
function `scipy.fft.rfft`.
|
194 |
+
|
195 |
+
Examples
|
196 |
+
--------
|
197 |
+
>>> from scipy.fftpack import fft, rfft
|
198 |
+
>>> a = [9, -9, 1, 3]
|
199 |
+
>>> fft(a)
|
200 |
+
array([ 4. +0.j, 8.+12.j, 16. +0.j, 8.-12.j])
|
201 |
+
>>> rfft(a)
|
202 |
+
array([ 4., 8., 12., 16.])
|
203 |
+
|
204 |
+
"""
|
205 |
+
return _pocketfft.rfft_fftpack(x, n, axis, None, overwrite_x)
|
206 |
+
|
207 |
+
|
208 |
+
def irfft(x, n=None, axis=-1, overwrite_x=False):
|
209 |
+
"""
|
210 |
+
Return inverse discrete Fourier transform of real sequence x.
|
211 |
+
|
212 |
+
The contents of `x` are interpreted as the output of the `rfft`
|
213 |
+
function.
|
214 |
+
|
215 |
+
Parameters
|
216 |
+
----------
|
217 |
+
x : array_like
|
218 |
+
Transformed data to invert.
|
219 |
+
n : int, optional
|
220 |
+
Length of the inverse Fourier transform.
|
221 |
+
If n < x.shape[axis], x is truncated.
|
222 |
+
If n > x.shape[axis], x is zero-padded.
|
223 |
+
The default results in n = x.shape[axis].
|
224 |
+
axis : int, optional
|
225 |
+
Axis along which the ifft's are computed; the default is over
|
226 |
+
the last axis (i.e., axis=-1).
|
227 |
+
overwrite_x : bool, optional
|
228 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
229 |
+
|
230 |
+
Returns
|
231 |
+
-------
|
232 |
+
irfft : ndarray of floats
|
233 |
+
The inverse discrete Fourier transform.
|
234 |
+
|
235 |
+
See Also
|
236 |
+
--------
|
237 |
+
rfft, ifft, scipy.fft.irfft
|
238 |
+
|
239 |
+
Notes
|
240 |
+
-----
|
241 |
+
The returned real array contains::
|
242 |
+
|
243 |
+
[y(0),y(1),...,y(n-1)]
|
244 |
+
|
245 |
+
where for n is even::
|
246 |
+
|
247 |
+
y(j) = 1/n (sum[k=1..n/2-1] (x[2*k-1]+sqrt(-1)*x[2*k])
|
248 |
+
* exp(sqrt(-1)*j*k* 2*pi/n)
|
249 |
+
+ c.c. + x[0] + (-1)**(j) x[n-1])
|
250 |
+
|
251 |
+
and for n is odd::
|
252 |
+
|
253 |
+
y(j) = 1/n (sum[k=1..(n-1)/2] (x[2*k-1]+sqrt(-1)*x[2*k])
|
254 |
+
* exp(sqrt(-1)*j*k* 2*pi/n)
|
255 |
+
+ c.c. + x[0])
|
256 |
+
|
257 |
+
c.c. denotes complex conjugate of preceding expression.
|
258 |
+
|
259 |
+
For details on input parameters, see `rfft`.
|
260 |
+
|
261 |
+
To process (conjugate-symmetric) frequency-domain data with a complex
|
262 |
+
datatype, consider using the newer function `scipy.fft.irfft`.
|
263 |
+
|
264 |
+
Examples
|
265 |
+
--------
|
266 |
+
>>> from scipy.fftpack import rfft, irfft
|
267 |
+
>>> a = [1.0, 2.0, 3.0, 4.0, 5.0]
|
268 |
+
>>> irfft(a)
|
269 |
+
array([ 2.6 , -3.16405192, 1.24398433, -1.14955713, 1.46962473])
|
270 |
+
>>> irfft(rfft(a))
|
271 |
+
array([1., 2., 3., 4., 5.])
|
272 |
+
|
273 |
+
"""
|
274 |
+
return _pocketfft.irfft_fftpack(x, n, axis, None, overwrite_x)
|
275 |
+
|
276 |
+
|
277 |
+
def fftn(x, shape=None, axes=None, overwrite_x=False):
|
278 |
+
"""
|
279 |
+
Return multidimensional discrete Fourier transform.
|
280 |
+
|
281 |
+
The returned array contains::
|
282 |
+
|
283 |
+
y[j_1,..,j_d] = sum[k_1=0..n_1-1, ..., k_d=0..n_d-1]
|
284 |
+
x[k_1,..,k_d] * prod[i=1..d] exp(-sqrt(-1)*2*pi/n_i * j_i * k_i)
|
285 |
+
|
286 |
+
where d = len(x.shape) and n = x.shape.
|
287 |
+
|
288 |
+
Parameters
|
289 |
+
----------
|
290 |
+
x : array_like
|
291 |
+
The (N-D) array to transform.
|
292 |
+
shape : int or array_like of ints or None, optional
|
293 |
+
The shape of the result. If both `shape` and `axes` (see below) are
|
294 |
+
None, `shape` is ``x.shape``; if `shape` is None but `axes` is
|
295 |
+
not None, then `shape` is ``numpy.take(x.shape, axes, axis=0)``.
|
296 |
+
If ``shape[i] > x.shape[i]``, the ith dimension is padded with zeros.
|
297 |
+
If ``shape[i] < x.shape[i]``, the ith dimension is truncated to
|
298 |
+
length ``shape[i]``.
|
299 |
+
If any element of `shape` is -1, the size of the corresponding
|
300 |
+
dimension of `x` is used.
|
301 |
+
axes : int or array_like of ints or None, optional
|
302 |
+
The axes of `x` (`y` if `shape` is not None) along which the
|
303 |
+
transform is applied.
|
304 |
+
The default is over all axes.
|
305 |
+
overwrite_x : bool, optional
|
306 |
+
If True, the contents of `x` can be destroyed. Default is False.
|
307 |
+
|
308 |
+
Returns
|
309 |
+
-------
|
310 |
+
y : complex-valued N-D NumPy array
|
311 |
+
The (N-D) DFT of the input array.
|
312 |
+
|
313 |
+
See Also
|
314 |
+
--------
|
315 |
+
ifftn
|
316 |
+
|
317 |
+
Notes
|
318 |
+
-----
|
319 |
+
If ``x`` is real-valued, then
|
320 |
+
``y[..., j_i, ...] == y[..., n_i-j_i, ...].conjugate()``.
|
321 |
+
|
322 |
+
Both single and double precision routines are implemented. Half precision
|
323 |
+
inputs will be converted to single precision. Non-floating-point inputs
|
324 |
+
will be converted to double precision. Long-double precision inputs are
|
325 |
+
not supported.
|
326 |
+
|
327 |
+
Examples
|
328 |
+
--------
|
329 |
+
>>> import numpy as np
|
330 |
+
>>> from scipy.fftpack import fftn, ifftn
|
331 |
+
>>> y = (-np.arange(16), 8 - np.arange(16), np.arange(16))
|
332 |
+
>>> np.allclose(y, fftn(ifftn(y)))
|
333 |
+
True
|
334 |
+
|
335 |
+
"""
|
336 |
+
shape = _good_shape(x, shape, axes)
|
337 |
+
return _pocketfft.fftn(x, shape, axes, None, overwrite_x)
|
338 |
+
|
339 |
+
|
340 |
+
def ifftn(x, shape=None, axes=None, overwrite_x=False):
|
341 |
+
"""
|
342 |
+
Return inverse multidimensional discrete Fourier transform.
|
343 |
+
|
344 |
+
The sequence can be of an arbitrary type.
|
345 |
+
|
346 |
+
The returned array contains::
|
347 |
+
|
348 |
+
y[j_1,..,j_d] = 1/p * sum[k_1=0..n_1-1, ..., k_d=0..n_d-1]
|
349 |
+
x[k_1,..,k_d] * prod[i=1..d] exp(sqrt(-1)*2*pi/n_i * j_i * k_i)
|
350 |
+
|
351 |
+
where ``d = len(x.shape)``, ``n = x.shape``, and ``p = prod[i=1..d] n_i``.
|
352 |
+
|
353 |
+
For description of parameters see `fftn`.
|
354 |
+
|
355 |
+
See Also
|
356 |
+
--------
|
357 |
+
fftn : for detailed information.
|
358 |
+
|
359 |
+
Examples
|
360 |
+
--------
|
361 |
+
>>> from scipy.fftpack import fftn, ifftn
|
362 |
+
>>> import numpy as np
|
363 |
+
>>> y = (-np.arange(16), 8 - np.arange(16), np.arange(16))
|
364 |
+
>>> np.allclose(y, ifftn(fftn(y)))
|
365 |
+
True
|
366 |
+
|
367 |
+
"""
|
368 |
+
shape = _good_shape(x, shape, axes)
|
369 |
+
return _pocketfft.ifftn(x, shape, axes, None, overwrite_x)
|
370 |
+
|
371 |
+
|
372 |
+
def fft2(x, shape=None, axes=(-2,-1), overwrite_x=False):
|
373 |
+
"""
|
374 |
+
2-D discrete Fourier transform.
|
375 |
+
|
376 |
+
Return the 2-D discrete Fourier transform of the 2-D argument
|
377 |
+
`x`.
|
378 |
+
|
379 |
+
See Also
|
380 |
+
--------
|
381 |
+
fftn : for detailed information.
|
382 |
+
|
383 |
+
Examples
|
384 |
+
--------
|
385 |
+
>>> import numpy as np
|
386 |
+
>>> from scipy.fftpack import fft2, ifft2
|
387 |
+
>>> y = np.mgrid[:5, :5][0]
|
388 |
+
>>> y
|
389 |
+
array([[0, 0, 0, 0, 0],
|
390 |
+
[1, 1, 1, 1, 1],
|
391 |
+
[2, 2, 2, 2, 2],
|
392 |
+
[3, 3, 3, 3, 3],
|
393 |
+
[4, 4, 4, 4, 4]])
|
394 |
+
>>> np.allclose(y, ifft2(fft2(y)))
|
395 |
+
True
|
396 |
+
"""
|
397 |
+
return fftn(x,shape,axes,overwrite_x)
|
398 |
+
|
399 |
+
|
400 |
+
def ifft2(x, shape=None, axes=(-2,-1), overwrite_x=False):
|
401 |
+
"""
|
402 |
+
2-D discrete inverse Fourier transform of real or complex sequence.
|
403 |
+
|
404 |
+
Return inverse 2-D discrete Fourier transform of
|
405 |
+
arbitrary type sequence x.
|
406 |
+
|
407 |
+
See `ifft` for more information.
|
408 |
+
|
409 |
+
See Also
|
410 |
+
--------
|
411 |
+
fft2, ifft
|
412 |
+
|
413 |
+
Examples
|
414 |
+
--------
|
415 |
+
>>> import numpy as np
|
416 |
+
>>> from scipy.fftpack import fft2, ifft2
|
417 |
+
>>> y = np.mgrid[:5, :5][0]
|
418 |
+
>>> y
|
419 |
+
array([[0, 0, 0, 0, 0],
|
420 |
+
[1, 1, 1, 1, 1],
|
421 |
+
[2, 2, 2, 2, 2],
|
422 |
+
[3, 3, 3, 3, 3],
|
423 |
+
[4, 4, 4, 4, 4]])
|
424 |
+
>>> np.allclose(y, fft2(ifft2(y)))
|
425 |
+
True
|
426 |
+
|
427 |
+
"""
|
428 |
+
return ifftn(x,shape,axes,overwrite_x)
|
venv/lib/python3.10/site-packages/scipy/fftpack/_helper.py
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import operator
|
2 |
+
|
3 |
+
import numpy as np
|
4 |
+
from numpy.fft import fftshift, ifftshift, fftfreq
|
5 |
+
|
6 |
+
import scipy.fft._pocketfft.helper as _helper
|
7 |
+
|
8 |
+
__all__ = ['fftshift', 'ifftshift', 'fftfreq', 'rfftfreq', 'next_fast_len']
|
9 |
+
|
10 |
+
|
11 |
+
def rfftfreq(n, d=1.0):
|
12 |
+
"""DFT sample frequencies (for usage with rfft, irfft).
|
13 |
+
|
14 |
+
The returned float array contains the frequency bins in
|
15 |
+
cycles/unit (with zero at the start) given a window length `n` and a
|
16 |
+
sample spacing `d`::
|
17 |
+
|
18 |
+
f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2]/(d*n) if n is even
|
19 |
+
f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2,n/2]/(d*n) if n is odd
|
20 |
+
|
21 |
+
Parameters
|
22 |
+
----------
|
23 |
+
n : int
|
24 |
+
Window length.
|
25 |
+
d : scalar, optional
|
26 |
+
Sample spacing. Default is 1.
|
27 |
+
|
28 |
+
Returns
|
29 |
+
-------
|
30 |
+
out : ndarray
|
31 |
+
The array of length `n`, containing the sample frequencies.
|
32 |
+
|
33 |
+
Examples
|
34 |
+
--------
|
35 |
+
>>> import numpy as np
|
36 |
+
>>> from scipy import fftpack
|
37 |
+
>>> sig = np.array([-2, 8, 6, 4, 1, 0, 3, 5], dtype=float)
|
38 |
+
>>> sig_fft = fftpack.rfft(sig)
|
39 |
+
>>> n = sig_fft.size
|
40 |
+
>>> timestep = 0.1
|
41 |
+
>>> freq = fftpack.rfftfreq(n, d=timestep)
|
42 |
+
>>> freq
|
43 |
+
array([ 0. , 1.25, 1.25, 2.5 , 2.5 , 3.75, 3.75, 5. ])
|
44 |
+
|
45 |
+
"""
|
46 |
+
n = operator.index(n)
|
47 |
+
if n < 0:
|
48 |
+
raise ValueError("n = %s is not valid. "
|
49 |
+
"n must be a nonnegative integer." % n)
|
50 |
+
|
51 |
+
return (np.arange(1, n + 1, dtype=int) // 2) / float(n * d)
|
52 |
+
|
53 |
+
|
54 |
+
def next_fast_len(target):
|
55 |
+
"""
|
56 |
+
Find the next fast size of input data to `fft`, for zero-padding, etc.
|
57 |
+
|
58 |
+
SciPy's FFTPACK has efficient functions for radix {2, 3, 4, 5}, so this
|
59 |
+
returns the next composite of the prime factors 2, 3, and 5 which is
|
60 |
+
greater than or equal to `target`. (These are also known as 5-smooth
|
61 |
+
numbers, regular numbers, or Hamming numbers.)
|
62 |
+
|
63 |
+
Parameters
|
64 |
+
----------
|
65 |
+
target : int
|
66 |
+
Length to start searching from. Must be a positive integer.
|
67 |
+
|
68 |
+
Returns
|
69 |
+
-------
|
70 |
+
out : int
|
71 |
+
The first 5-smooth number greater than or equal to `target`.
|
72 |
+
|
73 |
+
Notes
|
74 |
+
-----
|
75 |
+
.. versionadded:: 0.18.0
|
76 |
+
|
77 |
+
Examples
|
78 |
+
--------
|
79 |
+
On a particular machine, an FFT of prime length takes 133 ms:
|
80 |
+
|
81 |
+
>>> from scipy import fftpack
|
82 |
+
>>> import numpy as np
|
83 |
+
>>> rng = np.random.default_rng()
|
84 |
+
>>> min_len = 10007 # prime length is worst case for speed
|
85 |
+
>>> a = rng.standard_normal(min_len)
|
86 |
+
>>> b = fftpack.fft(a)
|
87 |
+
|
88 |
+
Zero-padding to the next 5-smooth length reduces computation time to
|
89 |
+
211 us, a speedup of 630 times:
|
90 |
+
|
91 |
+
>>> fftpack.next_fast_len(min_len)
|
92 |
+
10125
|
93 |
+
>>> b = fftpack.fft(a, 10125)
|
94 |
+
|
95 |
+
Rounding up to the next power of 2 is not optimal, taking 367 us to
|
96 |
+
compute, 1.7 times as long as the 5-smooth size:
|
97 |
+
|
98 |
+
>>> b = fftpack.fft(a, 16384)
|
99 |
+
|
100 |
+
"""
|
101 |
+
# Real transforms use regular sizes so this is backwards compatible
|
102 |
+
return _helper.good_size(target, True)
|
103 |
+
|
104 |
+
|
105 |
+
def _good_shape(x, shape, axes):
|
106 |
+
"""Ensure that shape argument is valid for scipy.fftpack
|
107 |
+
|
108 |
+
scipy.fftpack does not support len(shape) < x.ndim when axes is not given.
|
109 |
+
"""
|
110 |
+
if shape is not None and axes is None:
|
111 |
+
shape = _helper._iterable_of_int(shape, 'shape')
|
112 |
+
if len(shape) != np.ndim(x):
|
113 |
+
raise ValueError("when given, axes and shape arguments"
|
114 |
+
" have to be of the same length")
|
115 |
+
return shape
|
venv/lib/python3.10/site-packages/scipy/fftpack/_pseudo_diffs.py
ADDED
@@ -0,0 +1,551 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Differential and pseudo-differential operators.
|
3 |
+
"""
|
4 |
+
# Created by Pearu Peterson, September 2002
|
5 |
+
|
6 |
+
__all__ = ['diff',
|
7 |
+
'tilbert','itilbert','hilbert','ihilbert',
|
8 |
+
'cs_diff','cc_diff','sc_diff','ss_diff',
|
9 |
+
'shift']
|
10 |
+
|
11 |
+
from numpy import pi, asarray, sin, cos, sinh, cosh, tanh, iscomplexobj
|
12 |
+
from . import convolve
|
13 |
+
|
14 |
+
from scipy.fft._pocketfft.helper import _datacopied
|
15 |
+
|
16 |
+
|
17 |
+
_cache = {}
|
18 |
+
|
19 |
+
|
20 |
+
def diff(x,order=1,period=None, _cache=_cache):
|
21 |
+
"""
|
22 |
+
Return kth derivative (or integral) of a periodic sequence x.
|
23 |
+
|
24 |
+
If x_j and y_j are Fourier coefficients of periodic functions x
|
25 |
+
and y, respectively, then::
|
26 |
+
|
27 |
+
y_j = pow(sqrt(-1)*j*2*pi/period, order) * x_j
|
28 |
+
y_0 = 0 if order is not 0.
|
29 |
+
|
30 |
+
Parameters
|
31 |
+
----------
|
32 |
+
x : array_like
|
33 |
+
Input array.
|
34 |
+
order : int, optional
|
35 |
+
The order of differentiation. Default order is 1. If order is
|
36 |
+
negative, then integration is carried out under the assumption
|
37 |
+
that ``x_0 == 0``.
|
38 |
+
period : float, optional
|
39 |
+
The assumed period of the sequence. Default is ``2*pi``.
|
40 |
+
|
41 |
+
Notes
|
42 |
+
-----
|
43 |
+
If ``sum(x, axis=0) = 0`` then ``diff(diff(x, k), -k) == x`` (within
|
44 |
+
numerical accuracy).
|
45 |
+
|
46 |
+
For odd order and even ``len(x)``, the Nyquist mode is taken zero.
|
47 |
+
|
48 |
+
"""
|
49 |
+
tmp = asarray(x)
|
50 |
+
if order == 0:
|
51 |
+
return tmp
|
52 |
+
if iscomplexobj(tmp):
|
53 |
+
return diff(tmp.real,order,period)+1j*diff(tmp.imag,order,period)
|
54 |
+
if period is not None:
|
55 |
+
c = 2*pi/period
|
56 |
+
else:
|
57 |
+
c = 1.0
|
58 |
+
n = len(x)
|
59 |
+
omega = _cache.get((n,order,c))
|
60 |
+
if omega is None:
|
61 |
+
if len(_cache) > 20:
|
62 |
+
while _cache:
|
63 |
+
_cache.popitem()
|
64 |
+
|
65 |
+
def kernel(k,order=order,c=c):
|
66 |
+
if k:
|
67 |
+
return pow(c*k,order)
|
68 |
+
return 0
|
69 |
+
omega = convolve.init_convolution_kernel(n,kernel,d=order,
|
70 |
+
zero_nyquist=1)
|
71 |
+
_cache[(n,order,c)] = omega
|
72 |
+
overwrite_x = _datacopied(tmp, x)
|
73 |
+
return convolve.convolve(tmp,omega,swap_real_imag=order % 2,
|
74 |
+
overwrite_x=overwrite_x)
|
75 |
+
|
76 |
+
|
77 |
+
del _cache
|
78 |
+
|
79 |
+
|
80 |
+
_cache = {}
|
81 |
+
|
82 |
+
|
83 |
+
def tilbert(x, h, period=None, _cache=_cache):
|
84 |
+
"""
|
85 |
+
Return h-Tilbert transform of a periodic sequence x.
|
86 |
+
|
87 |
+
If x_j and y_j are Fourier coefficients of periodic functions x
|
88 |
+
and y, respectively, then::
|
89 |
+
|
90 |
+
y_j = sqrt(-1)*coth(j*h*2*pi/period) * x_j
|
91 |
+
y_0 = 0
|
92 |
+
|
93 |
+
Parameters
|
94 |
+
----------
|
95 |
+
x : array_like
|
96 |
+
The input array to transform.
|
97 |
+
h : float
|
98 |
+
Defines the parameter of the Tilbert transform.
|
99 |
+
period : float, optional
|
100 |
+
The assumed period of the sequence. Default period is ``2*pi``.
|
101 |
+
|
102 |
+
Returns
|
103 |
+
-------
|
104 |
+
tilbert : ndarray
|
105 |
+
The result of the transform.
|
106 |
+
|
107 |
+
Notes
|
108 |
+
-----
|
109 |
+
If ``sum(x, axis=0) == 0`` and ``n = len(x)`` is odd, then
|
110 |
+
``tilbert(itilbert(x)) == x``.
|
111 |
+
|
112 |
+
If ``2 * pi * h / period`` is approximately 10 or larger, then
|
113 |
+
numerically ``tilbert == hilbert``
|
114 |
+
(theoretically oo-Tilbert == Hilbert).
|
115 |
+
|
116 |
+
For even ``len(x)``, the Nyquist mode of ``x`` is taken zero.
|
117 |
+
|
118 |
+
"""
|
119 |
+
tmp = asarray(x)
|
120 |
+
if iscomplexobj(tmp):
|
121 |
+
return tilbert(tmp.real, h, period) + \
|
122 |
+
1j * tilbert(tmp.imag, h, period)
|
123 |
+
|
124 |
+
if period is not None:
|
125 |
+
h = h * 2 * pi / period
|
126 |
+
|
127 |
+
n = len(x)
|
128 |
+
omega = _cache.get((n, h))
|
129 |
+
if omega is None:
|
130 |
+
if len(_cache) > 20:
|
131 |
+
while _cache:
|
132 |
+
_cache.popitem()
|
133 |
+
|
134 |
+
def kernel(k, h=h):
|
135 |
+
if k:
|
136 |
+
return 1.0/tanh(h*k)
|
137 |
+
|
138 |
+
return 0
|
139 |
+
|
140 |
+
omega = convolve.init_convolution_kernel(n, kernel, d=1)
|
141 |
+
_cache[(n,h)] = omega
|
142 |
+
|
143 |
+
overwrite_x = _datacopied(tmp, x)
|
144 |
+
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)
|
145 |
+
|
146 |
+
|
147 |
+
del _cache
|
148 |
+
|
149 |
+
|
150 |
+
_cache = {}
|
151 |
+
|
152 |
+
|
153 |
+
def itilbert(x,h,period=None, _cache=_cache):
|
154 |
+
"""
|
155 |
+
Return inverse h-Tilbert transform of a periodic sequence x.
|
156 |
+
|
157 |
+
If ``x_j`` and ``y_j`` are Fourier coefficients of periodic functions x
|
158 |
+
and y, respectively, then::
|
159 |
+
|
160 |
+
y_j = -sqrt(-1)*tanh(j*h*2*pi/period) * x_j
|
161 |
+
y_0 = 0
|
162 |
+
|
163 |
+
For more details, see `tilbert`.
|
164 |
+
|
165 |
+
"""
|
166 |
+
tmp = asarray(x)
|
167 |
+
if iscomplexobj(tmp):
|
168 |
+
return itilbert(tmp.real,h,period) + \
|
169 |
+
1j*itilbert(tmp.imag,h,period)
|
170 |
+
if period is not None:
|
171 |
+
h = h*2*pi/period
|
172 |
+
n = len(x)
|
173 |
+
omega = _cache.get((n,h))
|
174 |
+
if omega is None:
|
175 |
+
if len(_cache) > 20:
|
176 |
+
while _cache:
|
177 |
+
_cache.popitem()
|
178 |
+
|
179 |
+
def kernel(k,h=h):
|
180 |
+
if k:
|
181 |
+
return -tanh(h*k)
|
182 |
+
return 0
|
183 |
+
omega = convolve.init_convolution_kernel(n,kernel,d=1)
|
184 |
+
_cache[(n,h)] = omega
|
185 |
+
overwrite_x = _datacopied(tmp, x)
|
186 |
+
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)
|
187 |
+
|
188 |
+
|
189 |
+
del _cache
|
190 |
+
|
191 |
+
|
192 |
+
_cache = {}
|
193 |
+
|
194 |
+
|
195 |
+
def hilbert(x, _cache=_cache):
|
196 |
+
"""
|
197 |
+
Return Hilbert transform of a periodic sequence x.
|
198 |
+
|
199 |
+
If x_j and y_j are Fourier coefficients of periodic functions x
|
200 |
+
and y, respectively, then::
|
201 |
+
|
202 |
+
y_j = sqrt(-1)*sign(j) * x_j
|
203 |
+
y_0 = 0
|
204 |
+
|
205 |
+
Parameters
|
206 |
+
----------
|
207 |
+
x : array_like
|
208 |
+
The input array, should be periodic.
|
209 |
+
_cache : dict, optional
|
210 |
+
Dictionary that contains the kernel used to do a convolution with.
|
211 |
+
|
212 |
+
Returns
|
213 |
+
-------
|
214 |
+
y : ndarray
|
215 |
+
The transformed input.
|
216 |
+
|
217 |
+
See Also
|
218 |
+
--------
|
219 |
+
scipy.signal.hilbert : Compute the analytic signal, using the Hilbert
|
220 |
+
transform.
|
221 |
+
|
222 |
+
Notes
|
223 |
+
-----
|
224 |
+
If ``sum(x, axis=0) == 0`` then ``hilbert(ihilbert(x)) == x``.
|
225 |
+
|
226 |
+
For even len(x), the Nyquist mode of x is taken zero.
|
227 |
+
|
228 |
+
The sign of the returned transform does not have a factor -1 that is more
|
229 |
+
often than not found in the definition of the Hilbert transform. Note also
|
230 |
+
that `scipy.signal.hilbert` does have an extra -1 factor compared to this
|
231 |
+
function.
|
232 |
+
|
233 |
+
"""
|
234 |
+
tmp = asarray(x)
|
235 |
+
if iscomplexobj(tmp):
|
236 |
+
return hilbert(tmp.real)+1j*hilbert(tmp.imag)
|
237 |
+
n = len(x)
|
238 |
+
omega = _cache.get(n)
|
239 |
+
if omega is None:
|
240 |
+
if len(_cache) > 20:
|
241 |
+
while _cache:
|
242 |
+
_cache.popitem()
|
243 |
+
|
244 |
+
def kernel(k):
|
245 |
+
if k > 0:
|
246 |
+
return 1.0
|
247 |
+
elif k < 0:
|
248 |
+
return -1.0
|
249 |
+
return 0.0
|
250 |
+
omega = convolve.init_convolution_kernel(n,kernel,d=1)
|
251 |
+
_cache[n] = omega
|
252 |
+
overwrite_x = _datacopied(tmp, x)
|
253 |
+
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)
|
254 |
+
|
255 |
+
|
256 |
+
del _cache
|
257 |
+
|
258 |
+
|
259 |
+
def ihilbert(x):
|
260 |
+
"""
|
261 |
+
Return inverse Hilbert transform of a periodic sequence x.
|
262 |
+
|
263 |
+
If ``x_j`` and ``y_j`` are Fourier coefficients of periodic functions x
|
264 |
+
and y, respectively, then::
|
265 |
+
|
266 |
+
y_j = -sqrt(-1)*sign(j) * x_j
|
267 |
+
y_0 = 0
|
268 |
+
|
269 |
+
"""
|
270 |
+
return -hilbert(x)
|
271 |
+
|
272 |
+
|
273 |
+
_cache = {}
|
274 |
+
|
275 |
+
|
276 |
+
def cs_diff(x, a, b, period=None, _cache=_cache):
|
277 |
+
"""
|
278 |
+
Return (a,b)-cosh/sinh pseudo-derivative of a periodic sequence.
|
279 |
+
|
280 |
+
If ``x_j`` and ``y_j`` are Fourier coefficients of periodic functions x
|
281 |
+
and y, respectively, then::
|
282 |
+
|
283 |
+
y_j = -sqrt(-1)*cosh(j*a*2*pi/period)/sinh(j*b*2*pi/period) * x_j
|
284 |
+
y_0 = 0
|
285 |
+
|
286 |
+
Parameters
|
287 |
+
----------
|
288 |
+
x : array_like
|
289 |
+
The array to take the pseudo-derivative from.
|
290 |
+
a, b : float
|
291 |
+
Defines the parameters of the cosh/sinh pseudo-differential
|
292 |
+
operator.
|
293 |
+
period : float, optional
|
294 |
+
The period of the sequence. Default period is ``2*pi``.
|
295 |
+
|
296 |
+
Returns
|
297 |
+
-------
|
298 |
+
cs_diff : ndarray
|
299 |
+
Pseudo-derivative of periodic sequence `x`.
|
300 |
+
|
301 |
+
Notes
|
302 |
+
-----
|
303 |
+
For even len(`x`), the Nyquist mode of `x` is taken as zero.
|
304 |
+
|
305 |
+
"""
|
306 |
+
tmp = asarray(x)
|
307 |
+
if iscomplexobj(tmp):
|
308 |
+
return cs_diff(tmp.real,a,b,period) + \
|
309 |
+
1j*cs_diff(tmp.imag,a,b,period)
|
310 |
+
if period is not None:
|
311 |
+
a = a*2*pi/period
|
312 |
+
b = b*2*pi/period
|
313 |
+
n = len(x)
|
314 |
+
omega = _cache.get((n,a,b))
|
315 |
+
if omega is None:
|
316 |
+
if len(_cache) > 20:
|
317 |
+
while _cache:
|
318 |
+
_cache.popitem()
|
319 |
+
|
320 |
+
def kernel(k,a=a,b=b):
|
321 |
+
if k:
|
322 |
+
return -cosh(a*k)/sinh(b*k)
|
323 |
+
return 0
|
324 |
+
omega = convolve.init_convolution_kernel(n,kernel,d=1)
|
325 |
+
_cache[(n,a,b)] = omega
|
326 |
+
overwrite_x = _datacopied(tmp, x)
|
327 |
+
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)
|
328 |
+
|
329 |
+
|
330 |
+
del _cache
|
331 |
+
|
332 |
+
|
333 |
+
_cache = {}
|
334 |
+
|
335 |
+
|
336 |
+
def sc_diff(x, a, b, period=None, _cache=_cache):
|
337 |
+
"""
|
338 |
+
Return (a,b)-sinh/cosh pseudo-derivative of a periodic sequence x.
|
339 |
+
|
340 |
+
If x_j and y_j are Fourier coefficients of periodic functions x
|
341 |
+
and y, respectively, then::
|
342 |
+
|
343 |
+
y_j = sqrt(-1)*sinh(j*a*2*pi/period)/cosh(j*b*2*pi/period) * x_j
|
344 |
+
y_0 = 0
|
345 |
+
|
346 |
+
Parameters
|
347 |
+
----------
|
348 |
+
x : array_like
|
349 |
+
Input array.
|
350 |
+
a,b : float
|
351 |
+
Defines the parameters of the sinh/cosh pseudo-differential
|
352 |
+
operator.
|
353 |
+
period : float, optional
|
354 |
+
The period of the sequence x. Default is 2*pi.
|
355 |
+
|
356 |
+
Notes
|
357 |
+
-----
|
358 |
+
``sc_diff(cs_diff(x,a,b),b,a) == x``
|
359 |
+
For even ``len(x)``, the Nyquist mode of x is taken as zero.
|
360 |
+
|
361 |
+
"""
|
362 |
+
tmp = asarray(x)
|
363 |
+
if iscomplexobj(tmp):
|
364 |
+
return sc_diff(tmp.real,a,b,period) + \
|
365 |
+
1j*sc_diff(tmp.imag,a,b,period)
|
366 |
+
if period is not None:
|
367 |
+
a = a*2*pi/period
|
368 |
+
b = b*2*pi/period
|
369 |
+
n = len(x)
|
370 |
+
omega = _cache.get((n,a,b))
|
371 |
+
if omega is None:
|
372 |
+
if len(_cache) > 20:
|
373 |
+
while _cache:
|
374 |
+
_cache.popitem()
|
375 |
+
|
376 |
+
def kernel(k,a=a,b=b):
|
377 |
+
if k:
|
378 |
+
return sinh(a*k)/cosh(b*k)
|
379 |
+
return 0
|
380 |
+
omega = convolve.init_convolution_kernel(n,kernel,d=1)
|
381 |
+
_cache[(n,a,b)] = omega
|
382 |
+
overwrite_x = _datacopied(tmp, x)
|
383 |
+
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)
|
384 |
+
|
385 |
+
|
386 |
+
del _cache
|
387 |
+
|
388 |
+
|
389 |
+
_cache = {}
|
390 |
+
|
391 |
+
|
392 |
+
def ss_diff(x, a, b, period=None, _cache=_cache):
|
393 |
+
"""
|
394 |
+
Return (a,b)-sinh/sinh pseudo-derivative of a periodic sequence x.
|
395 |
+
|
396 |
+
If x_j and y_j are Fourier coefficients of periodic functions x
|
397 |
+
and y, respectively, then::
|
398 |
+
|
399 |
+
y_j = sinh(j*a*2*pi/period)/sinh(j*b*2*pi/period) * x_j
|
400 |
+
y_0 = a/b * x_0
|
401 |
+
|
402 |
+
Parameters
|
403 |
+
----------
|
404 |
+
x : array_like
|
405 |
+
The array to take the pseudo-derivative from.
|
406 |
+
a,b
|
407 |
+
Defines the parameters of the sinh/sinh pseudo-differential
|
408 |
+
operator.
|
409 |
+
period : float, optional
|
410 |
+
The period of the sequence x. Default is ``2*pi``.
|
411 |
+
|
412 |
+
Notes
|
413 |
+
-----
|
414 |
+
``ss_diff(ss_diff(x,a,b),b,a) == x``
|
415 |
+
|
416 |
+
"""
|
417 |
+
tmp = asarray(x)
|
418 |
+
if iscomplexobj(tmp):
|
419 |
+
return ss_diff(tmp.real,a,b,period) + \
|
420 |
+
1j*ss_diff(tmp.imag,a,b,period)
|
421 |
+
if period is not None:
|
422 |
+
a = a*2*pi/period
|
423 |
+
b = b*2*pi/period
|
424 |
+
n = len(x)
|
425 |
+
omega = _cache.get((n,a,b))
|
426 |
+
if omega is None:
|
427 |
+
if len(_cache) > 20:
|
428 |
+
while _cache:
|
429 |
+
_cache.popitem()
|
430 |
+
|
431 |
+
def kernel(k,a=a,b=b):
|
432 |
+
if k:
|
433 |
+
return sinh(a*k)/sinh(b*k)
|
434 |
+
return float(a)/b
|
435 |
+
omega = convolve.init_convolution_kernel(n,kernel)
|
436 |
+
_cache[(n,a,b)] = omega
|
437 |
+
overwrite_x = _datacopied(tmp, x)
|
438 |
+
return convolve.convolve(tmp,omega,overwrite_x=overwrite_x)
|
439 |
+
|
440 |
+
|
441 |
+
del _cache
|
442 |
+
|
443 |
+
|
444 |
+
_cache = {}
|
445 |
+
|
446 |
+
|
447 |
+
def cc_diff(x, a, b, period=None, _cache=_cache):
|
448 |
+
"""
|
449 |
+
Return (a,b)-cosh/cosh pseudo-derivative of a periodic sequence.
|
450 |
+
|
451 |
+
If x_j and y_j are Fourier coefficients of periodic functions x
|
452 |
+
and y, respectively, then::
|
453 |
+
|
454 |
+
y_j = cosh(j*a*2*pi/period)/cosh(j*b*2*pi/period) * x_j
|
455 |
+
|
456 |
+
Parameters
|
457 |
+
----------
|
458 |
+
x : array_like
|
459 |
+
The array to take the pseudo-derivative from.
|
460 |
+
a,b : float
|
461 |
+
Defines the parameters of the sinh/sinh pseudo-differential
|
462 |
+
operator.
|
463 |
+
period : float, optional
|
464 |
+
The period of the sequence x. Default is ``2*pi``.
|
465 |
+
|
466 |
+
Returns
|
467 |
+
-------
|
468 |
+
cc_diff : ndarray
|
469 |
+
Pseudo-derivative of periodic sequence `x`.
|
470 |
+
|
471 |
+
Notes
|
472 |
+
-----
|
473 |
+
``cc_diff(cc_diff(x,a,b),b,a) == x``
|
474 |
+
|
475 |
+
"""
|
476 |
+
tmp = asarray(x)
|
477 |
+
if iscomplexobj(tmp):
|
478 |
+
return cc_diff(tmp.real,a,b,period) + \
|
479 |
+
1j*cc_diff(tmp.imag,a,b,period)
|
480 |
+
if period is not None:
|
481 |
+
a = a*2*pi/period
|
482 |
+
b = b*2*pi/period
|
483 |
+
n = len(x)
|
484 |
+
omega = _cache.get((n,a,b))
|
485 |
+
if omega is None:
|
486 |
+
if len(_cache) > 20:
|
487 |
+
while _cache:
|
488 |
+
_cache.popitem()
|
489 |
+
|
490 |
+
def kernel(k,a=a,b=b):
|
491 |
+
return cosh(a*k)/cosh(b*k)
|
492 |
+
omega = convolve.init_convolution_kernel(n,kernel)
|
493 |
+
_cache[(n,a,b)] = omega
|
494 |
+
overwrite_x = _datacopied(tmp, x)
|
495 |
+
return convolve.convolve(tmp,omega,overwrite_x=overwrite_x)
|
496 |
+
|
497 |
+
|
498 |
+
del _cache
|
499 |
+
|
500 |
+
|
501 |
+
_cache = {}
|
502 |
+
|
503 |
+
|
504 |
+
def shift(x, a, period=None, _cache=_cache):
|
505 |
+
"""
|
506 |
+
Shift periodic sequence x by a: y(u) = x(u+a).
|
507 |
+
|
508 |
+
If x_j and y_j are Fourier coefficients of periodic functions x
|
509 |
+
and y, respectively, then::
|
510 |
+
|
511 |
+
y_j = exp(j*a*2*pi/period*sqrt(-1)) * x_f
|
512 |
+
|
513 |
+
Parameters
|
514 |
+
----------
|
515 |
+
x : array_like
|
516 |
+
The array to take the pseudo-derivative from.
|
517 |
+
a : float
|
518 |
+
Defines the parameters of the sinh/sinh pseudo-differential
|
519 |
+
period : float, optional
|
520 |
+
The period of the sequences x and y. Default period is ``2*pi``.
|
521 |
+
"""
|
522 |
+
tmp = asarray(x)
|
523 |
+
if iscomplexobj(tmp):
|
524 |
+
return shift(tmp.real,a,period)+1j*shift(tmp.imag,a,period)
|
525 |
+
if period is not None:
|
526 |
+
a = a*2*pi/period
|
527 |
+
n = len(x)
|
528 |
+
omega = _cache.get((n,a))
|
529 |
+
if omega is None:
|
530 |
+
if len(_cache) > 20:
|
531 |
+
while _cache:
|
532 |
+
_cache.popitem()
|
533 |
+
|
534 |
+
def kernel_real(k,a=a):
|
535 |
+
return cos(a*k)
|
536 |
+
|
537 |
+
def kernel_imag(k,a=a):
|
538 |
+
return sin(a*k)
|
539 |
+
omega_real = convolve.init_convolution_kernel(n,kernel_real,d=0,
|
540 |
+
zero_nyquist=0)
|
541 |
+
omega_imag = convolve.init_convolution_kernel(n,kernel_imag,d=1,
|
542 |
+
zero_nyquist=0)
|
543 |
+
_cache[(n,a)] = omega_real,omega_imag
|
544 |
+
else:
|
545 |
+
omega_real,omega_imag = omega
|
546 |
+
overwrite_x = _datacopied(tmp, x)
|
547 |
+
return convolve.convolve_z(tmp,omega_real,omega_imag,
|
548 |
+
overwrite_x=overwrite_x)
|
549 |
+
|
550 |
+
|
551 |
+
del _cache
|
venv/lib/python3.10/site-packages/scipy/fftpack/_realtransforms.py
ADDED
@@ -0,0 +1,598 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Real spectrum transforms (DCT, DST, MDCT)
|
3 |
+
"""
|
4 |
+
|
5 |
+
__all__ = ['dct', 'idct', 'dst', 'idst', 'dctn', 'idctn', 'dstn', 'idstn']
|
6 |
+
|
7 |
+
from scipy.fft import _pocketfft
|
8 |
+
from ._helper import _good_shape
|
9 |
+
|
10 |
+
_inverse_typemap = {1: 1, 2: 3, 3: 2, 4: 4}
|
11 |
+
|
12 |
+
|
13 |
+
def dctn(x, type=2, shape=None, axes=None, norm=None, overwrite_x=False):
|
14 |
+
"""
|
15 |
+
Return multidimensional Discrete Cosine Transform along the specified axes.
|
16 |
+
|
17 |
+
Parameters
|
18 |
+
----------
|
19 |
+
x : array_like
|
20 |
+
The input array.
|
21 |
+
type : {1, 2, 3, 4}, optional
|
22 |
+
Type of the DCT (see Notes). Default type is 2.
|
23 |
+
shape : int or array_like of ints or None, optional
|
24 |
+
The shape of the result. If both `shape` and `axes` (see below) are
|
25 |
+
None, `shape` is ``x.shape``; if `shape` is None but `axes` is
|
26 |
+
not None, then `shape` is ``numpy.take(x.shape, axes, axis=0)``.
|
27 |
+
If ``shape[i] > x.shape[i]``, the ith dimension is padded with zeros.
|
28 |
+
If ``shape[i] < x.shape[i]``, the ith dimension is truncated to
|
29 |
+
length ``shape[i]``.
|
30 |
+
If any element of `shape` is -1, the size of the corresponding
|
31 |
+
dimension of `x` is used.
|
32 |
+
axes : int or array_like of ints or None, optional
|
33 |
+
Axes along which the DCT is computed.
|
34 |
+
The default is over all axes.
|
35 |
+
norm : {None, 'ortho'}, optional
|
36 |
+
Normalization mode (see Notes). Default is None.
|
37 |
+
overwrite_x : bool, optional
|
38 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
39 |
+
|
40 |
+
Returns
|
41 |
+
-------
|
42 |
+
y : ndarray of real
|
43 |
+
The transformed input array.
|
44 |
+
|
45 |
+
See Also
|
46 |
+
--------
|
47 |
+
idctn : Inverse multidimensional DCT
|
48 |
+
|
49 |
+
Notes
|
50 |
+
-----
|
51 |
+
For full details of the DCT types and normalization modes, as well as
|
52 |
+
references, see `dct`.
|
53 |
+
|
54 |
+
Examples
|
55 |
+
--------
|
56 |
+
>>> import numpy as np
|
57 |
+
>>> from scipy.fftpack import dctn, idctn
|
58 |
+
>>> rng = np.random.default_rng()
|
59 |
+
>>> y = rng.standard_normal((16, 16))
|
60 |
+
>>> np.allclose(y, idctn(dctn(y, norm='ortho'), norm='ortho'))
|
61 |
+
True
|
62 |
+
|
63 |
+
"""
|
64 |
+
shape = _good_shape(x, shape, axes)
|
65 |
+
return _pocketfft.dctn(x, type, shape, axes, norm, overwrite_x)
|
66 |
+
|
67 |
+
|
68 |
+
def idctn(x, type=2, shape=None, axes=None, norm=None, overwrite_x=False):
|
69 |
+
"""
|
70 |
+
Return multidimensional Discrete Cosine Transform along the specified axes.
|
71 |
+
|
72 |
+
Parameters
|
73 |
+
----------
|
74 |
+
x : array_like
|
75 |
+
The input array.
|
76 |
+
type : {1, 2, 3, 4}, optional
|
77 |
+
Type of the DCT (see Notes). Default type is 2.
|
78 |
+
shape : int or array_like of ints or None, optional
|
79 |
+
The shape of the result. If both `shape` and `axes` (see below) are
|
80 |
+
None, `shape` is ``x.shape``; if `shape` is None but `axes` is
|
81 |
+
not None, then `shape` is ``numpy.take(x.shape, axes, axis=0)``.
|
82 |
+
If ``shape[i] > x.shape[i]``, the ith dimension is padded with zeros.
|
83 |
+
If ``shape[i] < x.shape[i]``, the ith dimension is truncated to
|
84 |
+
length ``shape[i]``.
|
85 |
+
If any element of `shape` is -1, the size of the corresponding
|
86 |
+
dimension of `x` is used.
|
87 |
+
axes : int or array_like of ints or None, optional
|
88 |
+
Axes along which the IDCT is computed.
|
89 |
+
The default is over all axes.
|
90 |
+
norm : {None, 'ortho'}, optional
|
91 |
+
Normalization mode (see Notes). Default is None.
|
92 |
+
overwrite_x : bool, optional
|
93 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
94 |
+
|
95 |
+
Returns
|
96 |
+
-------
|
97 |
+
y : ndarray of real
|
98 |
+
The transformed input array.
|
99 |
+
|
100 |
+
See Also
|
101 |
+
--------
|
102 |
+
dctn : multidimensional DCT
|
103 |
+
|
104 |
+
Notes
|
105 |
+
-----
|
106 |
+
For full details of the IDCT types and normalization modes, as well as
|
107 |
+
references, see `idct`.
|
108 |
+
|
109 |
+
Examples
|
110 |
+
--------
|
111 |
+
>>> import numpy as np
|
112 |
+
>>> from scipy.fftpack import dctn, idctn
|
113 |
+
>>> rng = np.random.default_rng()
|
114 |
+
>>> y = rng.standard_normal((16, 16))
|
115 |
+
>>> np.allclose(y, idctn(dctn(y, norm='ortho'), norm='ortho'))
|
116 |
+
True
|
117 |
+
|
118 |
+
"""
|
119 |
+
type = _inverse_typemap[type]
|
120 |
+
shape = _good_shape(x, shape, axes)
|
121 |
+
return _pocketfft.dctn(x, type, shape, axes, norm, overwrite_x)
|
122 |
+
|
123 |
+
|
124 |
+
def dstn(x, type=2, shape=None, axes=None, norm=None, overwrite_x=False):
|
125 |
+
"""
|
126 |
+
Return multidimensional Discrete Sine Transform along the specified axes.
|
127 |
+
|
128 |
+
Parameters
|
129 |
+
----------
|
130 |
+
x : array_like
|
131 |
+
The input array.
|
132 |
+
type : {1, 2, 3, 4}, optional
|
133 |
+
Type of the DST (see Notes). Default type is 2.
|
134 |
+
shape : int or array_like of ints or None, optional
|
135 |
+
The shape of the result. If both `shape` and `axes` (see below) are
|
136 |
+
None, `shape` is ``x.shape``; if `shape` is None but `axes` is
|
137 |
+
not None, then `shape` is ``numpy.take(x.shape, axes, axis=0)``.
|
138 |
+
If ``shape[i] > x.shape[i]``, the ith dimension is padded with zeros.
|
139 |
+
If ``shape[i] < x.shape[i]``, the ith dimension is truncated to
|
140 |
+
length ``shape[i]``.
|
141 |
+
If any element of `shape` is -1, the size of the corresponding
|
142 |
+
dimension of `x` is used.
|
143 |
+
axes : int or array_like of ints or None, optional
|
144 |
+
Axes along which the DCT is computed.
|
145 |
+
The default is over all axes.
|
146 |
+
norm : {None, 'ortho'}, optional
|
147 |
+
Normalization mode (see Notes). Default is None.
|
148 |
+
overwrite_x : bool, optional
|
149 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
150 |
+
|
151 |
+
Returns
|
152 |
+
-------
|
153 |
+
y : ndarray of real
|
154 |
+
The transformed input array.
|
155 |
+
|
156 |
+
See Also
|
157 |
+
--------
|
158 |
+
idstn : Inverse multidimensional DST
|
159 |
+
|
160 |
+
Notes
|
161 |
+
-----
|
162 |
+
For full details of the DST types and normalization modes, as well as
|
163 |
+
references, see `dst`.
|
164 |
+
|
165 |
+
Examples
|
166 |
+
--------
|
167 |
+
>>> import numpy as np
|
168 |
+
>>> from scipy.fftpack import dstn, idstn
|
169 |
+
>>> rng = np.random.default_rng()
|
170 |
+
>>> y = rng.standard_normal((16, 16))
|
171 |
+
>>> np.allclose(y, idstn(dstn(y, norm='ortho'), norm='ortho'))
|
172 |
+
True
|
173 |
+
|
174 |
+
"""
|
175 |
+
shape = _good_shape(x, shape, axes)
|
176 |
+
return _pocketfft.dstn(x, type, shape, axes, norm, overwrite_x)
|
177 |
+
|
178 |
+
|
179 |
+
def idstn(x, type=2, shape=None, axes=None, norm=None, overwrite_x=False):
|
180 |
+
"""
|
181 |
+
Return multidimensional Discrete Sine Transform along the specified axes.
|
182 |
+
|
183 |
+
Parameters
|
184 |
+
----------
|
185 |
+
x : array_like
|
186 |
+
The input array.
|
187 |
+
type : {1, 2, 3, 4}, optional
|
188 |
+
Type of the DST (see Notes). Default type is 2.
|
189 |
+
shape : int or array_like of ints or None, optional
|
190 |
+
The shape of the result. If both `shape` and `axes` (see below) are
|
191 |
+
None, `shape` is ``x.shape``; if `shape` is None but `axes` is
|
192 |
+
not None, then `shape` is ``numpy.take(x.shape, axes, axis=0)``.
|
193 |
+
If ``shape[i] > x.shape[i]``, the ith dimension is padded with zeros.
|
194 |
+
If ``shape[i] < x.shape[i]``, the ith dimension is truncated to
|
195 |
+
length ``shape[i]``.
|
196 |
+
If any element of `shape` is -1, the size of the corresponding
|
197 |
+
dimension of `x` is used.
|
198 |
+
axes : int or array_like of ints or None, optional
|
199 |
+
Axes along which the IDST is computed.
|
200 |
+
The default is over all axes.
|
201 |
+
norm : {None, 'ortho'}, optional
|
202 |
+
Normalization mode (see Notes). Default is None.
|
203 |
+
overwrite_x : bool, optional
|
204 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
205 |
+
|
206 |
+
Returns
|
207 |
+
-------
|
208 |
+
y : ndarray of real
|
209 |
+
The transformed input array.
|
210 |
+
|
211 |
+
See Also
|
212 |
+
--------
|
213 |
+
dstn : multidimensional DST
|
214 |
+
|
215 |
+
Notes
|
216 |
+
-----
|
217 |
+
For full details of the IDST types and normalization modes, as well as
|
218 |
+
references, see `idst`.
|
219 |
+
|
220 |
+
Examples
|
221 |
+
--------
|
222 |
+
>>> import numpy as np
|
223 |
+
>>> from scipy.fftpack import dstn, idstn
|
224 |
+
>>> rng = np.random.default_rng()
|
225 |
+
>>> y = rng.standard_normal((16, 16))
|
226 |
+
>>> np.allclose(y, idstn(dstn(y, norm='ortho'), norm='ortho'))
|
227 |
+
True
|
228 |
+
|
229 |
+
"""
|
230 |
+
type = _inverse_typemap[type]
|
231 |
+
shape = _good_shape(x, shape, axes)
|
232 |
+
return _pocketfft.dstn(x, type, shape, axes, norm, overwrite_x)
|
233 |
+
|
234 |
+
|
235 |
+
def dct(x, type=2, n=None, axis=-1, norm=None, overwrite_x=False):
|
236 |
+
r"""
|
237 |
+
Return the Discrete Cosine Transform of arbitrary type sequence x.
|
238 |
+
|
239 |
+
Parameters
|
240 |
+
----------
|
241 |
+
x : array_like
|
242 |
+
The input array.
|
243 |
+
type : {1, 2, 3, 4}, optional
|
244 |
+
Type of the DCT (see Notes). Default type is 2.
|
245 |
+
n : int, optional
|
246 |
+
Length of the transform. If ``n < x.shape[axis]``, `x` is
|
247 |
+
truncated. If ``n > x.shape[axis]``, `x` is zero-padded. The
|
248 |
+
default results in ``n = x.shape[axis]``.
|
249 |
+
axis : int, optional
|
250 |
+
Axis along which the dct is computed; the default is over the
|
251 |
+
last axis (i.e., ``axis=-1``).
|
252 |
+
norm : {None, 'ortho'}, optional
|
253 |
+
Normalization mode (see Notes). Default is None.
|
254 |
+
overwrite_x : bool, optional
|
255 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
256 |
+
|
257 |
+
Returns
|
258 |
+
-------
|
259 |
+
y : ndarray of real
|
260 |
+
The transformed input array.
|
261 |
+
|
262 |
+
See Also
|
263 |
+
--------
|
264 |
+
idct : Inverse DCT
|
265 |
+
|
266 |
+
Notes
|
267 |
+
-----
|
268 |
+
For a single dimension array ``x``, ``dct(x, norm='ortho')`` is equal to
|
269 |
+
MATLAB ``dct(x)``.
|
270 |
+
|
271 |
+
There are, theoretically, 8 types of the DCT, only the first 4 types are
|
272 |
+
implemented in scipy. 'The' DCT generally refers to DCT type 2, and 'the'
|
273 |
+
Inverse DCT generally refers to DCT type 3.
|
274 |
+
|
275 |
+
**Type I**
|
276 |
+
|
277 |
+
There are several definitions of the DCT-I; we use the following
|
278 |
+
(for ``norm=None``)
|
279 |
+
|
280 |
+
.. math::
|
281 |
+
|
282 |
+
y_k = x_0 + (-1)^k x_{N-1} + 2 \sum_{n=1}^{N-2} x_n \cos\left(
|
283 |
+
\frac{\pi k n}{N-1} \right)
|
284 |
+
|
285 |
+
If ``norm='ortho'``, ``x[0]`` and ``x[N-1]`` are multiplied by a scaling
|
286 |
+
factor of :math:`\sqrt{2}`, and ``y[k]`` is multiplied by a scaling factor
|
287 |
+
``f``
|
288 |
+
|
289 |
+
.. math::
|
290 |
+
|
291 |
+
f = \begin{cases}
|
292 |
+
\frac{1}{2}\sqrt{\frac{1}{N-1}} & \text{if }k=0\text{ or }N-1, \\
|
293 |
+
\frac{1}{2}\sqrt{\frac{2}{N-1}} & \text{otherwise} \end{cases}
|
294 |
+
|
295 |
+
.. versionadded:: 1.2.0
|
296 |
+
Orthonormalization in DCT-I.
|
297 |
+
|
298 |
+
.. note::
|
299 |
+
The DCT-I is only supported for input size > 1.
|
300 |
+
|
301 |
+
**Type II**
|
302 |
+
|
303 |
+
There are several definitions of the DCT-II; we use the following
|
304 |
+
(for ``norm=None``)
|
305 |
+
|
306 |
+
.. math::
|
307 |
+
|
308 |
+
y_k = 2 \sum_{n=0}^{N-1} x_n \cos\left(\frac{\pi k(2n+1)}{2N} \right)
|
309 |
+
|
310 |
+
If ``norm='ortho'``, ``y[k]`` is multiplied by a scaling factor ``f``
|
311 |
+
|
312 |
+
.. math::
|
313 |
+
f = \begin{cases}
|
314 |
+
\sqrt{\frac{1}{4N}} & \text{if }k=0, \\
|
315 |
+
\sqrt{\frac{1}{2N}} & \text{otherwise} \end{cases}
|
316 |
+
|
317 |
+
which makes the corresponding matrix of coefficients orthonormal
|
318 |
+
(``O @ O.T = np.eye(N)``).
|
319 |
+
|
320 |
+
**Type III**
|
321 |
+
|
322 |
+
There are several definitions, we use the following (for ``norm=None``)
|
323 |
+
|
324 |
+
.. math::
|
325 |
+
|
326 |
+
y_k = x_0 + 2 \sum_{n=1}^{N-1} x_n \cos\left(\frac{\pi(2k+1)n}{2N}\right)
|
327 |
+
|
328 |
+
or, for ``norm='ortho'``
|
329 |
+
|
330 |
+
.. math::
|
331 |
+
|
332 |
+
y_k = \frac{x_0}{\sqrt{N}} + \sqrt{\frac{2}{N}} \sum_{n=1}^{N-1} x_n
|
333 |
+
\cos\left(\frac{\pi(2k+1)n}{2N}\right)
|
334 |
+
|
335 |
+
The (unnormalized) DCT-III is the inverse of the (unnormalized) DCT-II, up
|
336 |
+
to a factor `2N`. The orthonormalized DCT-III is exactly the inverse of
|
337 |
+
the orthonormalized DCT-II.
|
338 |
+
|
339 |
+
**Type IV**
|
340 |
+
|
341 |
+
There are several definitions of the DCT-IV; we use the following
|
342 |
+
(for ``norm=None``)
|
343 |
+
|
344 |
+
.. math::
|
345 |
+
|
346 |
+
y_k = 2 \sum_{n=0}^{N-1} x_n \cos\left(\frac{\pi(2k+1)(2n+1)}{4N} \right)
|
347 |
+
|
348 |
+
If ``norm='ortho'``, ``y[k]`` is multiplied by a scaling factor ``f``
|
349 |
+
|
350 |
+
.. math::
|
351 |
+
|
352 |
+
f = \frac{1}{\sqrt{2N}}
|
353 |
+
|
354 |
+
.. versionadded:: 1.2.0
|
355 |
+
Support for DCT-IV.
|
356 |
+
|
357 |
+
References
|
358 |
+
----------
|
359 |
+
.. [1] 'A Fast Cosine Transform in One and Two Dimensions', by J.
|
360 |
+
Makhoul, `IEEE Transactions on acoustics, speech and signal
|
361 |
+
processing` vol. 28(1), pp. 27-34,
|
362 |
+
:doi:`10.1109/TASSP.1980.1163351` (1980).
|
363 |
+
.. [2] Wikipedia, "Discrete cosine transform",
|
364 |
+
https://en.wikipedia.org/wiki/Discrete_cosine_transform
|
365 |
+
|
366 |
+
Examples
|
367 |
+
--------
|
368 |
+
The Type 1 DCT is equivalent to the FFT (though faster) for real,
|
369 |
+
even-symmetrical inputs. The output is also real and even-symmetrical.
|
370 |
+
Half of the FFT input is used to generate half of the FFT output:
|
371 |
+
|
372 |
+
>>> from scipy.fftpack import fft, dct
|
373 |
+
>>> import numpy as np
|
374 |
+
>>> fft(np.array([4., 3., 5., 10., 5., 3.])).real
|
375 |
+
array([ 30., -8., 6., -2., 6., -8.])
|
376 |
+
>>> dct(np.array([4., 3., 5., 10.]), 1)
|
377 |
+
array([ 30., -8., 6., -2.])
|
378 |
+
|
379 |
+
"""
|
380 |
+
return _pocketfft.dct(x, type, n, axis, norm, overwrite_x)
|
381 |
+
|
382 |
+
|
383 |
+
def idct(x, type=2, n=None, axis=-1, norm=None, overwrite_x=False):
|
384 |
+
"""
|
385 |
+
Return the Inverse Discrete Cosine Transform of an arbitrary type sequence.
|
386 |
+
|
387 |
+
Parameters
|
388 |
+
----------
|
389 |
+
x : array_like
|
390 |
+
The input array.
|
391 |
+
type : {1, 2, 3, 4}, optional
|
392 |
+
Type of the DCT (see Notes). Default type is 2.
|
393 |
+
n : int, optional
|
394 |
+
Length of the transform. If ``n < x.shape[axis]``, `x` is
|
395 |
+
truncated. If ``n > x.shape[axis]``, `x` is zero-padded. The
|
396 |
+
default results in ``n = x.shape[axis]``.
|
397 |
+
axis : int, optional
|
398 |
+
Axis along which the idct is computed; the default is over the
|
399 |
+
last axis (i.e., ``axis=-1``).
|
400 |
+
norm : {None, 'ortho'}, optional
|
401 |
+
Normalization mode (see Notes). Default is None.
|
402 |
+
overwrite_x : bool, optional
|
403 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
404 |
+
|
405 |
+
Returns
|
406 |
+
-------
|
407 |
+
idct : ndarray of real
|
408 |
+
The transformed input array.
|
409 |
+
|
410 |
+
See Also
|
411 |
+
--------
|
412 |
+
dct : Forward DCT
|
413 |
+
|
414 |
+
Notes
|
415 |
+
-----
|
416 |
+
For a single dimension array `x`, ``idct(x, norm='ortho')`` is equal to
|
417 |
+
MATLAB ``idct(x)``.
|
418 |
+
|
419 |
+
'The' IDCT is the IDCT of type 2, which is the same as DCT of type 3.
|
420 |
+
|
421 |
+
IDCT of type 1 is the DCT of type 1, IDCT of type 2 is the DCT of type
|
422 |
+
3, and IDCT of type 3 is the DCT of type 2. IDCT of type 4 is the DCT
|
423 |
+
of type 4. For the definition of these types, see `dct`.
|
424 |
+
|
425 |
+
Examples
|
426 |
+
--------
|
427 |
+
The Type 1 DCT is equivalent to the DFT for real, even-symmetrical
|
428 |
+
inputs. The output is also real and even-symmetrical. Half of the IFFT
|
429 |
+
input is used to generate half of the IFFT output:
|
430 |
+
|
431 |
+
>>> from scipy.fftpack import ifft, idct
|
432 |
+
>>> import numpy as np
|
433 |
+
>>> ifft(np.array([ 30., -8., 6., -2., 6., -8.])).real
|
434 |
+
array([ 4., 3., 5., 10., 5., 3.])
|
435 |
+
>>> idct(np.array([ 30., -8., 6., -2.]), 1) / 6
|
436 |
+
array([ 4., 3., 5., 10.])
|
437 |
+
|
438 |
+
"""
|
439 |
+
type = _inverse_typemap[type]
|
440 |
+
return _pocketfft.dct(x, type, n, axis, norm, overwrite_x)
|
441 |
+
|
442 |
+
|
443 |
+
def dst(x, type=2, n=None, axis=-1, norm=None, overwrite_x=False):
|
444 |
+
r"""
|
445 |
+
Return the Discrete Sine Transform of arbitrary type sequence x.
|
446 |
+
|
447 |
+
Parameters
|
448 |
+
----------
|
449 |
+
x : array_like
|
450 |
+
The input array.
|
451 |
+
type : {1, 2, 3, 4}, optional
|
452 |
+
Type of the DST (see Notes). Default type is 2.
|
453 |
+
n : int, optional
|
454 |
+
Length of the transform. If ``n < x.shape[axis]``, `x` is
|
455 |
+
truncated. If ``n > x.shape[axis]``, `x` is zero-padded. The
|
456 |
+
default results in ``n = x.shape[axis]``.
|
457 |
+
axis : int, optional
|
458 |
+
Axis along which the dst is computed; the default is over the
|
459 |
+
last axis (i.e., ``axis=-1``).
|
460 |
+
norm : {None, 'ortho'}, optional
|
461 |
+
Normalization mode (see Notes). Default is None.
|
462 |
+
overwrite_x : bool, optional
|
463 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
464 |
+
|
465 |
+
Returns
|
466 |
+
-------
|
467 |
+
dst : ndarray of reals
|
468 |
+
The transformed input array.
|
469 |
+
|
470 |
+
See Also
|
471 |
+
--------
|
472 |
+
idst : Inverse DST
|
473 |
+
|
474 |
+
Notes
|
475 |
+
-----
|
476 |
+
For a single dimension array ``x``.
|
477 |
+
|
478 |
+
There are, theoretically, 8 types of the DST for different combinations of
|
479 |
+
even/odd boundary conditions and boundary off sets [1]_, only the first
|
480 |
+
4 types are implemented in scipy.
|
481 |
+
|
482 |
+
**Type I**
|
483 |
+
|
484 |
+
There are several definitions of the DST-I; we use the following
|
485 |
+
for ``norm=None``. DST-I assumes the input is odd around `n=-1` and `n=N`.
|
486 |
+
|
487 |
+
.. math::
|
488 |
+
|
489 |
+
y_k = 2 \sum_{n=0}^{N-1} x_n \sin\left(\frac{\pi(k+1)(n+1)}{N+1}\right)
|
490 |
+
|
491 |
+
Note that the DST-I is only supported for input size > 1.
|
492 |
+
The (unnormalized) DST-I is its own inverse, up to a factor `2(N+1)`.
|
493 |
+
The orthonormalized DST-I is exactly its own inverse.
|
494 |
+
|
495 |
+
**Type II**
|
496 |
+
|
497 |
+
There are several definitions of the DST-II; we use the following for
|
498 |
+
``norm=None``. DST-II assumes the input is odd around `n=-1/2` and
|
499 |
+
`n=N-1/2`; the output is odd around :math:`k=-1` and even around `k=N-1`
|
500 |
+
|
501 |
+
.. math::
|
502 |
+
|
503 |
+
y_k = 2 \sum_{n=0}^{N-1} x_n \sin\left(\frac{\pi(k+1)(2n+1)}{2N}\right)
|
504 |
+
|
505 |
+
if ``norm='ortho'``, ``y[k]`` is multiplied by a scaling factor ``f``
|
506 |
+
|
507 |
+
.. math::
|
508 |
+
|
509 |
+
f = \begin{cases}
|
510 |
+
\sqrt{\frac{1}{4N}} & \text{if }k = 0, \\
|
511 |
+
\sqrt{\frac{1}{2N}} & \text{otherwise} \end{cases}
|
512 |
+
|
513 |
+
**Type III**
|
514 |
+
|
515 |
+
There are several definitions of the DST-III, we use the following (for
|
516 |
+
``norm=None``). DST-III assumes the input is odd around `n=-1` and even
|
517 |
+
around `n=N-1`
|
518 |
+
|
519 |
+
.. math::
|
520 |
+
|
521 |
+
y_k = (-1)^k x_{N-1} + 2 \sum_{n=0}^{N-2} x_n \sin\left(
|
522 |
+
\frac{\pi(2k+1)(n+1)}{2N}\right)
|
523 |
+
|
524 |
+
The (unnormalized) DST-III is the inverse of the (unnormalized) DST-II, up
|
525 |
+
to a factor `2N`. The orthonormalized DST-III is exactly the inverse of the
|
526 |
+
orthonormalized DST-II.
|
527 |
+
|
528 |
+
.. versionadded:: 0.11.0
|
529 |
+
|
530 |
+
**Type IV**
|
531 |
+
|
532 |
+
There are several definitions of the DST-IV, we use the following (for
|
533 |
+
``norm=None``). DST-IV assumes the input is odd around `n=-0.5` and even
|
534 |
+
around `n=N-0.5`
|
535 |
+
|
536 |
+
.. math::
|
537 |
+
|
538 |
+
y_k = 2 \sum_{n=0}^{N-1} x_n \sin\left(\frac{\pi(2k+1)(2n+1)}{4N}\right)
|
539 |
+
|
540 |
+
The (unnormalized) DST-IV is its own inverse, up to a factor `2N`. The
|
541 |
+
orthonormalized DST-IV is exactly its own inverse.
|
542 |
+
|
543 |
+
.. versionadded:: 1.2.0
|
544 |
+
Support for DST-IV.
|
545 |
+
|
546 |
+
References
|
547 |
+
----------
|
548 |
+
.. [1] Wikipedia, "Discrete sine transform",
|
549 |
+
https://en.wikipedia.org/wiki/Discrete_sine_transform
|
550 |
+
|
551 |
+
"""
|
552 |
+
return _pocketfft.dst(x, type, n, axis, norm, overwrite_x)
|
553 |
+
|
554 |
+
|
555 |
+
def idst(x, type=2, n=None, axis=-1, norm=None, overwrite_x=False):
|
556 |
+
"""
|
557 |
+
Return the Inverse Discrete Sine Transform of an arbitrary type sequence.
|
558 |
+
|
559 |
+
Parameters
|
560 |
+
----------
|
561 |
+
x : array_like
|
562 |
+
The input array.
|
563 |
+
type : {1, 2, 3, 4}, optional
|
564 |
+
Type of the DST (see Notes). Default type is 2.
|
565 |
+
n : int, optional
|
566 |
+
Length of the transform. If ``n < x.shape[axis]``, `x` is
|
567 |
+
truncated. If ``n > x.shape[axis]``, `x` is zero-padded. The
|
568 |
+
default results in ``n = x.shape[axis]``.
|
569 |
+
axis : int, optional
|
570 |
+
Axis along which the idst is computed; the default is over the
|
571 |
+
last axis (i.e., ``axis=-1``).
|
572 |
+
norm : {None, 'ortho'}, optional
|
573 |
+
Normalization mode (see Notes). Default is None.
|
574 |
+
overwrite_x : bool, optional
|
575 |
+
If True, the contents of `x` can be destroyed; the default is False.
|
576 |
+
|
577 |
+
Returns
|
578 |
+
-------
|
579 |
+
idst : ndarray of real
|
580 |
+
The transformed input array.
|
581 |
+
|
582 |
+
See Also
|
583 |
+
--------
|
584 |
+
dst : Forward DST
|
585 |
+
|
586 |
+
Notes
|
587 |
+
-----
|
588 |
+
'The' IDST is the IDST of type 2, which is the same as DST of type 3.
|
589 |
+
|
590 |
+
IDST of type 1 is the DST of type 1, IDST of type 2 is the DST of type
|
591 |
+
3, and IDST of type 3 is the DST of type 2. For the definition of these
|
592 |
+
types, see `dst`.
|
593 |
+
|
594 |
+
.. versionadded:: 0.11.0
|
595 |
+
|
596 |
+
"""
|
597 |
+
type = _inverse_typemap[type]
|
598 |
+
return _pocketfft.dst(x, type, n, axis, norm, overwrite_x)
|
venv/lib/python3.10/site-packages/scipy/fftpack/basic.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is not meant for public use and will be removed in SciPy v2.0.0.
|
2 |
+
# Use the `scipy.fftpack` namespace for importing the functions
|
3 |
+
# included below.
|
4 |
+
|
5 |
+
from scipy._lib.deprecation import _sub_module_deprecation
|
6 |
+
|
7 |
+
__all__ = [ # noqa: F822
|
8 |
+
'fft','ifft','fftn','ifftn','rfft','irfft',
|
9 |
+
'fft2','ifft2'
|
10 |
+
]
|
11 |
+
|
12 |
+
|
13 |
+
def __dir__():
|
14 |
+
return __all__
|
15 |
+
|
16 |
+
|
17 |
+
def __getattr__(name):
|
18 |
+
return _sub_module_deprecation(sub_package="fftpack", module="basic",
|
19 |
+
private_modules=["_basic"], all=__all__,
|
20 |
+
attribute=name)
|
venv/lib/python3.10/site-packages/scipy/fftpack/convolve.cpython-310-x86_64-linux-gnu.so
ADDED
Binary file (273 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/helper.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is not meant for public use and will be removed in SciPy v2.0.0.
|
2 |
+
# Use the `scipy.fftpack` namespace for importing the functions
|
3 |
+
# included below.
|
4 |
+
|
5 |
+
from scipy._lib.deprecation import _sub_module_deprecation
|
6 |
+
|
7 |
+
__all__ = [ # noqa: F822
|
8 |
+
'fftshift', 'ifftshift', 'fftfreq', 'rfftfreq', 'next_fast_len'
|
9 |
+
]
|
10 |
+
|
11 |
+
|
12 |
+
def __dir__():
|
13 |
+
return __all__
|
14 |
+
|
15 |
+
|
16 |
+
def __getattr__(name):
|
17 |
+
return _sub_module_deprecation(sub_package="fftpack", module="helper",
|
18 |
+
private_modules=["_helper"], all=__all__,
|
19 |
+
attribute=name)
|
venv/lib/python3.10/site-packages/scipy/fftpack/pseudo_diffs.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is not meant for public use and will be removed in SciPy v2.0.0.
|
2 |
+
# Use the `scipy.fftpack` namespace for importing the functions
|
3 |
+
# included below.
|
4 |
+
|
5 |
+
from scipy._lib.deprecation import _sub_module_deprecation
|
6 |
+
|
7 |
+
__all__ = [ # noqa: F822
|
8 |
+
'diff',
|
9 |
+
'tilbert', 'itilbert', 'hilbert', 'ihilbert',
|
10 |
+
'cs_diff', 'cc_diff', 'sc_diff', 'ss_diff',
|
11 |
+
'shift', 'iscomplexobj', 'convolve'
|
12 |
+
]
|
13 |
+
|
14 |
+
|
15 |
+
def __dir__():
|
16 |
+
return __all__
|
17 |
+
|
18 |
+
|
19 |
+
def __getattr__(name):
|
20 |
+
return _sub_module_deprecation(sub_package="fftpack", module="pseudo_diffs",
|
21 |
+
private_modules=["_pseudo_diffs"], all=__all__,
|
22 |
+
attribute=name)
|
venv/lib/python3.10/site-packages/scipy/fftpack/realtransforms.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is not meant for public use and will be removed in SciPy v2.0.0.
|
2 |
+
# Use the `scipy.fftpack` namespace for importing the functions
|
3 |
+
# included below.
|
4 |
+
|
5 |
+
from scipy._lib.deprecation import _sub_module_deprecation
|
6 |
+
|
7 |
+
__all__ = [ # noqa: F822
|
8 |
+
'dct', 'idct', 'dst', 'idst', 'dctn', 'idctn', 'dstn', 'idstn'
|
9 |
+
]
|
10 |
+
|
11 |
+
|
12 |
+
def __dir__():
|
13 |
+
return __all__
|
14 |
+
|
15 |
+
|
16 |
+
def __getattr__(name):
|
17 |
+
return _sub_module_deprecation(sub_package="fftpack", module="realtransforms",
|
18 |
+
private_modules=["_realtransforms"], all=__all__,
|
19 |
+
attribute=name)
|
venv/lib/python3.10/site-packages/scipy/fftpack/tests/__init__.py
ADDED
File without changes
|
venv/lib/python3.10/site-packages/scipy/fftpack/tests/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (187 Bytes). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/tests/__pycache__/test_helper.cpython-310.pyc
ADDED
Binary file (2.23 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/tests/__pycache__/test_pseudo_diffs.cpython-310.pyc
ADDED
Binary file (13.1 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/fftpack/tests/test_basic.py
ADDED
@@ -0,0 +1,873 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Created by Pearu Peterson, September 2002
|
2 |
+
|
3 |
+
from numpy.testing import (assert_, assert_equal, assert_array_almost_equal,
|
4 |
+
assert_array_almost_equal_nulp, assert_array_less)
|
5 |
+
import pytest
|
6 |
+
from pytest import raises as assert_raises
|
7 |
+
from scipy.fftpack import ifft, fft, fftn, ifftn, rfft, irfft, fft2
|
8 |
+
|
9 |
+
from numpy import (arange, array, asarray, zeros, dot, exp, pi,
|
10 |
+
swapaxes, double, cdouble)
|
11 |
+
import numpy as np
|
12 |
+
import numpy.fft
|
13 |
+
from numpy.random import rand
|
14 |
+
|
15 |
+
# "large" composite numbers supported by FFTPACK
|
16 |
+
LARGE_COMPOSITE_SIZES = [
|
17 |
+
2**13,
|
18 |
+
2**5 * 3**5,
|
19 |
+
2**3 * 3**3 * 5**2,
|
20 |
+
]
|
21 |
+
SMALL_COMPOSITE_SIZES = [
|
22 |
+
2,
|
23 |
+
2*3*5,
|
24 |
+
2*2*3*3,
|
25 |
+
]
|
26 |
+
# prime
|
27 |
+
LARGE_PRIME_SIZES = [
|
28 |
+
2011
|
29 |
+
]
|
30 |
+
SMALL_PRIME_SIZES = [
|
31 |
+
29
|
32 |
+
]
|
33 |
+
|
34 |
+
|
35 |
+
def _assert_close_in_norm(x, y, rtol, size, rdt):
|
36 |
+
# helper function for testing
|
37 |
+
err_msg = f"size: {size} rdt: {rdt}"
|
38 |
+
assert_array_less(np.linalg.norm(x - y), rtol*np.linalg.norm(x), err_msg)
|
39 |
+
|
40 |
+
|
41 |
+
def random(size):
|
42 |
+
return rand(*size)
|
43 |
+
|
44 |
+
|
45 |
+
def direct_dft(x):
|
46 |
+
x = asarray(x)
|
47 |
+
n = len(x)
|
48 |
+
y = zeros(n, dtype=cdouble)
|
49 |
+
w = -arange(n)*(2j*pi/n)
|
50 |
+
for i in range(n):
|
51 |
+
y[i] = dot(exp(i*w), x)
|
52 |
+
return y
|
53 |
+
|
54 |
+
|
55 |
+
def direct_idft(x):
|
56 |
+
x = asarray(x)
|
57 |
+
n = len(x)
|
58 |
+
y = zeros(n, dtype=cdouble)
|
59 |
+
w = arange(n)*(2j*pi/n)
|
60 |
+
for i in range(n):
|
61 |
+
y[i] = dot(exp(i*w), x)/n
|
62 |
+
return y
|
63 |
+
|
64 |
+
|
65 |
+
def direct_dftn(x):
|
66 |
+
x = asarray(x)
|
67 |
+
for axis in range(len(x.shape)):
|
68 |
+
x = fft(x, axis=axis)
|
69 |
+
return x
|
70 |
+
|
71 |
+
|
72 |
+
def direct_idftn(x):
|
73 |
+
x = asarray(x)
|
74 |
+
for axis in range(len(x.shape)):
|
75 |
+
x = ifft(x, axis=axis)
|
76 |
+
return x
|
77 |
+
|
78 |
+
|
79 |
+
def direct_rdft(x):
|
80 |
+
x = asarray(x)
|
81 |
+
n = len(x)
|
82 |
+
w = -arange(n)*(2j*pi/n)
|
83 |
+
r = zeros(n, dtype=double)
|
84 |
+
for i in range(n//2+1):
|
85 |
+
y = dot(exp(i*w), x)
|
86 |
+
if i:
|
87 |
+
r[2*i-1] = y.real
|
88 |
+
if 2*i < n:
|
89 |
+
r[2*i] = y.imag
|
90 |
+
else:
|
91 |
+
r[0] = y.real
|
92 |
+
return r
|
93 |
+
|
94 |
+
|
95 |
+
def direct_irdft(x):
|
96 |
+
x = asarray(x)
|
97 |
+
n = len(x)
|
98 |
+
x1 = zeros(n, dtype=cdouble)
|
99 |
+
for i in range(n//2+1):
|
100 |
+
if i:
|
101 |
+
if 2*i < n:
|
102 |
+
x1[i] = x[2*i-1] + 1j*x[2*i]
|
103 |
+
x1[n-i] = x[2*i-1] - 1j*x[2*i]
|
104 |
+
else:
|
105 |
+
x1[i] = x[2*i-1]
|
106 |
+
else:
|
107 |
+
x1[0] = x[0]
|
108 |
+
return direct_idft(x1).real
|
109 |
+
|
110 |
+
|
111 |
+
class _TestFFTBase:
|
112 |
+
def setup_method(self):
|
113 |
+
self.cdt = None
|
114 |
+
self.rdt = None
|
115 |
+
np.random.seed(1234)
|
116 |
+
|
117 |
+
def test_definition(self):
|
118 |
+
x = np.array([1,2,3,4+1j,1,2,3,4+2j], dtype=self.cdt)
|
119 |
+
y = fft(x)
|
120 |
+
assert_equal(y.dtype, self.cdt)
|
121 |
+
y1 = direct_dft(x)
|
122 |
+
assert_array_almost_equal(y,y1)
|
123 |
+
x = np.array([1,2,3,4+0j,5], dtype=self.cdt)
|
124 |
+
assert_array_almost_equal(fft(x),direct_dft(x))
|
125 |
+
|
126 |
+
def test_n_argument_real(self):
|
127 |
+
x1 = np.array([1,2,3,4], dtype=self.rdt)
|
128 |
+
x2 = np.array([1,2,3,4], dtype=self.rdt)
|
129 |
+
y = fft([x1,x2],n=4)
|
130 |
+
assert_equal(y.dtype, self.cdt)
|
131 |
+
assert_equal(y.shape,(2,4))
|
132 |
+
assert_array_almost_equal(y[0],direct_dft(x1))
|
133 |
+
assert_array_almost_equal(y[1],direct_dft(x2))
|
134 |
+
|
135 |
+
def _test_n_argument_complex(self):
|
136 |
+
x1 = np.array([1,2,3,4+1j], dtype=self.cdt)
|
137 |
+
x2 = np.array([1,2,3,4+1j], dtype=self.cdt)
|
138 |
+
y = fft([x1,x2],n=4)
|
139 |
+
assert_equal(y.dtype, self.cdt)
|
140 |
+
assert_equal(y.shape,(2,4))
|
141 |
+
assert_array_almost_equal(y[0],direct_dft(x1))
|
142 |
+
assert_array_almost_equal(y[1],direct_dft(x2))
|
143 |
+
|
144 |
+
def test_invalid_sizes(self):
|
145 |
+
assert_raises(ValueError, fft, [])
|
146 |
+
assert_raises(ValueError, fft, [[1,1],[2,2]], -5)
|
147 |
+
|
148 |
+
|
149 |
+
class TestDoubleFFT(_TestFFTBase):
|
150 |
+
def setup_method(self):
|
151 |
+
self.cdt = np.complex128
|
152 |
+
self.rdt = np.float64
|
153 |
+
|
154 |
+
|
155 |
+
class TestSingleFFT(_TestFFTBase):
|
156 |
+
def setup_method(self):
|
157 |
+
self.cdt = np.complex64
|
158 |
+
self.rdt = np.float32
|
159 |
+
|
160 |
+
reason = ("single-precision FFT implementation is partially disabled, "
|
161 |
+
"until accuracy issues with large prime powers are resolved")
|
162 |
+
|
163 |
+
@pytest.mark.xfail(run=False, reason=reason)
|
164 |
+
def test_notice(self):
|
165 |
+
pass
|
166 |
+
|
167 |
+
|
168 |
+
class TestFloat16FFT:
|
169 |
+
|
170 |
+
def test_1_argument_real(self):
|
171 |
+
x1 = np.array([1, 2, 3, 4], dtype=np.float16)
|
172 |
+
y = fft(x1, n=4)
|
173 |
+
assert_equal(y.dtype, np.complex64)
|
174 |
+
assert_equal(y.shape, (4, ))
|
175 |
+
assert_array_almost_equal(y, direct_dft(x1.astype(np.float32)))
|
176 |
+
|
177 |
+
def test_n_argument_real(self):
|
178 |
+
x1 = np.array([1, 2, 3, 4], dtype=np.float16)
|
179 |
+
x2 = np.array([1, 2, 3, 4], dtype=np.float16)
|
180 |
+
y = fft([x1, x2], n=4)
|
181 |
+
assert_equal(y.dtype, np.complex64)
|
182 |
+
assert_equal(y.shape, (2, 4))
|
183 |
+
assert_array_almost_equal(y[0], direct_dft(x1.astype(np.float32)))
|
184 |
+
assert_array_almost_equal(y[1], direct_dft(x2.astype(np.float32)))
|
185 |
+
|
186 |
+
|
187 |
+
class _TestIFFTBase:
|
188 |
+
def setup_method(self):
|
189 |
+
np.random.seed(1234)
|
190 |
+
|
191 |
+
def test_definition(self):
|
192 |
+
x = np.array([1,2,3,4+1j,1,2,3,4+2j], self.cdt)
|
193 |
+
y = ifft(x)
|
194 |
+
y1 = direct_idft(x)
|
195 |
+
assert_equal(y.dtype, self.cdt)
|
196 |
+
assert_array_almost_equal(y,y1)
|
197 |
+
|
198 |
+
x = np.array([1,2,3,4+0j,5], self.cdt)
|
199 |
+
assert_array_almost_equal(ifft(x),direct_idft(x))
|
200 |
+
|
201 |
+
def test_definition_real(self):
|
202 |
+
x = np.array([1,2,3,4,1,2,3,4], self.rdt)
|
203 |
+
y = ifft(x)
|
204 |
+
assert_equal(y.dtype, self.cdt)
|
205 |
+
y1 = direct_idft(x)
|
206 |
+
assert_array_almost_equal(y,y1)
|
207 |
+
|
208 |
+
x = np.array([1,2,3,4,5], dtype=self.rdt)
|
209 |
+
assert_equal(y.dtype, self.cdt)
|
210 |
+
assert_array_almost_equal(ifft(x),direct_idft(x))
|
211 |
+
|
212 |
+
def test_random_complex(self):
|
213 |
+
for size in [1,51,111,100,200,64,128,256,1024]:
|
214 |
+
x = random([size]).astype(self.cdt)
|
215 |
+
x = random([size]).astype(self.cdt) + 1j*x
|
216 |
+
y1 = ifft(fft(x))
|
217 |
+
y2 = fft(ifft(x))
|
218 |
+
assert_equal(y1.dtype, self.cdt)
|
219 |
+
assert_equal(y2.dtype, self.cdt)
|
220 |
+
assert_array_almost_equal(y1, x)
|
221 |
+
assert_array_almost_equal(y2, x)
|
222 |
+
|
223 |
+
def test_random_real(self):
|
224 |
+
for size in [1,51,111,100,200,64,128,256,1024]:
|
225 |
+
x = random([size]).astype(self.rdt)
|
226 |
+
y1 = ifft(fft(x))
|
227 |
+
y2 = fft(ifft(x))
|
228 |
+
assert_equal(y1.dtype, self.cdt)
|
229 |
+
assert_equal(y2.dtype, self.cdt)
|
230 |
+
assert_array_almost_equal(y1, x)
|
231 |
+
assert_array_almost_equal(y2, x)
|
232 |
+
|
233 |
+
def test_size_accuracy(self):
|
234 |
+
# Sanity check for the accuracy for prime and non-prime sized inputs
|
235 |
+
if self.rdt == np.float32:
|
236 |
+
rtol = 1e-5
|
237 |
+
elif self.rdt == np.float64:
|
238 |
+
rtol = 1e-10
|
239 |
+
|
240 |
+
for size in LARGE_COMPOSITE_SIZES + LARGE_PRIME_SIZES:
|
241 |
+
np.random.seed(1234)
|
242 |
+
x = np.random.rand(size).astype(self.rdt)
|
243 |
+
y = ifft(fft(x))
|
244 |
+
_assert_close_in_norm(x, y, rtol, size, self.rdt)
|
245 |
+
y = fft(ifft(x))
|
246 |
+
_assert_close_in_norm(x, y, rtol, size, self.rdt)
|
247 |
+
|
248 |
+
x = (x + 1j*np.random.rand(size)).astype(self.cdt)
|
249 |
+
y = ifft(fft(x))
|
250 |
+
_assert_close_in_norm(x, y, rtol, size, self.rdt)
|
251 |
+
y = fft(ifft(x))
|
252 |
+
_assert_close_in_norm(x, y, rtol, size, self.rdt)
|
253 |
+
|
254 |
+
def test_invalid_sizes(self):
|
255 |
+
assert_raises(ValueError, ifft, [])
|
256 |
+
assert_raises(ValueError, ifft, [[1,1],[2,2]], -5)
|
257 |
+
|
258 |
+
|
259 |
+
class TestDoubleIFFT(_TestIFFTBase):
|
260 |
+
def setup_method(self):
|
261 |
+
self.cdt = np.complex128
|
262 |
+
self.rdt = np.float64
|
263 |
+
|
264 |
+
|
265 |
+
class TestSingleIFFT(_TestIFFTBase):
|
266 |
+
def setup_method(self):
|
267 |
+
self.cdt = np.complex64
|
268 |
+
self.rdt = np.float32
|
269 |
+
|
270 |
+
|
271 |
+
class _TestRFFTBase:
|
272 |
+
def setup_method(self):
|
273 |
+
np.random.seed(1234)
|
274 |
+
|
275 |
+
def test_definition(self):
|
276 |
+
for t in [[1, 2, 3, 4, 1, 2, 3, 4], [1, 2, 3, 4, 1, 2, 3, 4, 5]]:
|
277 |
+
x = np.array(t, dtype=self.rdt)
|
278 |
+
y = rfft(x)
|
279 |
+
y1 = direct_rdft(x)
|
280 |
+
assert_array_almost_equal(y,y1)
|
281 |
+
assert_equal(y.dtype, self.rdt)
|
282 |
+
|
283 |
+
def test_invalid_sizes(self):
|
284 |
+
assert_raises(ValueError, rfft, [])
|
285 |
+
assert_raises(ValueError, rfft, [[1,1],[2,2]], -5)
|
286 |
+
|
287 |
+
# See gh-5790
|
288 |
+
class MockSeries:
|
289 |
+
def __init__(self, data):
|
290 |
+
self.data = np.asarray(data)
|
291 |
+
|
292 |
+
def __getattr__(self, item):
|
293 |
+
try:
|
294 |
+
return getattr(self.data, item)
|
295 |
+
except AttributeError as e:
|
296 |
+
raise AttributeError("'MockSeries' object "
|
297 |
+
f"has no attribute '{item}'") from e
|
298 |
+
|
299 |
+
def test_non_ndarray_with_dtype(self):
|
300 |
+
x = np.array([1., 2., 3., 4., 5.])
|
301 |
+
xs = _TestRFFTBase.MockSeries(x)
|
302 |
+
|
303 |
+
expected = [1, 2, 3, 4, 5]
|
304 |
+
rfft(xs)
|
305 |
+
|
306 |
+
# Data should not have been overwritten
|
307 |
+
assert_equal(x, expected)
|
308 |
+
assert_equal(xs.data, expected)
|
309 |
+
|
310 |
+
def test_complex_input(self):
|
311 |
+
assert_raises(TypeError, rfft, np.arange(4, dtype=np.complex64))
|
312 |
+
|
313 |
+
|
314 |
+
class TestRFFTDouble(_TestRFFTBase):
|
315 |
+
def setup_method(self):
|
316 |
+
self.cdt = np.complex128
|
317 |
+
self.rdt = np.float64
|
318 |
+
|
319 |
+
|
320 |
+
class TestRFFTSingle(_TestRFFTBase):
|
321 |
+
def setup_method(self):
|
322 |
+
self.cdt = np.complex64
|
323 |
+
self.rdt = np.float32
|
324 |
+
|
325 |
+
|
326 |
+
class _TestIRFFTBase:
|
327 |
+
def setup_method(self):
|
328 |
+
np.random.seed(1234)
|
329 |
+
|
330 |
+
def test_definition(self):
|
331 |
+
x1 = [1,2,3,4,1,2,3,4]
|
332 |
+
x1_1 = [1,2+3j,4+1j,2+3j,4,2-3j,4-1j,2-3j]
|
333 |
+
x2 = [1,2,3,4,1,2,3,4,5]
|
334 |
+
x2_1 = [1,2+3j,4+1j,2+3j,4+5j,4-5j,2-3j,4-1j,2-3j]
|
335 |
+
|
336 |
+
def _test(x, xr):
|
337 |
+
y = irfft(np.array(x, dtype=self.rdt))
|
338 |
+
y1 = direct_irdft(x)
|
339 |
+
assert_equal(y.dtype, self.rdt)
|
340 |
+
assert_array_almost_equal(y,y1, decimal=self.ndec)
|
341 |
+
assert_array_almost_equal(y,ifft(xr), decimal=self.ndec)
|
342 |
+
|
343 |
+
_test(x1, x1_1)
|
344 |
+
_test(x2, x2_1)
|
345 |
+
|
346 |
+
def test_random_real(self):
|
347 |
+
for size in [1,51,111,100,200,64,128,256,1024]:
|
348 |
+
x = random([size]).astype(self.rdt)
|
349 |
+
y1 = irfft(rfft(x))
|
350 |
+
y2 = rfft(irfft(x))
|
351 |
+
assert_equal(y1.dtype, self.rdt)
|
352 |
+
assert_equal(y2.dtype, self.rdt)
|
353 |
+
assert_array_almost_equal(y1, x, decimal=self.ndec,
|
354 |
+
err_msg="size=%d" % size)
|
355 |
+
assert_array_almost_equal(y2, x, decimal=self.ndec,
|
356 |
+
err_msg="size=%d" % size)
|
357 |
+
|
358 |
+
def test_size_accuracy(self):
|
359 |
+
# Sanity check for the accuracy for prime and non-prime sized inputs
|
360 |
+
if self.rdt == np.float32:
|
361 |
+
rtol = 1e-5
|
362 |
+
elif self.rdt == np.float64:
|
363 |
+
rtol = 1e-10
|
364 |
+
|
365 |
+
for size in LARGE_COMPOSITE_SIZES + LARGE_PRIME_SIZES:
|
366 |
+
np.random.seed(1234)
|
367 |
+
x = np.random.rand(size).astype(self.rdt)
|
368 |
+
y = irfft(rfft(x))
|
369 |
+
_assert_close_in_norm(x, y, rtol, size, self.rdt)
|
370 |
+
y = rfft(irfft(x))
|
371 |
+
_assert_close_in_norm(x, y, rtol, size, self.rdt)
|
372 |
+
|
373 |
+
def test_invalid_sizes(self):
|
374 |
+
assert_raises(ValueError, irfft, [])
|
375 |
+
assert_raises(ValueError, irfft, [[1,1],[2,2]], -5)
|
376 |
+
|
377 |
+
def test_complex_input(self):
|
378 |
+
assert_raises(TypeError, irfft, np.arange(4, dtype=np.complex64))
|
379 |
+
|
380 |
+
|
381 |
+
# self.ndec is bogus; we should have a assert_array_approx_equal for number of
|
382 |
+
# significant digits
|
383 |
+
|
384 |
+
class TestIRFFTDouble(_TestIRFFTBase):
|
385 |
+
def setup_method(self):
|
386 |
+
self.cdt = np.complex128
|
387 |
+
self.rdt = np.float64
|
388 |
+
self.ndec = 14
|
389 |
+
|
390 |
+
|
391 |
+
class TestIRFFTSingle(_TestIRFFTBase):
|
392 |
+
def setup_method(self):
|
393 |
+
self.cdt = np.complex64
|
394 |
+
self.rdt = np.float32
|
395 |
+
self.ndec = 5
|
396 |
+
|
397 |
+
|
398 |
+
class Testfft2:
|
399 |
+
def setup_method(self):
|
400 |
+
np.random.seed(1234)
|
401 |
+
|
402 |
+
def test_regression_244(self):
|
403 |
+
"""FFT returns wrong result with axes parameter."""
|
404 |
+
# fftn (and hence fft2) used to break when both axes and shape were
|
405 |
+
# used
|
406 |
+
x = numpy.ones((4, 4, 2))
|
407 |
+
y = fft2(x, shape=(8, 8), axes=(-3, -2))
|
408 |
+
y_r = numpy.fft.fftn(x, s=(8, 8), axes=(-3, -2))
|
409 |
+
assert_array_almost_equal(y, y_r)
|
410 |
+
|
411 |
+
def test_invalid_sizes(self):
|
412 |
+
assert_raises(ValueError, fft2, [[]])
|
413 |
+
assert_raises(ValueError, fft2, [[1, 1], [2, 2]], (4, -3))
|
414 |
+
|
415 |
+
|
416 |
+
class TestFftnSingle:
|
417 |
+
def setup_method(self):
|
418 |
+
np.random.seed(1234)
|
419 |
+
|
420 |
+
def test_definition(self):
|
421 |
+
x = [[1, 2, 3],
|
422 |
+
[4, 5, 6],
|
423 |
+
[7, 8, 9]]
|
424 |
+
y = fftn(np.array(x, np.float32))
|
425 |
+
assert_(y.dtype == np.complex64,
|
426 |
+
msg="double precision output with single precision")
|
427 |
+
|
428 |
+
y_r = np.array(fftn(x), np.complex64)
|
429 |
+
assert_array_almost_equal_nulp(y, y_r)
|
430 |
+
|
431 |
+
@pytest.mark.parametrize('size', SMALL_COMPOSITE_SIZES + SMALL_PRIME_SIZES)
|
432 |
+
def test_size_accuracy_small(self, size):
|
433 |
+
x = np.random.rand(size, size) + 1j*np.random.rand(size, size)
|
434 |
+
y1 = fftn(x.real.astype(np.float32))
|
435 |
+
y2 = fftn(x.real.astype(np.float64)).astype(np.complex64)
|
436 |
+
|
437 |
+
assert_equal(y1.dtype, np.complex64)
|
438 |
+
assert_array_almost_equal_nulp(y1, y2, 2000)
|
439 |
+
|
440 |
+
@pytest.mark.parametrize('size', LARGE_COMPOSITE_SIZES + LARGE_PRIME_SIZES)
|
441 |
+
def test_size_accuracy_large(self, size):
|
442 |
+
x = np.random.rand(size, 3) + 1j*np.random.rand(size, 3)
|
443 |
+
y1 = fftn(x.real.astype(np.float32))
|
444 |
+
y2 = fftn(x.real.astype(np.float64)).astype(np.complex64)
|
445 |
+
|
446 |
+
assert_equal(y1.dtype, np.complex64)
|
447 |
+
assert_array_almost_equal_nulp(y1, y2, 2000)
|
448 |
+
|
449 |
+
def test_definition_float16(self):
|
450 |
+
x = [[1, 2, 3],
|
451 |
+
[4, 5, 6],
|
452 |
+
[7, 8, 9]]
|
453 |
+
y = fftn(np.array(x, np.float16))
|
454 |
+
assert_equal(y.dtype, np.complex64)
|
455 |
+
y_r = np.array(fftn(x), np.complex64)
|
456 |
+
assert_array_almost_equal_nulp(y, y_r)
|
457 |
+
|
458 |
+
@pytest.mark.parametrize('size', SMALL_COMPOSITE_SIZES + SMALL_PRIME_SIZES)
|
459 |
+
def test_float16_input_small(self, size):
|
460 |
+
x = np.random.rand(size, size) + 1j*np.random.rand(size, size)
|
461 |
+
y1 = fftn(x.real.astype(np.float16))
|
462 |
+
y2 = fftn(x.real.astype(np.float64)).astype(np.complex64)
|
463 |
+
|
464 |
+
assert_equal(y1.dtype, np.complex64)
|
465 |
+
assert_array_almost_equal_nulp(y1, y2, 5e5)
|
466 |
+
|
467 |
+
@pytest.mark.parametrize('size', LARGE_COMPOSITE_SIZES + LARGE_PRIME_SIZES)
|
468 |
+
def test_float16_input_large(self, size):
|
469 |
+
x = np.random.rand(size, 3) + 1j*np.random.rand(size, 3)
|
470 |
+
y1 = fftn(x.real.astype(np.float16))
|
471 |
+
y2 = fftn(x.real.astype(np.float64)).astype(np.complex64)
|
472 |
+
|
473 |
+
assert_equal(y1.dtype, np.complex64)
|
474 |
+
assert_array_almost_equal_nulp(y1, y2, 2e6)
|
475 |
+
|
476 |
+
|
477 |
+
class TestFftn:
|
478 |
+
def setup_method(self):
|
479 |
+
np.random.seed(1234)
|
480 |
+
|
481 |
+
def test_definition(self):
|
482 |
+
x = [[1, 2, 3],
|
483 |
+
[4, 5, 6],
|
484 |
+
[7, 8, 9]]
|
485 |
+
y = fftn(x)
|
486 |
+
assert_array_almost_equal(y, direct_dftn(x))
|
487 |
+
|
488 |
+
x = random((20, 26))
|
489 |
+
assert_array_almost_equal(fftn(x), direct_dftn(x))
|
490 |
+
|
491 |
+
x = random((5, 4, 3, 20))
|
492 |
+
assert_array_almost_equal(fftn(x), direct_dftn(x))
|
493 |
+
|
494 |
+
def test_axes_argument(self):
|
495 |
+
# plane == ji_plane, x== kji_space
|
496 |
+
plane1 = [[1, 2, 3],
|
497 |
+
[4, 5, 6],
|
498 |
+
[7, 8, 9]]
|
499 |
+
plane2 = [[10, 11, 12],
|
500 |
+
[13, 14, 15],
|
501 |
+
[16, 17, 18]]
|
502 |
+
plane3 = [[19, 20, 21],
|
503 |
+
[22, 23, 24],
|
504 |
+
[25, 26, 27]]
|
505 |
+
ki_plane1 = [[1, 2, 3],
|
506 |
+
[10, 11, 12],
|
507 |
+
[19, 20, 21]]
|
508 |
+
ki_plane2 = [[4, 5, 6],
|
509 |
+
[13, 14, 15],
|
510 |
+
[22, 23, 24]]
|
511 |
+
ki_plane3 = [[7, 8, 9],
|
512 |
+
[16, 17, 18],
|
513 |
+
[25, 26, 27]]
|
514 |
+
jk_plane1 = [[1, 10, 19],
|
515 |
+
[4, 13, 22],
|
516 |
+
[7, 16, 25]]
|
517 |
+
jk_plane2 = [[2, 11, 20],
|
518 |
+
[5, 14, 23],
|
519 |
+
[8, 17, 26]]
|
520 |
+
jk_plane3 = [[3, 12, 21],
|
521 |
+
[6, 15, 24],
|
522 |
+
[9, 18, 27]]
|
523 |
+
kj_plane1 = [[1, 4, 7],
|
524 |
+
[10, 13, 16], [19, 22, 25]]
|
525 |
+
kj_plane2 = [[2, 5, 8],
|
526 |
+
[11, 14, 17], [20, 23, 26]]
|
527 |
+
kj_plane3 = [[3, 6, 9],
|
528 |
+
[12, 15, 18], [21, 24, 27]]
|
529 |
+
ij_plane1 = [[1, 4, 7],
|
530 |
+
[2, 5, 8],
|
531 |
+
[3, 6, 9]]
|
532 |
+
ij_plane2 = [[10, 13, 16],
|
533 |
+
[11, 14, 17],
|
534 |
+
[12, 15, 18]]
|
535 |
+
ij_plane3 = [[19, 22, 25],
|
536 |
+
[20, 23, 26],
|
537 |
+
[21, 24, 27]]
|
538 |
+
ik_plane1 = [[1, 10, 19],
|
539 |
+
[2, 11, 20],
|
540 |
+
[3, 12, 21]]
|
541 |
+
ik_plane2 = [[4, 13, 22],
|
542 |
+
[5, 14, 23],
|
543 |
+
[6, 15, 24]]
|
544 |
+
ik_plane3 = [[7, 16, 25],
|
545 |
+
[8, 17, 26],
|
546 |
+
[9, 18, 27]]
|
547 |
+
ijk_space = [jk_plane1, jk_plane2, jk_plane3]
|
548 |
+
ikj_space = [kj_plane1, kj_plane2, kj_plane3]
|
549 |
+
jik_space = [ik_plane1, ik_plane2, ik_plane3]
|
550 |
+
jki_space = [ki_plane1, ki_plane2, ki_plane3]
|
551 |
+
kij_space = [ij_plane1, ij_plane2, ij_plane3]
|
552 |
+
x = array([plane1, plane2, plane3])
|
553 |
+
|
554 |
+
assert_array_almost_equal(fftn(x),
|
555 |
+
fftn(x, axes=(-3, -2, -1))) # kji_space
|
556 |
+
assert_array_almost_equal(fftn(x), fftn(x, axes=(0, 1, 2)))
|
557 |
+
assert_array_almost_equal(fftn(x, axes=(0, 2)), fftn(x, axes=(0, -1)))
|
558 |
+
y = fftn(x, axes=(2, 1, 0)) # ijk_space
|
559 |
+
assert_array_almost_equal(swapaxes(y, -1, -3), fftn(ijk_space))
|
560 |
+
y = fftn(x, axes=(2, 0, 1)) # ikj_space
|
561 |
+
assert_array_almost_equal(swapaxes(swapaxes(y, -1, -3), -1, -2),
|
562 |
+
fftn(ikj_space))
|
563 |
+
y = fftn(x, axes=(1, 2, 0)) # jik_space
|
564 |
+
assert_array_almost_equal(swapaxes(swapaxes(y, -1, -3), -3, -2),
|
565 |
+
fftn(jik_space))
|
566 |
+
y = fftn(x, axes=(1, 0, 2)) # jki_space
|
567 |
+
assert_array_almost_equal(swapaxes(y, -2, -3), fftn(jki_space))
|
568 |
+
y = fftn(x, axes=(0, 2, 1)) # kij_space
|
569 |
+
assert_array_almost_equal(swapaxes(y, -2, -1), fftn(kij_space))
|
570 |
+
|
571 |
+
y = fftn(x, axes=(-2, -1)) # ji_plane
|
572 |
+
assert_array_almost_equal(fftn(plane1), y[0])
|
573 |
+
assert_array_almost_equal(fftn(plane2), y[1])
|
574 |
+
assert_array_almost_equal(fftn(plane3), y[2])
|
575 |
+
|
576 |
+
y = fftn(x, axes=(1, 2)) # ji_plane
|
577 |
+
assert_array_almost_equal(fftn(plane1), y[0])
|
578 |
+
assert_array_almost_equal(fftn(plane2), y[1])
|
579 |
+
assert_array_almost_equal(fftn(plane3), y[2])
|
580 |
+
|
581 |
+
y = fftn(x, axes=(-3, -2)) # kj_plane
|
582 |
+
assert_array_almost_equal(fftn(x[:, :, 0]), y[:, :, 0])
|
583 |
+
assert_array_almost_equal(fftn(x[:, :, 1]), y[:, :, 1])
|
584 |
+
assert_array_almost_equal(fftn(x[:, :, 2]), y[:, :, 2])
|
585 |
+
|
586 |
+
y = fftn(x, axes=(-3, -1)) # ki_plane
|
587 |
+
assert_array_almost_equal(fftn(x[:, 0, :]), y[:, 0, :])
|
588 |
+
assert_array_almost_equal(fftn(x[:, 1, :]), y[:, 1, :])
|
589 |
+
assert_array_almost_equal(fftn(x[:, 2, :]), y[:, 2, :])
|
590 |
+
|
591 |
+
y = fftn(x, axes=(-1, -2)) # ij_plane
|
592 |
+
assert_array_almost_equal(fftn(ij_plane1), swapaxes(y[0], -2, -1))
|
593 |
+
assert_array_almost_equal(fftn(ij_plane2), swapaxes(y[1], -2, -1))
|
594 |
+
assert_array_almost_equal(fftn(ij_plane3), swapaxes(y[2], -2, -1))
|
595 |
+
|
596 |
+
y = fftn(x, axes=(-1, -3)) # ik_plane
|
597 |
+
assert_array_almost_equal(fftn(ik_plane1),
|
598 |
+
swapaxes(y[:, 0, :], -1, -2))
|
599 |
+
assert_array_almost_equal(fftn(ik_plane2),
|
600 |
+
swapaxes(y[:, 1, :], -1, -2))
|
601 |
+
assert_array_almost_equal(fftn(ik_plane3),
|
602 |
+
swapaxes(y[:, 2, :], -1, -2))
|
603 |
+
|
604 |
+
y = fftn(x, axes=(-2, -3)) # jk_plane
|
605 |
+
assert_array_almost_equal(fftn(jk_plane1),
|
606 |
+
swapaxes(y[:, :, 0], -1, -2))
|
607 |
+
assert_array_almost_equal(fftn(jk_plane2),
|
608 |
+
swapaxes(y[:, :, 1], -1, -2))
|
609 |
+
assert_array_almost_equal(fftn(jk_plane3),
|
610 |
+
swapaxes(y[:, :, 2], -1, -2))
|
611 |
+
|
612 |
+
y = fftn(x, axes=(-1,)) # i_line
|
613 |
+
for i in range(3):
|
614 |
+
for j in range(3):
|
615 |
+
assert_array_almost_equal(fft(x[i, j, :]), y[i, j, :])
|
616 |
+
y = fftn(x, axes=(-2,)) # j_line
|
617 |
+
for i in range(3):
|
618 |
+
for j in range(3):
|
619 |
+
assert_array_almost_equal(fft(x[i, :, j]), y[i, :, j])
|
620 |
+
y = fftn(x, axes=(0,)) # k_line
|
621 |
+
for i in range(3):
|
622 |
+
for j in range(3):
|
623 |
+
assert_array_almost_equal(fft(x[:, i, j]), y[:, i, j])
|
624 |
+
|
625 |
+
y = fftn(x, axes=()) # point
|
626 |
+
assert_array_almost_equal(y, x)
|
627 |
+
|
628 |
+
def test_shape_argument(self):
|
629 |
+
small_x = [[1, 2, 3],
|
630 |
+
[4, 5, 6]]
|
631 |
+
large_x1 = [[1, 2, 3, 0],
|
632 |
+
[4, 5, 6, 0],
|
633 |
+
[0, 0, 0, 0],
|
634 |
+
[0, 0, 0, 0]]
|
635 |
+
|
636 |
+
y = fftn(small_x, shape=(4, 4))
|
637 |
+
assert_array_almost_equal(y, fftn(large_x1))
|
638 |
+
|
639 |
+
y = fftn(small_x, shape=(3, 4))
|
640 |
+
assert_array_almost_equal(y, fftn(large_x1[:-1]))
|
641 |
+
|
642 |
+
def test_shape_axes_argument(self):
|
643 |
+
small_x = [[1, 2, 3],
|
644 |
+
[4, 5, 6],
|
645 |
+
[7, 8, 9]]
|
646 |
+
large_x1 = array([[1, 2, 3, 0],
|
647 |
+
[4, 5, 6, 0],
|
648 |
+
[7, 8, 9, 0],
|
649 |
+
[0, 0, 0, 0]])
|
650 |
+
y = fftn(small_x, shape=(4, 4), axes=(-2, -1))
|
651 |
+
assert_array_almost_equal(y, fftn(large_x1))
|
652 |
+
y = fftn(small_x, shape=(4, 4), axes=(-1, -2))
|
653 |
+
|
654 |
+
assert_array_almost_equal(y, swapaxes(
|
655 |
+
fftn(swapaxes(large_x1, -1, -2)), -1, -2))
|
656 |
+
|
657 |
+
def test_shape_axes_argument2(self):
|
658 |
+
# Change shape of the last axis
|
659 |
+
x = numpy.random.random((10, 5, 3, 7))
|
660 |
+
y = fftn(x, axes=(-1,), shape=(8,))
|
661 |
+
assert_array_almost_equal(y, fft(x, axis=-1, n=8))
|
662 |
+
|
663 |
+
# Change shape of an arbitrary axis which is not the last one
|
664 |
+
x = numpy.random.random((10, 5, 3, 7))
|
665 |
+
y = fftn(x, axes=(-2,), shape=(8,))
|
666 |
+
assert_array_almost_equal(y, fft(x, axis=-2, n=8))
|
667 |
+
|
668 |
+
# Change shape of axes: cf #244, where shape and axes were mixed up
|
669 |
+
x = numpy.random.random((4, 4, 2))
|
670 |
+
y = fftn(x, axes=(-3, -2), shape=(8, 8))
|
671 |
+
assert_array_almost_equal(y,
|
672 |
+
numpy.fft.fftn(x, axes=(-3, -2), s=(8, 8)))
|
673 |
+
|
674 |
+
def test_shape_argument_more(self):
|
675 |
+
x = zeros((4, 4, 2))
|
676 |
+
with assert_raises(ValueError,
|
677 |
+
match="when given, axes and shape arguments"
|
678 |
+
" have to be of the same length"):
|
679 |
+
fftn(x, shape=(8, 8, 2, 1))
|
680 |
+
|
681 |
+
def test_invalid_sizes(self):
|
682 |
+
with assert_raises(ValueError,
|
683 |
+
match="invalid number of data points"
|
684 |
+
r" \(\[1, 0\]\) specified"):
|
685 |
+
fftn([[]])
|
686 |
+
|
687 |
+
with assert_raises(ValueError,
|
688 |
+
match="invalid number of data points"
|
689 |
+
r" \(\[4, -3\]\) specified"):
|
690 |
+
fftn([[1, 1], [2, 2]], (4, -3))
|
691 |
+
|
692 |
+
|
693 |
+
class TestIfftn:
|
694 |
+
dtype = None
|
695 |
+
cdtype = None
|
696 |
+
|
697 |
+
def setup_method(self):
|
698 |
+
np.random.seed(1234)
|
699 |
+
|
700 |
+
@pytest.mark.parametrize('dtype,cdtype,maxnlp',
|
701 |
+
[(np.float64, np.complex128, 2000),
|
702 |
+
(np.float32, np.complex64, 3500)])
|
703 |
+
def test_definition(self, dtype, cdtype, maxnlp):
|
704 |
+
x = np.array([[1, 2, 3],
|
705 |
+
[4, 5, 6],
|
706 |
+
[7, 8, 9]], dtype=dtype)
|
707 |
+
y = ifftn(x)
|
708 |
+
assert_equal(y.dtype, cdtype)
|
709 |
+
assert_array_almost_equal_nulp(y, direct_idftn(x), maxnlp)
|
710 |
+
|
711 |
+
x = random((20, 26))
|
712 |
+
assert_array_almost_equal_nulp(ifftn(x), direct_idftn(x), maxnlp)
|
713 |
+
|
714 |
+
x = random((5, 4, 3, 20))
|
715 |
+
assert_array_almost_equal_nulp(ifftn(x), direct_idftn(x), maxnlp)
|
716 |
+
|
717 |
+
@pytest.mark.parametrize('maxnlp', [2000, 3500])
|
718 |
+
@pytest.mark.parametrize('size', [1, 2, 51, 32, 64, 92])
|
719 |
+
def test_random_complex(self, maxnlp, size):
|
720 |
+
x = random([size, size]) + 1j*random([size, size])
|
721 |
+
assert_array_almost_equal_nulp(ifftn(fftn(x)), x, maxnlp)
|
722 |
+
assert_array_almost_equal_nulp(fftn(ifftn(x)), x, maxnlp)
|
723 |
+
|
724 |
+
def test_invalid_sizes(self):
|
725 |
+
with assert_raises(ValueError,
|
726 |
+
match="invalid number of data points"
|
727 |
+
r" \(\[1, 0\]\) specified"):
|
728 |
+
ifftn([[]])
|
729 |
+
|
730 |
+
with assert_raises(ValueError,
|
731 |
+
match="invalid number of data points"
|
732 |
+
r" \(\[4, -3\]\) specified"):
|
733 |
+
ifftn([[1, 1], [2, 2]], (4, -3))
|
734 |
+
|
735 |
+
|
736 |
+
class FakeArray:
|
737 |
+
def __init__(self, data):
|
738 |
+
self._data = data
|
739 |
+
self.__array_interface__ = data.__array_interface__
|
740 |
+
|
741 |
+
|
742 |
+
class FakeArray2:
|
743 |
+
def __init__(self, data):
|
744 |
+
self._data = data
|
745 |
+
|
746 |
+
def __array__(self, dtype=None, copy=None):
|
747 |
+
return self._data
|
748 |
+
|
749 |
+
|
750 |
+
class TestOverwrite:
|
751 |
+
"""Check input overwrite behavior of the FFT functions."""
|
752 |
+
|
753 |
+
real_dtypes = (np.float32, np.float64)
|
754 |
+
dtypes = real_dtypes + (np.complex64, np.complex128)
|
755 |
+
fftsizes = [8, 16, 32]
|
756 |
+
|
757 |
+
def _check(self, x, routine, fftsize, axis, overwrite_x):
|
758 |
+
x2 = x.copy()
|
759 |
+
for fake in [lambda x: x, FakeArray, FakeArray2]:
|
760 |
+
routine(fake(x2), fftsize, axis, overwrite_x=overwrite_x)
|
761 |
+
|
762 |
+
sig = "{}({}{!r}, {!r}, axis={!r}, overwrite_x={!r})".format(
|
763 |
+
routine.__name__, x.dtype, x.shape, fftsize, axis, overwrite_x)
|
764 |
+
if not overwrite_x:
|
765 |
+
assert_equal(x2, x, err_msg="spurious overwrite in %s" % sig)
|
766 |
+
|
767 |
+
def _check_1d(self, routine, dtype, shape, axis, overwritable_dtypes,
|
768 |
+
fftsize, overwrite_x):
|
769 |
+
np.random.seed(1234)
|
770 |
+
if np.issubdtype(dtype, np.complexfloating):
|
771 |
+
data = np.random.randn(*shape) + 1j*np.random.randn(*shape)
|
772 |
+
else:
|
773 |
+
data = np.random.randn(*shape)
|
774 |
+
data = data.astype(dtype)
|
775 |
+
|
776 |
+
self._check(data, routine, fftsize, axis,
|
777 |
+
overwrite_x=overwrite_x)
|
778 |
+
|
779 |
+
@pytest.mark.parametrize('dtype', dtypes)
|
780 |
+
@pytest.mark.parametrize('fftsize', fftsizes)
|
781 |
+
@pytest.mark.parametrize('overwrite_x', [True, False])
|
782 |
+
@pytest.mark.parametrize('shape,axes', [((16,), -1),
|
783 |
+
((16, 2), 0),
|
784 |
+
((2, 16), 1)])
|
785 |
+
def test_fft_ifft(self, dtype, fftsize, overwrite_x, shape, axes):
|
786 |
+
overwritable = (np.complex128, np.complex64)
|
787 |
+
self._check_1d(fft, dtype, shape, axes, overwritable,
|
788 |
+
fftsize, overwrite_x)
|
789 |
+
self._check_1d(ifft, dtype, shape, axes, overwritable,
|
790 |
+
fftsize, overwrite_x)
|
791 |
+
|
792 |
+
@pytest.mark.parametrize('dtype', real_dtypes)
|
793 |
+
@pytest.mark.parametrize('fftsize', fftsizes)
|
794 |
+
@pytest.mark.parametrize('overwrite_x', [True, False])
|
795 |
+
@pytest.mark.parametrize('shape,axes', [((16,), -1),
|
796 |
+
((16, 2), 0),
|
797 |
+
((2, 16), 1)])
|
798 |
+
def test_rfft_irfft(self, dtype, fftsize, overwrite_x, shape, axes):
|
799 |
+
overwritable = self.real_dtypes
|
800 |
+
self._check_1d(irfft, dtype, shape, axes, overwritable,
|
801 |
+
fftsize, overwrite_x)
|
802 |
+
self._check_1d(rfft, dtype, shape, axes, overwritable,
|
803 |
+
fftsize, overwrite_x)
|
804 |
+
|
805 |
+
def _check_nd_one(self, routine, dtype, shape, axes, overwritable_dtypes,
|
806 |
+
overwrite_x):
|
807 |
+
np.random.seed(1234)
|
808 |
+
if np.issubdtype(dtype, np.complexfloating):
|
809 |
+
data = np.random.randn(*shape) + 1j*np.random.randn(*shape)
|
810 |
+
else:
|
811 |
+
data = np.random.randn(*shape)
|
812 |
+
data = data.astype(dtype)
|
813 |
+
|
814 |
+
def fftshape_iter(shp):
|
815 |
+
if len(shp) <= 0:
|
816 |
+
yield ()
|
817 |
+
else:
|
818 |
+
for j in (shp[0]//2, shp[0], shp[0]*2):
|
819 |
+
for rest in fftshape_iter(shp[1:]):
|
820 |
+
yield (j,) + rest
|
821 |
+
|
822 |
+
if axes is None:
|
823 |
+
part_shape = shape
|
824 |
+
else:
|
825 |
+
part_shape = tuple(np.take(shape, axes))
|
826 |
+
|
827 |
+
for fftshape in fftshape_iter(part_shape):
|
828 |
+
self._check(data, routine, fftshape, axes,
|
829 |
+
overwrite_x=overwrite_x)
|
830 |
+
if data.ndim > 1:
|
831 |
+
self._check(data.T, routine, fftshape, axes,
|
832 |
+
overwrite_x=overwrite_x)
|
833 |
+
|
834 |
+
@pytest.mark.parametrize('dtype', dtypes)
|
835 |
+
@pytest.mark.parametrize('overwrite_x', [True, False])
|
836 |
+
@pytest.mark.parametrize('shape,axes', [((16,), None),
|
837 |
+
((16,), (0,)),
|
838 |
+
((16, 2), (0,)),
|
839 |
+
((2, 16), (1,)),
|
840 |
+
((8, 16), None),
|
841 |
+
((8, 16), (0, 1)),
|
842 |
+
((8, 16, 2), (0, 1)),
|
843 |
+
((8, 16, 2), (1, 2)),
|
844 |
+
((8, 16, 2), (0,)),
|
845 |
+
((8, 16, 2), (1,)),
|
846 |
+
((8, 16, 2), (2,)),
|
847 |
+
((8, 16, 2), None),
|
848 |
+
((8, 16, 2), (0, 1, 2))])
|
849 |
+
def test_fftn_ifftn(self, dtype, overwrite_x, shape, axes):
|
850 |
+
overwritable = (np.complex128, np.complex64)
|
851 |
+
self._check_nd_one(fftn, dtype, shape, axes, overwritable,
|
852 |
+
overwrite_x)
|
853 |
+
self._check_nd_one(ifftn, dtype, shape, axes, overwritable,
|
854 |
+
overwrite_x)
|
855 |
+
|
856 |
+
|
857 |
+
@pytest.mark.parametrize('func', [fftn, ifftn, fft2])
|
858 |
+
def test_shape_axes_ndarray(func):
|
859 |
+
# Test fftn and ifftn work with NumPy arrays for shape and axes arguments
|
860 |
+
# Regression test for gh-13342
|
861 |
+
a = np.random.rand(10, 10)
|
862 |
+
|
863 |
+
expect = func(a, shape=(5, 5))
|
864 |
+
actual = func(a, shape=np.array([5, 5]))
|
865 |
+
assert_equal(expect, actual)
|
866 |
+
|
867 |
+
expect = func(a, axes=(-1,))
|
868 |
+
actual = func(a, axes=np.array([-1,]))
|
869 |
+
assert_equal(expect, actual)
|
870 |
+
|
871 |
+
expect = func(a, shape=(4, 7), axes=(1, 0))
|
872 |
+
actual = func(a, shape=np.array([4, 7]), axes=np.array([1, 0]))
|
873 |
+
assert_equal(expect, actual)
|
venv/lib/python3.10/site-packages/scipy/fftpack/tests/test_helper.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Created by Pearu Peterson, September 2002
|
2 |
+
|
3 |
+
__usage__ = """
|
4 |
+
Build fftpack:
|
5 |
+
python setup_fftpack.py build
|
6 |
+
Run tests if scipy is installed:
|
7 |
+
python -c 'import scipy;scipy.fftpack.test(<level>)'
|
8 |
+
Run tests if fftpack is not installed:
|
9 |
+
python tests/test_helper.py [<level>]
|
10 |
+
"""
|
11 |
+
|
12 |
+
from numpy.testing import assert_array_almost_equal
|
13 |
+
from scipy.fftpack import fftshift, ifftshift, fftfreq, rfftfreq
|
14 |
+
|
15 |
+
from numpy import pi, random
|
16 |
+
|
17 |
+
class TestFFTShift:
|
18 |
+
|
19 |
+
def test_definition(self):
|
20 |
+
x = [0,1,2,3,4,-4,-3,-2,-1]
|
21 |
+
y = [-4,-3,-2,-1,0,1,2,3,4]
|
22 |
+
assert_array_almost_equal(fftshift(x),y)
|
23 |
+
assert_array_almost_equal(ifftshift(y),x)
|
24 |
+
x = [0,1,2,3,4,-5,-4,-3,-2,-1]
|
25 |
+
y = [-5,-4,-3,-2,-1,0,1,2,3,4]
|
26 |
+
assert_array_almost_equal(fftshift(x),y)
|
27 |
+
assert_array_almost_equal(ifftshift(y),x)
|
28 |
+
|
29 |
+
def test_inverse(self):
|
30 |
+
for n in [1,4,9,100,211]:
|
31 |
+
x = random.random((n,))
|
32 |
+
assert_array_almost_equal(ifftshift(fftshift(x)),x)
|
33 |
+
|
34 |
+
|
35 |
+
class TestFFTFreq:
|
36 |
+
|
37 |
+
def test_definition(self):
|
38 |
+
x = [0,1,2,3,4,-4,-3,-2,-1]
|
39 |
+
assert_array_almost_equal(9*fftfreq(9),x)
|
40 |
+
assert_array_almost_equal(9*pi*fftfreq(9,pi),x)
|
41 |
+
x = [0,1,2,3,4,-5,-4,-3,-2,-1]
|
42 |
+
assert_array_almost_equal(10*fftfreq(10),x)
|
43 |
+
assert_array_almost_equal(10*pi*fftfreq(10,pi),x)
|
44 |
+
|
45 |
+
|
46 |
+
class TestRFFTFreq:
|
47 |
+
|
48 |
+
def test_definition(self):
|
49 |
+
x = [0,1,1,2,2,3,3,4,4]
|
50 |
+
assert_array_almost_equal(9*rfftfreq(9),x)
|
51 |
+
assert_array_almost_equal(9*pi*rfftfreq(9,pi),x)
|
52 |
+
x = [0,1,1,2,2,3,3,4,4,5]
|
53 |
+
assert_array_almost_equal(10*rfftfreq(10),x)
|
54 |
+
assert_array_almost_equal(10*pi*rfftfreq(10,pi),x)
|
venv/lib/python3.10/site-packages/scipy/fftpack/tests/test_import.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Test possibility of patching fftpack with pyfftw.
|
2 |
+
|
3 |
+
No module source outside of scipy.fftpack should contain an import of
|
4 |
+
the form `from scipy.fftpack import ...`, so that a simple replacement
|
5 |
+
of scipy.fftpack by the corresponding fftw interface completely swaps
|
6 |
+
the two FFT implementations.
|
7 |
+
|
8 |
+
Because this simply inspects source files, we only need to run the test
|
9 |
+
on one version of Python.
|
10 |
+
"""
|
11 |
+
|
12 |
+
|
13 |
+
from pathlib import Path
|
14 |
+
import re
|
15 |
+
import tokenize
|
16 |
+
from numpy.testing import assert_
|
17 |
+
import scipy
|
18 |
+
|
19 |
+
class TestFFTPackImport:
|
20 |
+
def test_fftpack_import(self):
|
21 |
+
base = Path(scipy.__file__).parent
|
22 |
+
regexp = r"\s*from.+\.fftpack import .*\n"
|
23 |
+
for path in base.rglob("*.py"):
|
24 |
+
if base / "fftpack" in path.parents:
|
25 |
+
continue
|
26 |
+
# use tokenize to auto-detect encoding on systems where no
|
27 |
+
# default encoding is defined (e.g., LANG='C')
|
28 |
+
with tokenize.open(str(path)) as file:
|
29 |
+
assert_(all(not re.fullmatch(regexp, line)
|
30 |
+
for line in file),
|
31 |
+
f"{path} contains an import from fftpack")
|
venv/lib/python3.10/site-packages/scipy/fftpack/tests/test_pseudo_diffs.py
ADDED
@@ -0,0 +1,380 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Created by Pearu Peterson, September 2002
|
2 |
+
|
3 |
+
__usage__ = """
|
4 |
+
Build fftpack:
|
5 |
+
python setup_fftpack.py build
|
6 |
+
Run tests if scipy is installed:
|
7 |
+
python -c 'import scipy;scipy.fftpack.test(<level>)'
|
8 |
+
Run tests if fftpack is not installed:
|
9 |
+
python tests/test_pseudo_diffs.py [<level>]
|
10 |
+
"""
|
11 |
+
|
12 |
+
from numpy.testing import (assert_equal, assert_almost_equal,
|
13 |
+
assert_array_almost_equal)
|
14 |
+
from scipy.fftpack import (diff, fft, ifft, tilbert, itilbert, hilbert,
|
15 |
+
ihilbert, shift, fftfreq, cs_diff, sc_diff,
|
16 |
+
ss_diff, cc_diff)
|
17 |
+
|
18 |
+
import numpy as np
|
19 |
+
from numpy import arange, sin, cos, pi, exp, tanh, sum, sign
|
20 |
+
from numpy.random import random
|
21 |
+
|
22 |
+
|
23 |
+
def direct_diff(x,k=1,period=None):
|
24 |
+
fx = fft(x)
|
25 |
+
n = len(fx)
|
26 |
+
if period is None:
|
27 |
+
period = 2*pi
|
28 |
+
w = fftfreq(n)*2j*pi/period*n
|
29 |
+
if k < 0:
|
30 |
+
w = 1 / w**k
|
31 |
+
w[0] = 0.0
|
32 |
+
else:
|
33 |
+
w = w**k
|
34 |
+
if n > 2000:
|
35 |
+
w[250:n-250] = 0.0
|
36 |
+
return ifft(w*fx).real
|
37 |
+
|
38 |
+
|
39 |
+
def direct_tilbert(x,h=1,period=None):
|
40 |
+
fx = fft(x)
|
41 |
+
n = len(fx)
|
42 |
+
if period is None:
|
43 |
+
period = 2*pi
|
44 |
+
w = fftfreq(n)*h*2*pi/period*n
|
45 |
+
w[0] = 1
|
46 |
+
w = 1j/tanh(w)
|
47 |
+
w[0] = 0j
|
48 |
+
return ifft(w*fx)
|
49 |
+
|
50 |
+
|
51 |
+
def direct_itilbert(x,h=1,period=None):
|
52 |
+
fx = fft(x)
|
53 |
+
n = len(fx)
|
54 |
+
if period is None:
|
55 |
+
period = 2*pi
|
56 |
+
w = fftfreq(n)*h*2*pi/period*n
|
57 |
+
w = -1j*tanh(w)
|
58 |
+
return ifft(w*fx)
|
59 |
+
|
60 |
+
|
61 |
+
def direct_hilbert(x):
|
62 |
+
fx = fft(x)
|
63 |
+
n = len(fx)
|
64 |
+
w = fftfreq(n)*n
|
65 |
+
w = 1j*sign(w)
|
66 |
+
return ifft(w*fx)
|
67 |
+
|
68 |
+
|
69 |
+
def direct_ihilbert(x):
|
70 |
+
return -direct_hilbert(x)
|
71 |
+
|
72 |
+
|
73 |
+
def direct_shift(x,a,period=None):
|
74 |
+
n = len(x)
|
75 |
+
if period is None:
|
76 |
+
k = fftfreq(n)*1j*n
|
77 |
+
else:
|
78 |
+
k = fftfreq(n)*2j*pi/period*n
|
79 |
+
return ifft(fft(x)*exp(k*a)).real
|
80 |
+
|
81 |
+
|
82 |
+
class TestDiff:
|
83 |
+
|
84 |
+
def test_definition(self):
|
85 |
+
for n in [16,17,64,127,32]:
|
86 |
+
x = arange(n)*2*pi/n
|
87 |
+
assert_array_almost_equal(diff(sin(x)),direct_diff(sin(x)))
|
88 |
+
assert_array_almost_equal(diff(sin(x),2),direct_diff(sin(x),2))
|
89 |
+
assert_array_almost_equal(diff(sin(x),3),direct_diff(sin(x),3))
|
90 |
+
assert_array_almost_equal(diff(sin(x),4),direct_diff(sin(x),4))
|
91 |
+
assert_array_almost_equal(diff(sin(x),5),direct_diff(sin(x),5))
|
92 |
+
assert_array_almost_equal(diff(sin(2*x),3),direct_diff(sin(2*x),3))
|
93 |
+
assert_array_almost_equal(diff(sin(2*x),4),direct_diff(sin(2*x),4))
|
94 |
+
assert_array_almost_equal(diff(cos(x)),direct_diff(cos(x)))
|
95 |
+
assert_array_almost_equal(diff(cos(x),2),direct_diff(cos(x),2))
|
96 |
+
assert_array_almost_equal(diff(cos(x),3),direct_diff(cos(x),3))
|
97 |
+
assert_array_almost_equal(diff(cos(x),4),direct_diff(cos(x),4))
|
98 |
+
assert_array_almost_equal(diff(cos(2*x)),direct_diff(cos(2*x)))
|
99 |
+
assert_array_almost_equal(diff(sin(x*n/8)),direct_diff(sin(x*n/8)))
|
100 |
+
assert_array_almost_equal(diff(cos(x*n/8)),direct_diff(cos(x*n/8)))
|
101 |
+
for k in range(5):
|
102 |
+
assert_array_almost_equal(diff(sin(4*x),k),direct_diff(sin(4*x),k))
|
103 |
+
assert_array_almost_equal(diff(cos(4*x),k),direct_diff(cos(4*x),k))
|
104 |
+
|
105 |
+
def test_period(self):
|
106 |
+
for n in [17,64]:
|
107 |
+
x = arange(n)/float(n)
|
108 |
+
assert_array_almost_equal(diff(sin(2*pi*x),period=1),
|
109 |
+
2*pi*cos(2*pi*x))
|
110 |
+
assert_array_almost_equal(diff(sin(2*pi*x),3,period=1),
|
111 |
+
-(2*pi)**3*cos(2*pi*x))
|
112 |
+
|
113 |
+
def test_sin(self):
|
114 |
+
for n in [32,64,77]:
|
115 |
+
x = arange(n)*2*pi/n
|
116 |
+
assert_array_almost_equal(diff(sin(x)),cos(x))
|
117 |
+
assert_array_almost_equal(diff(cos(x)),-sin(x))
|
118 |
+
assert_array_almost_equal(diff(sin(x),2),-sin(x))
|
119 |
+
assert_array_almost_equal(diff(sin(x),4),sin(x))
|
120 |
+
assert_array_almost_equal(diff(sin(4*x)),4*cos(4*x))
|
121 |
+
assert_array_almost_equal(diff(sin(sin(x))),cos(x)*cos(sin(x)))
|
122 |
+
|
123 |
+
def test_expr(self):
|
124 |
+
for n in [64,77,100,128,256,512,1024,2048,4096,8192][:5]:
|
125 |
+
x = arange(n)*2*pi/n
|
126 |
+
f = sin(x)*cos(4*x)+exp(sin(3*x))
|
127 |
+
df = cos(x)*cos(4*x)-4*sin(x)*sin(4*x)+3*cos(3*x)*exp(sin(3*x))
|
128 |
+
ddf = -17*sin(x)*cos(4*x)-8*cos(x)*sin(4*x)\
|
129 |
+
- 9*sin(3*x)*exp(sin(3*x))+9*cos(3*x)**2*exp(sin(3*x))
|
130 |
+
d1 = diff(f)
|
131 |
+
assert_array_almost_equal(d1,df)
|
132 |
+
assert_array_almost_equal(diff(df),ddf)
|
133 |
+
assert_array_almost_equal(diff(f,2),ddf)
|
134 |
+
assert_array_almost_equal(diff(ddf,-1),df)
|
135 |
+
|
136 |
+
def test_expr_large(self):
|
137 |
+
for n in [2048,4096]:
|
138 |
+
x = arange(n)*2*pi/n
|
139 |
+
f = sin(x)*cos(4*x)+exp(sin(3*x))
|
140 |
+
df = cos(x)*cos(4*x)-4*sin(x)*sin(4*x)+3*cos(3*x)*exp(sin(3*x))
|
141 |
+
ddf = -17*sin(x)*cos(4*x)-8*cos(x)*sin(4*x)\
|
142 |
+
- 9*sin(3*x)*exp(sin(3*x))+9*cos(3*x)**2*exp(sin(3*x))
|
143 |
+
assert_array_almost_equal(diff(f),df)
|
144 |
+
assert_array_almost_equal(diff(df),ddf)
|
145 |
+
assert_array_almost_equal(diff(ddf,-1),df)
|
146 |
+
assert_array_almost_equal(diff(f,2),ddf)
|
147 |
+
|
148 |
+
def test_int(self):
|
149 |
+
n = 64
|
150 |
+
x = arange(n)*2*pi/n
|
151 |
+
assert_array_almost_equal(diff(sin(x),-1),-cos(x))
|
152 |
+
assert_array_almost_equal(diff(sin(x),-2),-sin(x))
|
153 |
+
assert_array_almost_equal(diff(sin(x),-4),sin(x))
|
154 |
+
assert_array_almost_equal(diff(2*cos(2*x),-1),sin(2*x))
|
155 |
+
|
156 |
+
def test_random_even(self):
|
157 |
+
for k in [0,2,4,6]:
|
158 |
+
for n in [60,32,64,56,55]:
|
159 |
+
f = random((n,))
|
160 |
+
af = sum(f,axis=0)/n
|
161 |
+
f = f-af
|
162 |
+
# zeroing Nyquist mode:
|
163 |
+
f = diff(diff(f,1),-1)
|
164 |
+
assert_almost_equal(sum(f,axis=0),0.0)
|
165 |
+
assert_array_almost_equal(diff(diff(f,k),-k),f)
|
166 |
+
assert_array_almost_equal(diff(diff(f,-k),k),f)
|
167 |
+
|
168 |
+
def test_random_odd(self):
|
169 |
+
for k in [0,1,2,3,4,5,6]:
|
170 |
+
for n in [33,65,55]:
|
171 |
+
f = random((n,))
|
172 |
+
af = sum(f,axis=0)/n
|
173 |
+
f = f-af
|
174 |
+
assert_almost_equal(sum(f,axis=0),0.0)
|
175 |
+
assert_array_almost_equal(diff(diff(f,k),-k),f)
|
176 |
+
assert_array_almost_equal(diff(diff(f,-k),k),f)
|
177 |
+
|
178 |
+
def test_zero_nyquist(self):
|
179 |
+
for k in [0,1,2,3,4,5,6]:
|
180 |
+
for n in [32,33,64,56,55]:
|
181 |
+
f = random((n,))
|
182 |
+
af = sum(f,axis=0)/n
|
183 |
+
f = f-af
|
184 |
+
# zeroing Nyquist mode:
|
185 |
+
f = diff(diff(f,1),-1)
|
186 |
+
assert_almost_equal(sum(f,axis=0),0.0)
|
187 |
+
assert_array_almost_equal(diff(diff(f,k),-k),f)
|
188 |
+
assert_array_almost_equal(diff(diff(f,-k),k),f)
|
189 |
+
|
190 |
+
|
191 |
+
class TestTilbert:
|
192 |
+
|
193 |
+
def test_definition(self):
|
194 |
+
for h in [0.1,0.5,1,5.5,10]:
|
195 |
+
for n in [16,17,64,127]:
|
196 |
+
x = arange(n)*2*pi/n
|
197 |
+
y = tilbert(sin(x),h)
|
198 |
+
y1 = direct_tilbert(sin(x),h)
|
199 |
+
assert_array_almost_equal(y,y1)
|
200 |
+
assert_array_almost_equal(tilbert(sin(x),h),
|
201 |
+
direct_tilbert(sin(x),h))
|
202 |
+
assert_array_almost_equal(tilbert(sin(2*x),h),
|
203 |
+
direct_tilbert(sin(2*x),h))
|
204 |
+
|
205 |
+
def test_random_even(self):
|
206 |
+
for h in [0.1,0.5,1,5.5,10]:
|
207 |
+
for n in [32,64,56]:
|
208 |
+
f = random((n,))
|
209 |
+
af = sum(f,axis=0)/n
|
210 |
+
f = f-af
|
211 |
+
assert_almost_equal(sum(f,axis=0),0.0)
|
212 |
+
assert_array_almost_equal(direct_tilbert(direct_itilbert(f,h),h),f)
|
213 |
+
|
214 |
+
def test_random_odd(self):
|
215 |
+
for h in [0.1,0.5,1,5.5,10]:
|
216 |
+
for n in [33,65,55]:
|
217 |
+
f = random((n,))
|
218 |
+
af = sum(f,axis=0)/n
|
219 |
+
f = f-af
|
220 |
+
assert_almost_equal(sum(f,axis=0),0.0)
|
221 |
+
assert_array_almost_equal(itilbert(tilbert(f,h),h),f)
|
222 |
+
assert_array_almost_equal(tilbert(itilbert(f,h),h),f)
|
223 |
+
|
224 |
+
|
225 |
+
class TestITilbert:
|
226 |
+
|
227 |
+
def test_definition(self):
|
228 |
+
for h in [0.1,0.5,1,5.5,10]:
|
229 |
+
for n in [16,17,64,127]:
|
230 |
+
x = arange(n)*2*pi/n
|
231 |
+
y = itilbert(sin(x),h)
|
232 |
+
y1 = direct_itilbert(sin(x),h)
|
233 |
+
assert_array_almost_equal(y,y1)
|
234 |
+
assert_array_almost_equal(itilbert(sin(x),h),
|
235 |
+
direct_itilbert(sin(x),h))
|
236 |
+
assert_array_almost_equal(itilbert(sin(2*x),h),
|
237 |
+
direct_itilbert(sin(2*x),h))
|
238 |
+
|
239 |
+
|
240 |
+
class TestHilbert:
|
241 |
+
|
242 |
+
def test_definition(self):
|
243 |
+
for n in [16,17,64,127]:
|
244 |
+
x = arange(n)*2*pi/n
|
245 |
+
y = hilbert(sin(x))
|
246 |
+
y1 = direct_hilbert(sin(x))
|
247 |
+
assert_array_almost_equal(y,y1)
|
248 |
+
assert_array_almost_equal(hilbert(sin(2*x)),
|
249 |
+
direct_hilbert(sin(2*x)))
|
250 |
+
|
251 |
+
def test_tilbert_relation(self):
|
252 |
+
for n in [16,17,64,127]:
|
253 |
+
x = arange(n)*2*pi/n
|
254 |
+
f = sin(x)+cos(2*x)*sin(x)
|
255 |
+
y = hilbert(f)
|
256 |
+
y1 = direct_hilbert(f)
|
257 |
+
assert_array_almost_equal(y,y1)
|
258 |
+
y2 = tilbert(f,h=10)
|
259 |
+
assert_array_almost_equal(y,y2)
|
260 |
+
|
261 |
+
def test_random_odd(self):
|
262 |
+
for n in [33,65,55]:
|
263 |
+
f = random((n,))
|
264 |
+
af = sum(f,axis=0)/n
|
265 |
+
f = f-af
|
266 |
+
assert_almost_equal(sum(f,axis=0),0.0)
|
267 |
+
assert_array_almost_equal(ihilbert(hilbert(f)),f)
|
268 |
+
assert_array_almost_equal(hilbert(ihilbert(f)),f)
|
269 |
+
|
270 |
+
def test_random_even(self):
|
271 |
+
for n in [32,64,56]:
|
272 |
+
f = random((n,))
|
273 |
+
af = sum(f,axis=0)/n
|
274 |
+
f = f-af
|
275 |
+
# zeroing Nyquist mode:
|
276 |
+
f = diff(diff(f,1),-1)
|
277 |
+
assert_almost_equal(sum(f,axis=0),0.0)
|
278 |
+
assert_array_almost_equal(direct_hilbert(direct_ihilbert(f)),f)
|
279 |
+
assert_array_almost_equal(hilbert(ihilbert(f)),f)
|
280 |
+
|
281 |
+
|
282 |
+
class TestIHilbert:
|
283 |
+
|
284 |
+
def test_definition(self):
|
285 |
+
for n in [16,17,64,127]:
|
286 |
+
x = arange(n)*2*pi/n
|
287 |
+
y = ihilbert(sin(x))
|
288 |
+
y1 = direct_ihilbert(sin(x))
|
289 |
+
assert_array_almost_equal(y,y1)
|
290 |
+
assert_array_almost_equal(ihilbert(sin(2*x)),
|
291 |
+
direct_ihilbert(sin(2*x)))
|
292 |
+
|
293 |
+
def test_itilbert_relation(self):
|
294 |
+
for n in [16,17,64,127]:
|
295 |
+
x = arange(n)*2*pi/n
|
296 |
+
f = sin(x)+cos(2*x)*sin(x)
|
297 |
+
y = ihilbert(f)
|
298 |
+
y1 = direct_ihilbert(f)
|
299 |
+
assert_array_almost_equal(y,y1)
|
300 |
+
y2 = itilbert(f,h=10)
|
301 |
+
assert_array_almost_equal(y,y2)
|
302 |
+
|
303 |
+
|
304 |
+
class TestShift:
|
305 |
+
|
306 |
+
def test_definition(self):
|
307 |
+
for n in [18,17,64,127,32,2048,256]:
|
308 |
+
x = arange(n)*2*pi/n
|
309 |
+
for a in [0.1,3]:
|
310 |
+
assert_array_almost_equal(shift(sin(x),a),direct_shift(sin(x),a))
|
311 |
+
assert_array_almost_equal(shift(sin(x),a),sin(x+a))
|
312 |
+
assert_array_almost_equal(shift(cos(x),a),cos(x+a))
|
313 |
+
assert_array_almost_equal(shift(cos(2*x)+sin(x),a),
|
314 |
+
cos(2*(x+a))+sin(x+a))
|
315 |
+
assert_array_almost_equal(shift(exp(sin(x)),a),exp(sin(x+a)))
|
316 |
+
assert_array_almost_equal(shift(sin(x),2*pi),sin(x))
|
317 |
+
assert_array_almost_equal(shift(sin(x),pi),-sin(x))
|
318 |
+
assert_array_almost_equal(shift(sin(x),pi/2),cos(x))
|
319 |
+
|
320 |
+
|
321 |
+
class TestOverwrite:
|
322 |
+
"""Check input overwrite behavior """
|
323 |
+
|
324 |
+
real_dtypes = (np.float32, np.float64)
|
325 |
+
dtypes = real_dtypes + (np.complex64, np.complex128)
|
326 |
+
|
327 |
+
def _check(self, x, routine, *args, **kwargs):
|
328 |
+
x2 = x.copy()
|
329 |
+
routine(x2, *args, **kwargs)
|
330 |
+
sig = routine.__name__
|
331 |
+
if args:
|
332 |
+
sig += repr(args)
|
333 |
+
if kwargs:
|
334 |
+
sig += repr(kwargs)
|
335 |
+
assert_equal(x2, x, err_msg="spurious overwrite in %s" % sig)
|
336 |
+
|
337 |
+
def _check_1d(self, routine, dtype, shape, *args, **kwargs):
|
338 |
+
np.random.seed(1234)
|
339 |
+
if np.issubdtype(dtype, np.complexfloating):
|
340 |
+
data = np.random.randn(*shape) + 1j*np.random.randn(*shape)
|
341 |
+
else:
|
342 |
+
data = np.random.randn(*shape)
|
343 |
+
data = data.astype(dtype)
|
344 |
+
self._check(data, routine, *args, **kwargs)
|
345 |
+
|
346 |
+
def test_diff(self):
|
347 |
+
for dtype in self.dtypes:
|
348 |
+
self._check_1d(diff, dtype, (16,))
|
349 |
+
|
350 |
+
def test_tilbert(self):
|
351 |
+
for dtype in self.dtypes:
|
352 |
+
self._check_1d(tilbert, dtype, (16,), 1.6)
|
353 |
+
|
354 |
+
def test_itilbert(self):
|
355 |
+
for dtype in self.dtypes:
|
356 |
+
self._check_1d(itilbert, dtype, (16,), 1.6)
|
357 |
+
|
358 |
+
def test_hilbert(self):
|
359 |
+
for dtype in self.dtypes:
|
360 |
+
self._check_1d(hilbert, dtype, (16,))
|
361 |
+
|
362 |
+
def test_cs_diff(self):
|
363 |
+
for dtype in self.dtypes:
|
364 |
+
self._check_1d(cs_diff, dtype, (16,), 1.0, 4.0)
|
365 |
+
|
366 |
+
def test_sc_diff(self):
|
367 |
+
for dtype in self.dtypes:
|
368 |
+
self._check_1d(sc_diff, dtype, (16,), 1.0, 4.0)
|
369 |
+
|
370 |
+
def test_ss_diff(self):
|
371 |
+
for dtype in self.dtypes:
|
372 |
+
self._check_1d(ss_diff, dtype, (16,), 1.0, 4.0)
|
373 |
+
|
374 |
+
def test_cc_diff(self):
|
375 |
+
for dtype in self.dtypes:
|
376 |
+
self._check_1d(cc_diff, dtype, (16,), 1.0, 4.0)
|
377 |
+
|
378 |
+
def test_shift(self):
|
379 |
+
for dtype in self.dtypes:
|
380 |
+
self._check_1d(shift, dtype, (16,), 1.0)
|
venv/lib/python3.10/site-packages/scipy/fftpack/tests/test_real_transforms.py
ADDED
@@ -0,0 +1,815 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from os.path import join, dirname
|
2 |
+
|
3 |
+
import numpy as np
|
4 |
+
from numpy.testing import assert_array_almost_equal, assert_equal
|
5 |
+
import pytest
|
6 |
+
from pytest import raises as assert_raises
|
7 |
+
|
8 |
+
from scipy.fftpack._realtransforms import (
|
9 |
+
dct, idct, dst, idst, dctn, idctn, dstn, idstn)
|
10 |
+
|
11 |
+
# Matlab reference data
|
12 |
+
MDATA = np.load(join(dirname(__file__), 'test.npz'))
|
13 |
+
X = [MDATA['x%d' % i] for i in range(8)]
|
14 |
+
Y = [MDATA['y%d' % i] for i in range(8)]
|
15 |
+
|
16 |
+
# FFTW reference data: the data are organized as follows:
|
17 |
+
# * SIZES is an array containing all available sizes
|
18 |
+
# * for every type (1, 2, 3, 4) and every size, the array dct_type_size
|
19 |
+
# contains the output of the DCT applied to the input np.linspace(0, size-1,
|
20 |
+
# size)
|
21 |
+
FFTWDATA_DOUBLE = np.load(join(dirname(__file__), 'fftw_double_ref.npz'))
|
22 |
+
FFTWDATA_SINGLE = np.load(join(dirname(__file__), 'fftw_single_ref.npz'))
|
23 |
+
FFTWDATA_SIZES = FFTWDATA_DOUBLE['sizes']
|
24 |
+
|
25 |
+
|
26 |
+
def fftw_dct_ref(type, size, dt):
|
27 |
+
x = np.linspace(0, size-1, size).astype(dt)
|
28 |
+
dt = np.result_type(np.float32, dt)
|
29 |
+
if dt == np.float64:
|
30 |
+
data = FFTWDATA_DOUBLE
|
31 |
+
elif dt == np.float32:
|
32 |
+
data = FFTWDATA_SINGLE
|
33 |
+
else:
|
34 |
+
raise ValueError()
|
35 |
+
y = (data['dct_%d_%d' % (type, size)]).astype(dt)
|
36 |
+
return x, y, dt
|
37 |
+
|
38 |
+
|
39 |
+
def fftw_dst_ref(type, size, dt):
|
40 |
+
x = np.linspace(0, size-1, size).astype(dt)
|
41 |
+
dt = np.result_type(np.float32, dt)
|
42 |
+
if dt == np.float64:
|
43 |
+
data = FFTWDATA_DOUBLE
|
44 |
+
elif dt == np.float32:
|
45 |
+
data = FFTWDATA_SINGLE
|
46 |
+
else:
|
47 |
+
raise ValueError()
|
48 |
+
y = (data['dst_%d_%d' % (type, size)]).astype(dt)
|
49 |
+
return x, y, dt
|
50 |
+
|
51 |
+
|
52 |
+
def dct_2d_ref(x, **kwargs):
|
53 |
+
"""Calculate reference values for testing dct2."""
|
54 |
+
x = np.array(x, copy=True)
|
55 |
+
for row in range(x.shape[0]):
|
56 |
+
x[row, :] = dct(x[row, :], **kwargs)
|
57 |
+
for col in range(x.shape[1]):
|
58 |
+
x[:, col] = dct(x[:, col], **kwargs)
|
59 |
+
return x
|
60 |
+
|
61 |
+
|
62 |
+
def idct_2d_ref(x, **kwargs):
|
63 |
+
"""Calculate reference values for testing idct2."""
|
64 |
+
x = np.array(x, copy=True)
|
65 |
+
for row in range(x.shape[0]):
|
66 |
+
x[row, :] = idct(x[row, :], **kwargs)
|
67 |
+
for col in range(x.shape[1]):
|
68 |
+
x[:, col] = idct(x[:, col], **kwargs)
|
69 |
+
return x
|
70 |
+
|
71 |
+
|
72 |
+
def dst_2d_ref(x, **kwargs):
|
73 |
+
"""Calculate reference values for testing dst2."""
|
74 |
+
x = np.array(x, copy=True)
|
75 |
+
for row in range(x.shape[0]):
|
76 |
+
x[row, :] = dst(x[row, :], **kwargs)
|
77 |
+
for col in range(x.shape[1]):
|
78 |
+
x[:, col] = dst(x[:, col], **kwargs)
|
79 |
+
return x
|
80 |
+
|
81 |
+
|
82 |
+
def idst_2d_ref(x, **kwargs):
|
83 |
+
"""Calculate reference values for testing idst2."""
|
84 |
+
x = np.array(x, copy=True)
|
85 |
+
for row in range(x.shape[0]):
|
86 |
+
x[row, :] = idst(x[row, :], **kwargs)
|
87 |
+
for col in range(x.shape[1]):
|
88 |
+
x[:, col] = idst(x[:, col], **kwargs)
|
89 |
+
return x
|
90 |
+
|
91 |
+
|
92 |
+
def naive_dct1(x, norm=None):
|
93 |
+
"""Calculate textbook definition version of DCT-I."""
|
94 |
+
x = np.array(x, copy=True)
|
95 |
+
N = len(x)
|
96 |
+
M = N-1
|
97 |
+
y = np.zeros(N)
|
98 |
+
m0, m = 1, 2
|
99 |
+
if norm == 'ortho':
|
100 |
+
m0 = np.sqrt(1.0/M)
|
101 |
+
m = np.sqrt(2.0/M)
|
102 |
+
for k in range(N):
|
103 |
+
for n in range(1, N-1):
|
104 |
+
y[k] += m*x[n]*np.cos(np.pi*n*k/M)
|
105 |
+
y[k] += m0 * x[0]
|
106 |
+
y[k] += m0 * x[N-1] * (1 if k % 2 == 0 else -1)
|
107 |
+
if norm == 'ortho':
|
108 |
+
y[0] *= 1/np.sqrt(2)
|
109 |
+
y[N-1] *= 1/np.sqrt(2)
|
110 |
+
return y
|
111 |
+
|
112 |
+
|
113 |
+
def naive_dst1(x, norm=None):
|
114 |
+
"""Calculate textbook definition version of DST-I."""
|
115 |
+
x = np.array(x, copy=True)
|
116 |
+
N = len(x)
|
117 |
+
M = N+1
|
118 |
+
y = np.zeros(N)
|
119 |
+
for k in range(N):
|
120 |
+
for n in range(N):
|
121 |
+
y[k] += 2*x[n]*np.sin(np.pi*(n+1.0)*(k+1.0)/M)
|
122 |
+
if norm == 'ortho':
|
123 |
+
y *= np.sqrt(0.5/M)
|
124 |
+
return y
|
125 |
+
|
126 |
+
|
127 |
+
def naive_dct4(x, norm=None):
|
128 |
+
"""Calculate textbook definition version of DCT-IV."""
|
129 |
+
x = np.array(x, copy=True)
|
130 |
+
N = len(x)
|
131 |
+
y = np.zeros(N)
|
132 |
+
for k in range(N):
|
133 |
+
for n in range(N):
|
134 |
+
y[k] += x[n]*np.cos(np.pi*(n+0.5)*(k+0.5)/(N))
|
135 |
+
if norm == 'ortho':
|
136 |
+
y *= np.sqrt(2.0/N)
|
137 |
+
else:
|
138 |
+
y *= 2
|
139 |
+
return y
|
140 |
+
|
141 |
+
|
142 |
+
def naive_dst4(x, norm=None):
|
143 |
+
"""Calculate textbook definition version of DST-IV."""
|
144 |
+
x = np.array(x, copy=True)
|
145 |
+
N = len(x)
|
146 |
+
y = np.zeros(N)
|
147 |
+
for k in range(N):
|
148 |
+
for n in range(N):
|
149 |
+
y[k] += x[n]*np.sin(np.pi*(n+0.5)*(k+0.5)/(N))
|
150 |
+
if norm == 'ortho':
|
151 |
+
y *= np.sqrt(2.0/N)
|
152 |
+
else:
|
153 |
+
y *= 2
|
154 |
+
return y
|
155 |
+
|
156 |
+
|
157 |
+
class TestComplex:
|
158 |
+
def test_dct_complex64(self):
|
159 |
+
y = dct(1j*np.arange(5, dtype=np.complex64))
|
160 |
+
x = 1j*dct(np.arange(5))
|
161 |
+
assert_array_almost_equal(x, y)
|
162 |
+
|
163 |
+
def test_dct_complex(self):
|
164 |
+
y = dct(np.arange(5)*1j)
|
165 |
+
x = 1j*dct(np.arange(5))
|
166 |
+
assert_array_almost_equal(x, y)
|
167 |
+
|
168 |
+
def test_idct_complex(self):
|
169 |
+
y = idct(np.arange(5)*1j)
|
170 |
+
x = 1j*idct(np.arange(5))
|
171 |
+
assert_array_almost_equal(x, y)
|
172 |
+
|
173 |
+
def test_dst_complex64(self):
|
174 |
+
y = dst(np.arange(5, dtype=np.complex64)*1j)
|
175 |
+
x = 1j*dst(np.arange(5))
|
176 |
+
assert_array_almost_equal(x, y)
|
177 |
+
|
178 |
+
def test_dst_complex(self):
|
179 |
+
y = dst(np.arange(5)*1j)
|
180 |
+
x = 1j*dst(np.arange(5))
|
181 |
+
assert_array_almost_equal(x, y)
|
182 |
+
|
183 |
+
def test_idst_complex(self):
|
184 |
+
y = idst(np.arange(5)*1j)
|
185 |
+
x = 1j*idst(np.arange(5))
|
186 |
+
assert_array_almost_equal(x, y)
|
187 |
+
|
188 |
+
|
189 |
+
class _TestDCTBase:
|
190 |
+
def setup_method(self):
|
191 |
+
self.rdt = None
|
192 |
+
self.dec = 14
|
193 |
+
self.type = None
|
194 |
+
|
195 |
+
def test_definition(self):
|
196 |
+
for i in FFTWDATA_SIZES:
|
197 |
+
x, yr, dt = fftw_dct_ref(self.type, i, self.rdt)
|
198 |
+
y = dct(x, type=self.type)
|
199 |
+
assert_equal(y.dtype, dt)
|
200 |
+
# XXX: we divide by np.max(y) because the tests fail otherwise. We
|
201 |
+
# should really use something like assert_array_approx_equal. The
|
202 |
+
# difference is due to fftw using a better algorithm w.r.t error
|
203 |
+
# propagation compared to the ones from fftpack.
|
204 |
+
assert_array_almost_equal(y / np.max(y), yr / np.max(y), decimal=self.dec,
|
205 |
+
err_msg="Size %d failed" % i)
|
206 |
+
|
207 |
+
def test_axis(self):
|
208 |
+
nt = 2
|
209 |
+
for i in [7, 8, 9, 16, 32, 64]:
|
210 |
+
x = np.random.randn(nt, i)
|
211 |
+
y = dct(x, type=self.type)
|
212 |
+
for j in range(nt):
|
213 |
+
assert_array_almost_equal(y[j], dct(x[j], type=self.type),
|
214 |
+
decimal=self.dec)
|
215 |
+
|
216 |
+
x = x.T
|
217 |
+
y = dct(x, axis=0, type=self.type)
|
218 |
+
for j in range(nt):
|
219 |
+
assert_array_almost_equal(y[:,j], dct(x[:,j], type=self.type),
|
220 |
+
decimal=self.dec)
|
221 |
+
|
222 |
+
|
223 |
+
class _TestDCTIBase(_TestDCTBase):
|
224 |
+
def test_definition_ortho(self):
|
225 |
+
# Test orthornomal mode.
|
226 |
+
dt = np.result_type(np.float32, self.rdt)
|
227 |
+
for xr in X:
|
228 |
+
x = np.array(xr, dtype=self.rdt)
|
229 |
+
y = dct(x, norm='ortho', type=1)
|
230 |
+
y2 = naive_dct1(x, norm='ortho')
|
231 |
+
assert_equal(y.dtype, dt)
|
232 |
+
assert_array_almost_equal(y / np.max(y), y2 / np.max(y), decimal=self.dec)
|
233 |
+
|
234 |
+
class _TestDCTIIBase(_TestDCTBase):
|
235 |
+
def test_definition_matlab(self):
|
236 |
+
# Test correspondence with MATLAB (orthornomal mode).
|
237 |
+
dt = np.result_type(np.float32, self.rdt)
|
238 |
+
for xr, yr in zip(X, Y):
|
239 |
+
x = np.array(xr, dtype=dt)
|
240 |
+
y = dct(x, norm="ortho", type=2)
|
241 |
+
assert_equal(y.dtype, dt)
|
242 |
+
assert_array_almost_equal(y, yr, decimal=self.dec)
|
243 |
+
|
244 |
+
|
245 |
+
class _TestDCTIIIBase(_TestDCTBase):
|
246 |
+
def test_definition_ortho(self):
|
247 |
+
# Test orthornomal mode.
|
248 |
+
dt = np.result_type(np.float32, self.rdt)
|
249 |
+
for xr in X:
|
250 |
+
x = np.array(xr, dtype=self.rdt)
|
251 |
+
y = dct(x, norm='ortho', type=2)
|
252 |
+
xi = dct(y, norm="ortho", type=3)
|
253 |
+
assert_equal(xi.dtype, dt)
|
254 |
+
assert_array_almost_equal(xi, x, decimal=self.dec)
|
255 |
+
|
256 |
+
class _TestDCTIVBase(_TestDCTBase):
|
257 |
+
def test_definition_ortho(self):
|
258 |
+
# Test orthornomal mode.
|
259 |
+
dt = np.result_type(np.float32, self.rdt)
|
260 |
+
for xr in X:
|
261 |
+
x = np.array(xr, dtype=self.rdt)
|
262 |
+
y = dct(x, norm='ortho', type=4)
|
263 |
+
y2 = naive_dct4(x, norm='ortho')
|
264 |
+
assert_equal(y.dtype, dt)
|
265 |
+
assert_array_almost_equal(y / np.max(y), y2 / np.max(y), decimal=self.dec)
|
266 |
+
|
267 |
+
|
268 |
+
class TestDCTIDouble(_TestDCTIBase):
|
269 |
+
def setup_method(self):
|
270 |
+
self.rdt = np.float64
|
271 |
+
self.dec = 10
|
272 |
+
self.type = 1
|
273 |
+
|
274 |
+
|
275 |
+
class TestDCTIFloat(_TestDCTIBase):
|
276 |
+
def setup_method(self):
|
277 |
+
self.rdt = np.float32
|
278 |
+
self.dec = 4
|
279 |
+
self.type = 1
|
280 |
+
|
281 |
+
|
282 |
+
class TestDCTIInt(_TestDCTIBase):
|
283 |
+
def setup_method(self):
|
284 |
+
self.rdt = int
|
285 |
+
self.dec = 5
|
286 |
+
self.type = 1
|
287 |
+
|
288 |
+
|
289 |
+
class TestDCTIIDouble(_TestDCTIIBase):
|
290 |
+
def setup_method(self):
|
291 |
+
self.rdt = np.float64
|
292 |
+
self.dec = 10
|
293 |
+
self.type = 2
|
294 |
+
|
295 |
+
|
296 |
+
class TestDCTIIFloat(_TestDCTIIBase):
|
297 |
+
def setup_method(self):
|
298 |
+
self.rdt = np.float32
|
299 |
+
self.dec = 5
|
300 |
+
self.type = 2
|
301 |
+
|
302 |
+
|
303 |
+
class TestDCTIIInt(_TestDCTIIBase):
|
304 |
+
def setup_method(self):
|
305 |
+
self.rdt = int
|
306 |
+
self.dec = 5
|
307 |
+
self.type = 2
|
308 |
+
|
309 |
+
|
310 |
+
class TestDCTIIIDouble(_TestDCTIIIBase):
|
311 |
+
def setup_method(self):
|
312 |
+
self.rdt = np.float64
|
313 |
+
self.dec = 14
|
314 |
+
self.type = 3
|
315 |
+
|
316 |
+
|
317 |
+
class TestDCTIIIFloat(_TestDCTIIIBase):
|
318 |
+
def setup_method(self):
|
319 |
+
self.rdt = np.float32
|
320 |
+
self.dec = 5
|
321 |
+
self.type = 3
|
322 |
+
|
323 |
+
|
324 |
+
class TestDCTIIIInt(_TestDCTIIIBase):
|
325 |
+
def setup_method(self):
|
326 |
+
self.rdt = int
|
327 |
+
self.dec = 5
|
328 |
+
self.type = 3
|
329 |
+
|
330 |
+
|
331 |
+
class TestDCTIVDouble(_TestDCTIVBase):
|
332 |
+
def setup_method(self):
|
333 |
+
self.rdt = np.float64
|
334 |
+
self.dec = 12
|
335 |
+
self.type = 3
|
336 |
+
|
337 |
+
|
338 |
+
class TestDCTIVFloat(_TestDCTIVBase):
|
339 |
+
def setup_method(self):
|
340 |
+
self.rdt = np.float32
|
341 |
+
self.dec = 5
|
342 |
+
self.type = 3
|
343 |
+
|
344 |
+
|
345 |
+
class TestDCTIVInt(_TestDCTIVBase):
|
346 |
+
def setup_method(self):
|
347 |
+
self.rdt = int
|
348 |
+
self.dec = 5
|
349 |
+
self.type = 3
|
350 |
+
|
351 |
+
|
352 |
+
class _TestIDCTBase:
|
353 |
+
def setup_method(self):
|
354 |
+
self.rdt = None
|
355 |
+
self.dec = 14
|
356 |
+
self.type = None
|
357 |
+
|
358 |
+
def test_definition(self):
|
359 |
+
for i in FFTWDATA_SIZES:
|
360 |
+
xr, yr, dt = fftw_dct_ref(self.type, i, self.rdt)
|
361 |
+
x = idct(yr, type=self.type)
|
362 |
+
if self.type == 1:
|
363 |
+
x /= 2 * (i-1)
|
364 |
+
else:
|
365 |
+
x /= 2 * i
|
366 |
+
assert_equal(x.dtype, dt)
|
367 |
+
# XXX: we divide by np.max(y) because the tests fail otherwise. We
|
368 |
+
# should really use something like assert_array_approx_equal. The
|
369 |
+
# difference is due to fftw using a better algorithm w.r.t error
|
370 |
+
# propagation compared to the ones from fftpack.
|
371 |
+
assert_array_almost_equal(x / np.max(x), xr / np.max(x), decimal=self.dec,
|
372 |
+
err_msg="Size %d failed" % i)
|
373 |
+
|
374 |
+
|
375 |
+
class TestIDCTIDouble(_TestIDCTBase):
|
376 |
+
def setup_method(self):
|
377 |
+
self.rdt = np.float64
|
378 |
+
self.dec = 10
|
379 |
+
self.type = 1
|
380 |
+
|
381 |
+
|
382 |
+
class TestIDCTIFloat(_TestIDCTBase):
|
383 |
+
def setup_method(self):
|
384 |
+
self.rdt = np.float32
|
385 |
+
self.dec = 4
|
386 |
+
self.type = 1
|
387 |
+
|
388 |
+
|
389 |
+
class TestIDCTIInt(_TestIDCTBase):
|
390 |
+
def setup_method(self):
|
391 |
+
self.rdt = int
|
392 |
+
self.dec = 4
|
393 |
+
self.type = 1
|
394 |
+
|
395 |
+
|
396 |
+
class TestIDCTIIDouble(_TestIDCTBase):
|
397 |
+
def setup_method(self):
|
398 |
+
self.rdt = np.float64
|
399 |
+
self.dec = 10
|
400 |
+
self.type = 2
|
401 |
+
|
402 |
+
|
403 |
+
class TestIDCTIIFloat(_TestIDCTBase):
|
404 |
+
def setup_method(self):
|
405 |
+
self.rdt = np.float32
|
406 |
+
self.dec = 5
|
407 |
+
self.type = 2
|
408 |
+
|
409 |
+
|
410 |
+
class TestIDCTIIInt(_TestIDCTBase):
|
411 |
+
def setup_method(self):
|
412 |
+
self.rdt = int
|
413 |
+
self.dec = 5
|
414 |
+
self.type = 2
|
415 |
+
|
416 |
+
|
417 |
+
class TestIDCTIIIDouble(_TestIDCTBase):
|
418 |
+
def setup_method(self):
|
419 |
+
self.rdt = np.float64
|
420 |
+
self.dec = 14
|
421 |
+
self.type = 3
|
422 |
+
|
423 |
+
|
424 |
+
class TestIDCTIIIFloat(_TestIDCTBase):
|
425 |
+
def setup_method(self):
|
426 |
+
self.rdt = np.float32
|
427 |
+
self.dec = 5
|
428 |
+
self.type = 3
|
429 |
+
|
430 |
+
|
431 |
+
class TestIDCTIIIInt(_TestIDCTBase):
|
432 |
+
def setup_method(self):
|
433 |
+
self.rdt = int
|
434 |
+
self.dec = 5
|
435 |
+
self.type = 3
|
436 |
+
|
437 |
+
class TestIDCTIVDouble(_TestIDCTBase):
|
438 |
+
def setup_method(self):
|
439 |
+
self.rdt = np.float64
|
440 |
+
self.dec = 12
|
441 |
+
self.type = 4
|
442 |
+
|
443 |
+
|
444 |
+
class TestIDCTIVFloat(_TestIDCTBase):
|
445 |
+
def setup_method(self):
|
446 |
+
self.rdt = np.float32
|
447 |
+
self.dec = 5
|
448 |
+
self.type = 4
|
449 |
+
|
450 |
+
|
451 |
+
class TestIDCTIVInt(_TestIDCTBase):
|
452 |
+
def setup_method(self):
|
453 |
+
self.rdt = int
|
454 |
+
self.dec = 5
|
455 |
+
self.type = 4
|
456 |
+
|
457 |
+
class _TestDSTBase:
|
458 |
+
def setup_method(self):
|
459 |
+
self.rdt = None # dtype
|
460 |
+
self.dec = None # number of decimals to match
|
461 |
+
self.type = None # dst type
|
462 |
+
|
463 |
+
def test_definition(self):
|
464 |
+
for i in FFTWDATA_SIZES:
|
465 |
+
xr, yr, dt = fftw_dst_ref(self.type, i, self.rdt)
|
466 |
+
y = dst(xr, type=self.type)
|
467 |
+
assert_equal(y.dtype, dt)
|
468 |
+
# XXX: we divide by np.max(y) because the tests fail otherwise. We
|
469 |
+
# should really use something like assert_array_approx_equal. The
|
470 |
+
# difference is due to fftw using a better algorithm w.r.t error
|
471 |
+
# propagation compared to the ones from fftpack.
|
472 |
+
assert_array_almost_equal(y / np.max(y), yr / np.max(y), decimal=self.dec,
|
473 |
+
err_msg="Size %d failed" % i)
|
474 |
+
|
475 |
+
|
476 |
+
class _TestDSTIBase(_TestDSTBase):
|
477 |
+
def test_definition_ortho(self):
|
478 |
+
# Test orthornomal mode.
|
479 |
+
dt = np.result_type(np.float32, self.rdt)
|
480 |
+
for xr in X:
|
481 |
+
x = np.array(xr, dtype=self.rdt)
|
482 |
+
y = dst(x, norm='ortho', type=1)
|
483 |
+
y2 = naive_dst1(x, norm='ortho')
|
484 |
+
assert_equal(y.dtype, dt)
|
485 |
+
assert_array_almost_equal(y / np.max(y), y2 / np.max(y), decimal=self.dec)
|
486 |
+
|
487 |
+
class _TestDSTIVBase(_TestDSTBase):
|
488 |
+
def test_definition_ortho(self):
|
489 |
+
# Test orthornomal mode.
|
490 |
+
dt = np.result_type(np.float32, self.rdt)
|
491 |
+
for xr in X:
|
492 |
+
x = np.array(xr, dtype=self.rdt)
|
493 |
+
y = dst(x, norm='ortho', type=4)
|
494 |
+
y2 = naive_dst4(x, norm='ortho')
|
495 |
+
assert_equal(y.dtype, dt)
|
496 |
+
assert_array_almost_equal(y, y2, decimal=self.dec)
|
497 |
+
|
498 |
+
class TestDSTIDouble(_TestDSTIBase):
|
499 |
+
def setup_method(self):
|
500 |
+
self.rdt = np.float64
|
501 |
+
self.dec = 12
|
502 |
+
self.type = 1
|
503 |
+
|
504 |
+
|
505 |
+
class TestDSTIFloat(_TestDSTIBase):
|
506 |
+
def setup_method(self):
|
507 |
+
self.rdt = np.float32
|
508 |
+
self.dec = 4
|
509 |
+
self.type = 1
|
510 |
+
|
511 |
+
|
512 |
+
class TestDSTIInt(_TestDSTIBase):
|
513 |
+
def setup_method(self):
|
514 |
+
self.rdt = int
|
515 |
+
self.dec = 5
|
516 |
+
self.type = 1
|
517 |
+
|
518 |
+
|
519 |
+
class TestDSTIIDouble(_TestDSTBase):
|
520 |
+
def setup_method(self):
|
521 |
+
self.rdt = np.float64
|
522 |
+
self.dec = 14
|
523 |
+
self.type = 2
|
524 |
+
|
525 |
+
|
526 |
+
class TestDSTIIFloat(_TestDSTBase):
|
527 |
+
def setup_method(self):
|
528 |
+
self.rdt = np.float32
|
529 |
+
self.dec = 6
|
530 |
+
self.type = 2
|
531 |
+
|
532 |
+
|
533 |
+
class TestDSTIIInt(_TestDSTBase):
|
534 |
+
def setup_method(self):
|
535 |
+
self.rdt = int
|
536 |
+
self.dec = 6
|
537 |
+
self.type = 2
|
538 |
+
|
539 |
+
|
540 |
+
class TestDSTIIIDouble(_TestDSTBase):
|
541 |
+
def setup_method(self):
|
542 |
+
self.rdt = np.float64
|
543 |
+
self.dec = 14
|
544 |
+
self.type = 3
|
545 |
+
|
546 |
+
|
547 |
+
class TestDSTIIIFloat(_TestDSTBase):
|
548 |
+
def setup_method(self):
|
549 |
+
self.rdt = np.float32
|
550 |
+
self.dec = 7
|
551 |
+
self.type = 3
|
552 |
+
|
553 |
+
|
554 |
+
class TestDSTIIIInt(_TestDSTBase):
|
555 |
+
def setup_method(self):
|
556 |
+
self.rdt = int
|
557 |
+
self.dec = 7
|
558 |
+
self.type = 3
|
559 |
+
|
560 |
+
|
561 |
+
class TestDSTIVDouble(_TestDSTIVBase):
|
562 |
+
def setup_method(self):
|
563 |
+
self.rdt = np.float64
|
564 |
+
self.dec = 12
|
565 |
+
self.type = 4
|
566 |
+
|
567 |
+
|
568 |
+
class TestDSTIVFloat(_TestDSTIVBase):
|
569 |
+
def setup_method(self):
|
570 |
+
self.rdt = np.float32
|
571 |
+
self.dec = 4
|
572 |
+
self.type = 4
|
573 |
+
|
574 |
+
|
575 |
+
class TestDSTIVInt(_TestDSTIVBase):
|
576 |
+
def setup_method(self):
|
577 |
+
self.rdt = int
|
578 |
+
self.dec = 5
|
579 |
+
self.type = 4
|
580 |
+
|
581 |
+
|
582 |
+
class _TestIDSTBase:
|
583 |
+
def setup_method(self):
|
584 |
+
self.rdt = None
|
585 |
+
self.dec = None
|
586 |
+
self.type = None
|
587 |
+
|
588 |
+
def test_definition(self):
|
589 |
+
for i in FFTWDATA_SIZES:
|
590 |
+
xr, yr, dt = fftw_dst_ref(self.type, i, self.rdt)
|
591 |
+
x = idst(yr, type=self.type)
|
592 |
+
if self.type == 1:
|
593 |
+
x /= 2 * (i+1)
|
594 |
+
else:
|
595 |
+
x /= 2 * i
|
596 |
+
assert_equal(x.dtype, dt)
|
597 |
+
# XXX: we divide by np.max(x) because the tests fail otherwise. We
|
598 |
+
# should really use something like assert_array_approx_equal. The
|
599 |
+
# difference is due to fftw using a better algorithm w.r.t error
|
600 |
+
# propagation compared to the ones from fftpack.
|
601 |
+
assert_array_almost_equal(x / np.max(x), xr / np.max(x), decimal=self.dec,
|
602 |
+
err_msg="Size %d failed" % i)
|
603 |
+
|
604 |
+
|
605 |
+
class TestIDSTIDouble(_TestIDSTBase):
|
606 |
+
def setup_method(self):
|
607 |
+
self.rdt = np.float64
|
608 |
+
self.dec = 12
|
609 |
+
self.type = 1
|
610 |
+
|
611 |
+
|
612 |
+
class TestIDSTIFloat(_TestIDSTBase):
|
613 |
+
def setup_method(self):
|
614 |
+
self.rdt = np.float32
|
615 |
+
self.dec = 4
|
616 |
+
self.type = 1
|
617 |
+
|
618 |
+
|
619 |
+
class TestIDSTIInt(_TestIDSTBase):
|
620 |
+
def setup_method(self):
|
621 |
+
self.rdt = int
|
622 |
+
self.dec = 4
|
623 |
+
self.type = 1
|
624 |
+
|
625 |
+
|
626 |
+
class TestIDSTIIDouble(_TestIDSTBase):
|
627 |
+
def setup_method(self):
|
628 |
+
self.rdt = np.float64
|
629 |
+
self.dec = 14
|
630 |
+
self.type = 2
|
631 |
+
|
632 |
+
|
633 |
+
class TestIDSTIIFloat(_TestIDSTBase):
|
634 |
+
def setup_method(self):
|
635 |
+
self.rdt = np.float32
|
636 |
+
self.dec = 6
|
637 |
+
self.type = 2
|
638 |
+
|
639 |
+
|
640 |
+
class TestIDSTIIInt(_TestIDSTBase):
|
641 |
+
def setup_method(self):
|
642 |
+
self.rdt = int
|
643 |
+
self.dec = 6
|
644 |
+
self.type = 2
|
645 |
+
|
646 |
+
|
647 |
+
class TestIDSTIIIDouble(_TestIDSTBase):
|
648 |
+
def setup_method(self):
|
649 |
+
self.rdt = np.float64
|
650 |
+
self.dec = 14
|
651 |
+
self.type = 3
|
652 |
+
|
653 |
+
|
654 |
+
class TestIDSTIIIFloat(_TestIDSTBase):
|
655 |
+
def setup_method(self):
|
656 |
+
self.rdt = np.float32
|
657 |
+
self.dec = 6
|
658 |
+
self.type = 3
|
659 |
+
|
660 |
+
|
661 |
+
class TestIDSTIIIInt(_TestIDSTBase):
|
662 |
+
def setup_method(self):
|
663 |
+
self.rdt = int
|
664 |
+
self.dec = 6
|
665 |
+
self.type = 3
|
666 |
+
|
667 |
+
|
668 |
+
class TestIDSTIVDouble(_TestIDSTBase):
|
669 |
+
def setup_method(self):
|
670 |
+
self.rdt = np.float64
|
671 |
+
self.dec = 12
|
672 |
+
self.type = 4
|
673 |
+
|
674 |
+
|
675 |
+
class TestIDSTIVFloat(_TestIDSTBase):
|
676 |
+
def setup_method(self):
|
677 |
+
self.rdt = np.float32
|
678 |
+
self.dec = 6
|
679 |
+
self.type = 4
|
680 |
+
|
681 |
+
|
682 |
+
class TestIDSTIVnt(_TestIDSTBase):
|
683 |
+
def setup_method(self):
|
684 |
+
self.rdt = int
|
685 |
+
self.dec = 6
|
686 |
+
self.type = 4
|
687 |
+
|
688 |
+
|
689 |
+
class TestOverwrite:
|
690 |
+
"""Check input overwrite behavior."""
|
691 |
+
|
692 |
+
real_dtypes = [np.float32, np.float64]
|
693 |
+
|
694 |
+
def _check(self, x, routine, type, fftsize, axis, norm, overwrite_x, **kw):
|
695 |
+
x2 = x.copy()
|
696 |
+
routine(x2, type, fftsize, axis, norm, overwrite_x=overwrite_x)
|
697 |
+
|
698 |
+
sig = "{}({}{!r}, {!r}, axis={!r}, overwrite_x={!r})".format(
|
699 |
+
routine.__name__, x.dtype, x.shape, fftsize, axis, overwrite_x)
|
700 |
+
if not overwrite_x:
|
701 |
+
assert_equal(x2, x, err_msg="spurious overwrite in %s" % sig)
|
702 |
+
|
703 |
+
def _check_1d(self, routine, dtype, shape, axis):
|
704 |
+
np.random.seed(1234)
|
705 |
+
if np.issubdtype(dtype, np.complexfloating):
|
706 |
+
data = np.random.randn(*shape) + 1j*np.random.randn(*shape)
|
707 |
+
else:
|
708 |
+
data = np.random.randn(*shape)
|
709 |
+
data = data.astype(dtype)
|
710 |
+
|
711 |
+
for type in [1, 2, 3, 4]:
|
712 |
+
for overwrite_x in [True, False]:
|
713 |
+
for norm in [None, 'ortho']:
|
714 |
+
self._check(data, routine, type, None, axis, norm,
|
715 |
+
overwrite_x)
|
716 |
+
|
717 |
+
def test_dct(self):
|
718 |
+
for dtype in self.real_dtypes:
|
719 |
+
self._check_1d(dct, dtype, (16,), -1)
|
720 |
+
self._check_1d(dct, dtype, (16, 2), 0)
|
721 |
+
self._check_1d(dct, dtype, (2, 16), 1)
|
722 |
+
|
723 |
+
def test_idct(self):
|
724 |
+
for dtype in self.real_dtypes:
|
725 |
+
self._check_1d(idct, dtype, (16,), -1)
|
726 |
+
self._check_1d(idct, dtype, (16, 2), 0)
|
727 |
+
self._check_1d(idct, dtype, (2, 16), 1)
|
728 |
+
|
729 |
+
def test_dst(self):
|
730 |
+
for dtype in self.real_dtypes:
|
731 |
+
self._check_1d(dst, dtype, (16,), -1)
|
732 |
+
self._check_1d(dst, dtype, (16, 2), 0)
|
733 |
+
self._check_1d(dst, dtype, (2, 16), 1)
|
734 |
+
|
735 |
+
def test_idst(self):
|
736 |
+
for dtype in self.real_dtypes:
|
737 |
+
self._check_1d(idst, dtype, (16,), -1)
|
738 |
+
self._check_1d(idst, dtype, (16, 2), 0)
|
739 |
+
self._check_1d(idst, dtype, (2, 16), 1)
|
740 |
+
|
741 |
+
|
742 |
+
class Test_DCTN_IDCTN:
|
743 |
+
dec = 14
|
744 |
+
dct_type = [1, 2, 3, 4]
|
745 |
+
norms = [None, 'ortho']
|
746 |
+
rstate = np.random.RandomState(1234)
|
747 |
+
shape = (32, 16)
|
748 |
+
data = rstate.randn(*shape)
|
749 |
+
|
750 |
+
@pytest.mark.parametrize('fforward,finverse', [(dctn, idctn),
|
751 |
+
(dstn, idstn)])
|
752 |
+
@pytest.mark.parametrize('axes', [None,
|
753 |
+
1, (1,), [1],
|
754 |
+
0, (0,), [0],
|
755 |
+
(0, 1), [0, 1],
|
756 |
+
(-2, -1), [-2, -1]])
|
757 |
+
@pytest.mark.parametrize('dct_type', dct_type)
|
758 |
+
@pytest.mark.parametrize('norm', ['ortho'])
|
759 |
+
def test_axes_round_trip(self, fforward, finverse, axes, dct_type, norm):
|
760 |
+
tmp = fforward(self.data, type=dct_type, axes=axes, norm=norm)
|
761 |
+
tmp = finverse(tmp, type=dct_type, axes=axes, norm=norm)
|
762 |
+
assert_array_almost_equal(self.data, tmp, decimal=12)
|
763 |
+
|
764 |
+
@pytest.mark.parametrize('fforward,fforward_ref', [(dctn, dct_2d_ref),
|
765 |
+
(dstn, dst_2d_ref)])
|
766 |
+
@pytest.mark.parametrize('dct_type', dct_type)
|
767 |
+
@pytest.mark.parametrize('norm', norms)
|
768 |
+
def test_dctn_vs_2d_reference(self, fforward, fforward_ref,
|
769 |
+
dct_type, norm):
|
770 |
+
y1 = fforward(self.data, type=dct_type, axes=None, norm=norm)
|
771 |
+
y2 = fforward_ref(self.data, type=dct_type, norm=norm)
|
772 |
+
assert_array_almost_equal(y1, y2, decimal=11)
|
773 |
+
|
774 |
+
@pytest.mark.parametrize('finverse,finverse_ref', [(idctn, idct_2d_ref),
|
775 |
+
(idstn, idst_2d_ref)])
|
776 |
+
@pytest.mark.parametrize('dct_type', dct_type)
|
777 |
+
@pytest.mark.parametrize('norm', [None, 'ortho'])
|
778 |
+
def test_idctn_vs_2d_reference(self, finverse, finverse_ref,
|
779 |
+
dct_type, norm):
|
780 |
+
fdata = dctn(self.data, type=dct_type, norm=norm)
|
781 |
+
y1 = finverse(fdata, type=dct_type, norm=norm)
|
782 |
+
y2 = finverse_ref(fdata, type=dct_type, norm=norm)
|
783 |
+
assert_array_almost_equal(y1, y2, decimal=11)
|
784 |
+
|
785 |
+
@pytest.mark.parametrize('fforward,finverse', [(dctn, idctn),
|
786 |
+
(dstn, idstn)])
|
787 |
+
def test_axes_and_shape(self, fforward, finverse):
|
788 |
+
with assert_raises(ValueError,
|
789 |
+
match="when given, axes and shape arguments"
|
790 |
+
" have to be of the same length"):
|
791 |
+
fforward(self.data, shape=self.data.shape[0], axes=(0, 1))
|
792 |
+
|
793 |
+
with assert_raises(ValueError,
|
794 |
+
match="when given, axes and shape arguments"
|
795 |
+
" have to be of the same length"):
|
796 |
+
fforward(self.data, shape=self.data.shape[0], axes=None)
|
797 |
+
|
798 |
+
with assert_raises(ValueError,
|
799 |
+
match="when given, axes and shape arguments"
|
800 |
+
" have to be of the same length"):
|
801 |
+
fforward(self.data, shape=self.data.shape, axes=0)
|
802 |
+
|
803 |
+
@pytest.mark.parametrize('fforward', [dctn, dstn])
|
804 |
+
def test_shape(self, fforward):
|
805 |
+
tmp = fforward(self.data, shape=(128, 128), axes=None)
|
806 |
+
assert_equal(tmp.shape, (128, 128))
|
807 |
+
|
808 |
+
@pytest.mark.parametrize('fforward,finverse', [(dctn, idctn),
|
809 |
+
(dstn, idstn)])
|
810 |
+
@pytest.mark.parametrize('axes', [1, (1,), [1],
|
811 |
+
0, (0,), [0]])
|
812 |
+
def test_shape_is_none_with_axes(self, fforward, finverse, axes):
|
813 |
+
tmp = fforward(self.data, shape=None, axes=axes, norm='ortho')
|
814 |
+
tmp = finverse(tmp, shape=None, axes=axes, norm='ortho')
|
815 |
+
assert_array_almost_equal(self.data, tmp, decimal=self.dec)
|
venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (3.98 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/_geometric_slerp.cpython-310.pyc
ADDED
Binary file (7.22 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/_kdtree.cpython-310.pyc
ADDED
Binary file (34.4 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/_plotutils.cpython-310.pyc
ADDED
Binary file (6.68 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/_procrustes.cpython-310.pyc
ADDED
Binary file (4.27 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/_spherical_voronoi.cpython-310.pyc
ADDED
Binary file (11.9 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/ckdtree.cpython-310.pyc
ADDED
Binary file (679 Bytes). View file
|
|
venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/distance.cpython-310.pyc
ADDED
Binary file (80.5 kB). View file
|
|
venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/kdtree.cpython-310.pyc
ADDED
Binary file (694 Bytes). View file
|
|
venv/lib/python3.10/site-packages/scipy/spatial/__pycache__/qhull.cpython-310.pyc
ADDED
Binary file (666 Bytes). View file
|
|
venv/lib/python3.10/site-packages/scipy/spatial/tests/data/cdist-X1.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1.147593763490969421e-01 8.926156143344999849e-01 1.437758624645746330e-02 1.803435962879929022e-02 5.533046214065578949e-01 5.554315640747428118e-01 4.497546637814608950e-02 4.438089247948049376e-01 7.984582810220538507e-01 2.752880789161644692e-01 1.344667112315823809e-01 9.230479561452992199e-01 6.040471462941819913e-01 3.797251652770228247e-01 4.316042735592399149e-01 5.312356915348823705e-01 4.348143005129563310e-01 3.111531488508799681e-01 9.531194313908697424e-04 8.212995023500069269e-02 6.689953269869852726e-01 9.914864535288493430e-01 8.037556036341153565e-01
|
2 |
+
9.608925123801395074e-01 2.974451233678974127e-01 9.001110330654185088e-01 5.824163330415995654e-01 7.308574928293812834e-01 2.276154562412870952e-01 7.306791076039623745e-01 8.677244866905511333e-01 9.160806456176984192e-01 6.157216959991280714e-01 5.149053524695440531e-01 3.056427344890983999e-01 9.790557366933895223e-01 4.484995861076724877e-01 4.776550391081165747e-01 7.210436977670631187e-01 9.136399501661039979e-01 4.260275733550000776e-02 5.943900041968954717e-01 3.864571606342745991e-01 9.442027665110838131e-01 4.779949058608601309e-02 6.107551944250865228e-01
|
3 |
+
3.297286578103622023e-01 5.980207401936733502e-01 3.673301293561567205e-01 2.585830520887681949e-01 4.660558746104259686e-01 6.083795956610364986e-01 4.535206368070313632e-01 6.873989778785424276e-01 5.130152688495458468e-01 7.665877846542720198e-01 3.444402973525138023e-01 3.583658123644906102e-02 7.924818220986856732e-01 8.746685720522412444e-01 3.010105569182431884e-01 6.012239357385538163e-01 6.233737362204671006e-01 4.830438698668915176e-01 2.317286885842551047e-02 7.585989958123050547e-01 7.108257632278830451e-01 1.551024884178199281e-01 2.665485998155288083e-01
|
4 |
+
2.456278068903017253e-02 4.148739837711815648e-01 1.986372227934196655e-01 6.920408530298168825e-01 1.003067576685774398e-01 7.421560456480125190e-01 1.808453980608998313e-01 4.251297882537475870e-01 6.773002683522370004e-01 4.084108792570182445e-01 7.462888013191590897e-01 8.069930220529277776e-01 9.211110587681808903e-01 4.141491046181076108e-01 7.486318689260342829e-01 9.515405507589296263e-01 4.634288892577109742e-03 8.027593488166355762e-01 3.010346805217798405e-01 8.663248877242523127e-01 2.479968181181605447e-01 5.619851096054278017e-01 3.903886764590250857e-01
|
5 |
+
7.122019976035700584e-01 6.188878051047785878e-01 7.290897087051201320e-01 6.334802157757637442e-01 5.523084734954342156e-01 5.614937129563645213e-01 2.496741051791574462e-01 5.972227939599233926e-01 1.786590597761109622e-01 2.609525984850900038e-01 7.210438943286010538e-01 2.211429064605652250e-01 9.140497572472672250e-02 1.430242193668443962e-01 7.856446942916397447e-01 4.635256358156553125e-01 5.278744289813760426e-01 3.702808015407184072e-01 5.527073830480792038e-01 6.370732917599846168e-01 9.953487928925482953e-01 3.021789770611936765e-01 3.354901923998221402e-02
|
6 |
+
6.509638560895427695e-01 8.387598220902757751e-01 7.761375971745763103e-01 1.481627639227802717e-01 3.529474982902305324e-01 4.883093646287851586e-01 9.652923033658690199e-01 9.500680513565308294e-01 3.061885005078281985e-01 7.271902818906019750e-01 2.358962978196710303e-03 7.359889703223099211e-01 8.988893768074724955e-01 4.135279653937307121e-02 8.516441856688283796e-01 4.889597623270667270e-01 5.575909822114655245e-01 9.010853652261575641e-01 2.912844516556202246e-01 9.088759383368658629e-01 8.104351227460024898e-01 8.080695436776826890e-01 1.430530913253185155e-01
|
7 |
+
8.048001196608134400e-01 3.066089444418462762e-02 9.021887554292090661e-01 6.154331491807940591e-02 1.378912575206647784e-02 5.775720193142440673e-01 1.219298963069791464e-01 1.883270243412101808e-01 5.569262398688379356e-02 8.964817777510125651e-02 7.977092785346929782e-01 4.878149375226197293e-01 4.511973131518809410e-02 1.858690046801604323e-01 6.947686471083162063e-01 5.884058794291086025e-01 8.638884676612634816e-01 3.855470871341656336e-01 3.495049047300468059e-01 2.767740932353948136e-01 4.731087031714035218e-01 6.679001673437914288e-01 7.502944200696660682e-01
|
8 |
+
6.527328264244687261e-01 8.289483383553154505e-01 9.179741348282299818e-01 1.065639864466713105e-01 6.253616929058514184e-01 5.927750325266062381e-01 3.039157425463192563e-01 2.452766763359194302e-01 6.514027700704632107e-01 5.529218485487964463e-01 4.941158239308394151e-01 6.605306467722642516e-01 2.273688037050677346e-01 4.282616592244774534e-01 2.956128257930247250e-01 1.154803628237965896e-01 9.228220410235263849e-01 6.663525307676617659e-01 1.908852615936970087e-01 9.921383408926374159e-01 4.988716450388516188e-01 1.014900352736023414e-01 3.363930180244284474e-01
|
9 |
+
2.914369076275757919e-01 5.196673601143533272e-01 7.420144907858341465e-01 1.768984185504740569e-01 5.296766993228564369e-01 5.922023566159900776e-01 5.965161262020234334e-01 3.810272333046110793e-01 8.368797246118340194e-01 7.896422363801189892e-01 9.655797561098209414e-01 4.430034032346981121e-01 2.780869795706976122e-01 3.047310845416009162e-01 8.051138863500326703e-01 6.731468634690835895e-01 4.743383036815584930e-01 9.530709614322225853e-01 7.753587619850917934e-01 2.801137109357491051e-01 6.182543660889736614e-01 5.005218857766725593e-01 9.071447804755052857e-01
|
10 |
+
2.075071644012620453e-01 4.834950086973934802e-01 3.037011473860764532e-01 6.476084284887700937e-01 8.107195771564194020e-01 7.869075869075803364e-01 6.851234019375299633e-01 3.544187468104398331e-02 4.847673235908021017e-01 5.690262846164507726e-01 1.663354142616256803e-01 9.692796809752548537e-01 4.133441725866372485e-01 6.729167604487583665e-01 3.998813427407297283e-01 8.272617414104491695e-01 2.129248316324727774e-01 6.517004761357130249e-01 7.363013506605019520e-01 4.072375306356985636e-01 4.463336683526665238e-01 5.485059309728204102e-01 1.981745754527846071e-01
|
venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-boolean-inp.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
2 |
+
1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
3 |
+
1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
4 |
+
0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
5 |
+
1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
6 |
+
1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
7 |
+
1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
8 |
+
1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
|
9 |
+
1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
|
10 |
+
1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
11 |
+
0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
12 |
+
1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
13 |
+
1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00
|
14 |
+
1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
|
15 |
+
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
16 |
+
1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00
|
17 |
+
1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
18 |
+
0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
19 |
+
1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
20 |
+
1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-chebyshev-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-chebyshev-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
8.9084734e-01 9.3573853e-01 9.3507398e-01 9.6040691e-01 9.2918157e-01 9.6617342e-01 9.0430930e-01 9.5753424e-01 8.7106898e-01 9.2169905e-01 9.7401159e-01 8.9013416e-01 9.3956689e-01 9.0041896e-01 9.2588355e-01 9.3849417e-01 8.9713468e-01 9.1481804e-01 9.7500539e-01 9.0012586e-01 9.0962559e-01 8.5860091e-01 8.6981095e-01 8.9995771e-01 8.8070172e-01 9.1456657e-01 8.6711474e-01 9.2593917e-01 8.7560376e-01 8.5193121e-01 9.0898542e-01 8.7765302e-01 8.6555584e-01 8.6093485e-01 9.0447028e-01 8.7614405e-01 9.4803522e-01 8.4998062e-01 7.8398996e-01 8.9538612e-01 8.3902291e-01 9.9039470e-01 9.5480519e-01 8.9152195e-01 9.1623329e-01 7.9094921e-01 9.1777100e-01 9.8972335e-01 9.0429093e-01 8.7646362e-01 9.2136649e-01 9.7178177e-01 8.9610979e-01 9.4710327e-01 9.3612450e-01 9.0241499e-01 7.7992538e-01 8.7262126e-01 9.3325183e-01 8.5796531e-01 9.4267977e-01 6.7224167e-01 7.9568368e-01 8.6411267e-01 9.3311642e-01 9.0160114e-01 9.0698887e-01 8.5833256e-01 9.6902830e-01 9.5072298e-01 8.6808495e-01 9.7879599e-01 8.8060729e-01 8.2818573e-01 8.4366706e-01 8.4506700e-01 9.4532981e-01 9.1792306e-01 7.8917825e-01 9.8337805e-01 8.1751613e-01 9.3037855e-01 9.1618832e-01 8.6568874e-01 8.9751397e-01 8.7923710e-01 8.6814329e-01 9.0330164e-01 8.2426213e-01 9.4644643e-01 8.8431293e-01 8.8497426e-01 9.0633818e-01 9.5537161e-01 8.2167575e-01 8.7771053e-01 9.0681167e-01 8.7626143e-01 8.7463464e-01 9.8033940e-01 9.2920881e-01 9.5108549e-01 9.1287466e-01 8.0052218e-01 9.2409517e-01 8.8252650e-01 8.7873923e-01 9.2989402e-01 9.1985043e-01 9.6172646e-01 8.8223856e-01 9.4477822e-01 8.8310948e-01 9.4461306e-01 9.1875210e-01 9.1233363e-01 9.2124013e-01 9.5460897e-01 8.4640982e-01 9.0882657e-01 9.8169468e-01 9.7828355e-01 8.4150533e-01 8.6888923e-01 9.7138825e-01 8.7988144e-01 9.6720910e-01 8.9450147e-01 9.5331584e-01 8.8871809e-01 8.9736685e-01 8.6258146e-01 9.1331565e-01 9.0968870e-01 9.4833654e-01 9.0536967e-01 9.5099871e-01 8.0251958e-01 9.2526150e-01 9.8971957e-01 9.0340947e-01 9.4955892e-01 9.6838162e-01 8.7534901e-01 9.1178797e-01 9.2649154e-01 9.5260993e-01 9.3178143e-01 9.4943000e-01 8.7816171e-01 9.6506542e-01 8.3422958e-01 9.3443585e-01 9.3220084e-01 8.5706573e-01 8.4666325e-01 9.0474744e-01 9.1080644e-01 9.2406899e-01 8.7901768e-01 9.3265263e-01 9.5992829e-01 9.5696271e-01 9.1932272e-01 8.0937044e-01 9.0904917e-01 8.9516756e-01 9.4797906e-01 8.4159421e-01 9.6773901e-01 9.7099825e-01 9.6941820e-01 9.8174088e-01 9.7569951e-01 9.3655362e-01 8.4130333e-01 9.5994549e-01 8.4235414e-01 9.1429418e-01 9.3418117e-01 8.4600977e-01 8.8166496e-01 8.7594776e-01 8.8571112e-01 9.6308174e-01 9.5315927e-01 8.6997519e-01 8.9383032e-01 9.4686804e-01 9.4399596e-01
|
venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cityblock-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cityblock-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
3.2420590e+01 3.3246607e+01 3.0526910e+01 3.5166573e+01 3.1868301e+01 3.6025002e+01 3.2513623e+01 3.6557796e+01 3.3752212e+01 3.4422130e+01 3.2526018e+01 3.2581161e+01 3.3743555e+01 3.6960777e+01 3.4225270e+01 3.2965308e+01 3.4591031e+01 3.4204203e+01 3.4678123e+01 3.5728720e+01 3.0830047e+01 3.1550681e+01 3.3304790e+01 3.2676753e+01 3.2742330e+01 3.1684556e+01 3.2830915e+01 3.2956614e+01 2.7365639e+01 3.3207307e+01 3.3420925e+01 3.4357941e+01 2.8280126e+01 3.4523458e+01 3.2705274e+01 3.2455891e+01 3.1636060e+01 3.1594957e+01 3.1805202e+01 3.3886574e+01 3.3438829e+01 3.3330030e+01 3.4168514e+01 3.0637353e+01 4.2149167e+01 3.6340559e+01 2.9315308e+01 3.5778314e+01 3.7693050e+01 3.2598714e+01 3.2990836e+01 3.4967659e+01 3.9748920e+01 3.6745043e+01 2.7117550e+01 3.6014760e+01 2.9367558e+01 3.3845350e+01 3.5477339e+01 3.1513372e+01 3.2517953e+01 2.4755097e+01 3.0229897e+01 3.4799343e+01 3.3371710e+01 2.9600910e+01 3.3275088e+01 3.3567110e+01 3.4527016e+01 3.4942320e+01 3.2359383e+01 3.2607100e+01 3.1467914e+01 2.9032039e+01 3.3122878e+01 2.8496709e+01 2.9908448e+01 2.9962886e+01 3.0345299e+01 3.1737613e+01 2.8551485e+01 3.2610551e+01 3.3082660e+01 3.3719298e+01 3.6434018e+01 3.6589278e+01 3.3889586e+01 3.8036774e+01 3.1483497e+01 3.4196794e+01 3.5154035e+01 3.5488608e+01 3.6143183e+01 3.3473491e+01 3.4686446e+01 2.8687495e+01 3.5725742e+01 3.0188298e+01 3.3084534e+01 3.3538519e+01 3.6226849e+01 2.9052099e+01 3.6032733e+01 3.0811503e+01 3.2616190e+01 3.3888566e+01 3.3074570e+01 2.9683515e+01 3.0600771e+01 3.4345247e+01 3.6983843e+01 3.3692824e+01 3.3762461e+01 3.4024582e+01 3.3698854e+01 3.1238613e+01 3.4978833e+01 3.4991078e+01 3.4577741e+01 3.3749227e+01 3.4982272e+01 3.0487868e+01 3.2317632e+01 3.1125588e+01 3.4413791e+01 3.1881871e+01 3.1373821e+01 3.0416864e+01 3.2066187e+01 3.1128313e+01 3.0240249e+01 3.0125198e+01 3.1343454e+01 3.5479092e+01 3.4450767e+01 3.2953507e+01 3.4456795e+01 3.0136375e+01 3.3462150e+01 2.9894274e+01 3.1367432e+01 3.2839320e+01 3.1440398e+01 2.9400374e+01 3.1106338e+01 3.1242624e+01 3.5537892e+01 3.3056459e+01 2.8610281e+01 3.4296217e+01 3.5819772e+01 3.2503922e+01 3.0963029e+01 3.4762112e+01 3.4796284e+01 2.9645345e+01 3.4468088e+01 2.6975590e+01 3.3738555e+01 2.8825009e+01 3.2663999e+01 3.2547878e+01 3.2308091e+01 3.2489966e+01 3.0868597e+01 3.2974220e+01 3.0866111e+01 3.8197342e+01 3.0609568e+01 3.5478978e+01 2.9249184e+01 3.6185622e+01 3.1948258e+01 3.2649719e+01 3.3305650e+01 3.4643955e+01 3.6566241e+01 3.4968484e+01 3.2632218e+01 3.6741383e+01 3.5700008e+01 3.1962468e+01 3.1410623e+01 3.0412061e+01 3.3749077e+01 3.5649661e+01 3.7649263e+01 3.2832574e+01 3.1783914e+01 2.8264292e+01
|
venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-correlation-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-correlation-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
9.2507465e-01 9.6528566e-01 8.7255441e-01 1.1287379e+00 8.7318727e-01 1.0767102e+00 9.1419676e-01 1.1503304e+00 9.8074509e-01 1.0135025e+00 1.0495025e+00 9.4794536e-01 9.6829273e-01 1.1345767e+00 1.1048008e+00 9.2407796e-01 1.0228634e+00 9.3853195e-01 9.9377619e-01 1.0407662e+00 9.5048989e-01 9.0465688e-01 9.8056930e-01 8.9777156e-01 9.6357127e-01 9.3864452e-01 9.9754613e-01 9.7271356e-01 8.4383151e-01 9.6981983e-01 9.7510267e-01 1.0112663e+00 7.8730400e-01 1.0299498e+00 9.9307979e-01 9.0239520e-01 8.5428231e-01 8.8972742e-01 8.5933162e-01 9.6625934e-01 9.4175449e-01 9.9120729e-01 1.0503963e+00 8.8223053e-01 1.3261434e+00 1.1063209e+00 8.4058398e-01 1.0844267e+00 1.1153093e+00 1.0092643e+00 8.9585237e-01 1.0599818e+00 1.2321707e+00 1.1359624e+00 8.3503556e-01 1.1792243e+00 7.9159781e-01 1.0830419e+00 1.2181870e+00 9.9888500e-01 1.0227144e+00 6.8557277e-01 9.6836193e-01 1.1061227e+00 1.0883453e+00 9.5681974e-01 9.9436299e-01 1.0304323e+00 1.1273949e+00 1.0735563e+00 1.0582583e+00 9.6040272e-01 1.0032137e+00 8.4900547e-01 1.1035351e+00 8.7867480e-01 9.6433176e-01 9.1850122e-01 8.9337435e-01 1.0449390e+00 8.9639384e-01 9.6704971e-01 1.0084258e+00 1.0528587e+00 1.1764481e+00 1.0913280e+00 1.0136672e+00 1.2737156e+00 9.5130359e-01 1.0367909e+00 1.1983402e+00 1.1319901e+00 1.1117462e+00 1.0343695e+00 1.0838628e+00 7.5266057e-01 1.0763316e+00 8.8067924e-01 9.6734383e-01 9.8800551e-01 1.2265742e+00 7.8833055e-01 1.0338670e+00 8.6666625e-01 9.9039950e-01 9.7142684e-01 9.3138616e-01 8.5849977e-01 8.5486301e-01 1.0516028e+00 1.1105313e+00 9.5943505e-01 9.8845171e-01 1.0566288e+00 9.9712198e-01 9.5545756e-01 1.1817974e+00 9.9128482e-01 1.0117892e+00 1.0979115e+00 1.0493943e+00 9.1318848e-01 9.3157311e-01 8.7073304e-01 1.2459441e+00 9.3412689e-01 1.0482297e+00 9.4224032e-01 9.5134153e-01 9.0857493e-01 9.7264161e-01 8.2900820e-01 9.3140549e-01 1.1330242e+00 1.0333002e+00 1.0117861e+00 1.2053255e+00 8.5291396e-01 1.0148928e+00 8.6641379e-01 9.7080819e-01 9.5457159e-01 9.5207457e-01 9.3539674e-01 9.0769069e-01 9.5322590e-01 1.1181803e+00 9.9765614e-01 7.5370610e-01 1.0807114e+00 1.0804601e+00 9.0214124e-01 8.7101998e-01 1.0167435e+00 1.2045936e+00 8.7300539e-01 1.1054300e+00 7.9145574e-01 1.0279340e+00 8.7623462e-01 1.0034756e+00 1.0386933e+00 9.3910970e-01 1.0028455e+00 9.9868824e-01 9.8752945e-01 9.8319327e-01 1.3110209e+00 8.6180633e-01 1.0993856e+00 8.5912563e-01 1.1303979e+00 9.8690459e-01 9.6910090e-01 9.1456819e-01 1.1525339e+00 1.1064552e+00 1.1062255e+00 9.7226683e-01 1.1091447e+00 1.1072238e+00 9.6544444e-01 9.6681036e-01 9.3247685e-01 9.6854634e-01 1.1035119e+00 1.1317148e+00 9.5557793e-01 9.8908485e-01 7.4873648e-01
|
venv/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cosine-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|