8000 ENH: add `norm=forward,backward` to numpy.fft functions by cval26 · Pull Request #16476 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: add norm=forward,backward to numpy.fft functions #16476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
undo unnecessary docstrings changes made in my previous commits
  • Loading branch information
cvav-git committed Jun 2, 2020
commit da249dbb4f93d06556fc742306ac028fbd3c6662
8 changes: 4 additions & 4 deletions numpy/fft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
The inverse DFT is defined as

.. math::
a_m = \\frac{1}{n}\\sum_{k=0}^{n-1}A_k\\exp\\left\\{2\\pi i{mk\\over n}
\\right\\}\\qquad m = 0,\\ldots,n-1.
a_m = \\frac{1}{n}\\sum_{k=0}^{n-1}A_k\\exp\\left\\{2\\pi i{mk\\over n}\\right\\}
\\qquad m = 0,\\ldots,n-1.

It differs from the forward transform by the sign of the exponential
argument and the default normalization by :math:`1/n`.
Expand Down Expand Up @@ -167,8 +167,8 @@

.. math::
A_{kl} = \\sum_{m=0}^{M-1} \\sum_{n=0}^{N-1}
a_{mn}\\exp\\left\\{-2\\pi i \\left({mk\\over M}+{nl\\over N}\\right)
\\right\\}\\qquad k = 0, \\ldots, M-1;\\quad l = 0, \\ldots, N-1,
a_{mn}\\exp\\left\\{-2\\pi i \\left({mk\\over M}+{nl\\over N}\\right)\\right\\}
\\qquad k = 0, \\ldots, M-1;\\quad l = 0, \\ldots, N-1,

which extends in the obvious way to higher dimensions, and the inverses
in higher dimensions also extend in the same way.
Expand Down
14 changes: 5 additions & 9 deletions numpy/fft/_pocketfft.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Discrete Fourier Transforms
Discrete Fourier Transforms.

Routines in this module:

Expand Down Expand Up @@ -171,8 +171,7 @@ def fft(a, n=None, axis=-1, norm=None):
>>> sp = np.fft.fft(np.sin(t))
>>> freq = np.fft.fftfreq(t.shape[-1])
>>> plt.plot(freq, sp.real, freq, sp.imag)
[<matplotlib.lines.Line2D object at 0x...>, <matplotlib.lines.Line2D object
at 0x...>]
[<matplotlib.lines.Line2D object at 0x...>, <matplotlib.lines.Line2D object at 0x...>]
>>> plt.show()

"""
Expand Down Expand Up @@ -268,8 +267,7 @@ def ifft(a, n=None, axis=-1, norm=None):
>>> n[40:60] = np.exp(1j*np.random.uniform(0, 2*np.pi, (20,)))
>>> s = np.fft.ifft(n)
>>> plt.plot(t, s.real, 'b-', t, s.imag, 'r--')
[<matplotlib.lines.Line2D object at ...>, <matplotlib.lines.Line2D object
at ...>]
[<matplotlib.lines.Line2D object at ...>, <matplotlib.lines.Line2D object at ...>]
>>> plt.legend(('real', 'imaginary'))
<matplotlib.legend.Legend object at ...>
>>> plt.show()
Expand Down Expand Up @@ -547,8 +545,7 @@ def hfft(a, n=None, axis=-1, norm=None):
--------
>>> signal = np.array([1, 2, 3, 4, 3, 2])
>>> np.fft.fft(signal)
array([15.+0.j, -4.+0.j, 0.+0.j, -1.-0.j, 0.+0.j, -4.+0.j]) # may
vary
array([15.+0.j, -4.+0.j, 0.+0.j, -1.-0.j, 0.+0.j, -4.+0.j]) # may vary
>>> np.fft.hfft(signal[:4]) # Input first half of signal
array([15., -4., 0., -1., 0., -4.])
>>> np.fft.hfft(signal, 6) # Input entire signal and truncate
Expand Down Expand Up @@ -944,8 +941,7 @@ def fft2(a, s=None, axes=(-2, -1), norm=None):
--------
>>> a = np.mgrid[:5, :5][0]
>>> np.fft.fft2(a)
array([[ 50. +0.j , 0. +0.j , 0. +0.j , # may
vary
array([[ 50. +0.j , 0. +0.j , 0. +0.j , # may vary
0. +0.j , 0. +0.j ],
[-12.5+17.20477401j, 0. +0.j , 0. +0.j ,
0. +0.j , 0. +0.j ],
Expand Down
4 changes: 2 additions & 2 deletions numpy/fft/tests/test_pocketfft.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ def worker(args, q):
[x.join() for x in t]
# Make sure all threads returned the correct value
for i in range(self.threads):
assert_array_equal(q.get(timeout=5), expected, 'Function returned\
wrong value in multithreade context')
assert_array_equal(q.get(timeout=5), expected,
'Function returned wrong value in multithreade context')

def test_fft(self):
a = np.ones(self.input_shape) * 1+0j
Expand Down
0