summaryrefslogtreecommitdiff
path: root/numpy/fft/helper.py
diff options
context:
space:
mode:
authorendolith <endolith@gmail.com>2012-10-13 17:36:31 -0400
committerendolith <endolith@gmail.com>2012-10-13 17:36:31 -0400
commit2e2f4522275af6e256c243e2b43bf5fc1d37b07c (patch)
treec552eef5c9339a558b992617b4338a0d6b80bcf8 /numpy/fft/helper.py
parent4ddb4df47c156bee8271ca4ac444a6760d321e32 (diff)
downloadnumpy-2e2f4522275af6e256c243e2b43bf5fc1d37b07c.tar.gz
DOC: Clarify size of odd-length FFTs, default `d` for fftfreq, and some PEP8 style fixes
Diffstat (limited to 'numpy/fft/helper.py')
-rw-r--r--numpy/fft/helper.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/numpy/fft/helper.py b/numpy/fft/helper.py
index 903ea257e..6a89b0c93 100644
--- a/numpy/fft/helper.py
+++ b/numpy/fft/helper.py
@@ -10,7 +10,7 @@ from numpy.core import asarray, concatenate, arange, take, \
import numpy.core.numerictypes as nt
import types
-def fftshift(x,axes=None):
+def fftshift(x, axes=None):
"""
Shift the zero-frequency component to the center of the spectrum.
@@ -69,7 +69,7 @@ def fftshift(x,axes=None):
return y
-def ifftshift(x,axes=None):
+def ifftshift(x, axes=None):
"""
The inverse of fftshift.
@@ -116,7 +116,8 @@ def ifftshift(x,axes=None):
y = take(y,mylist,k)
return y
-def fftfreq(n,d=1.0):
+
+def fftfreq(n, d=1.0):
"""
Return the Discrete Fourier Transform sample frequencies.
@@ -124,15 +125,15 @@ def fftfreq(n,d=1.0):
cycles/unit (with zero at the start) given a window length `n` and a
sample spacing `d`::
- f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (d*n) if n is even
+ f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (d*n) if n is even
f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n) if n is odd
Parameters
----------
n : int
Window length.
- d : scalar
- Sample spacing.
+ d : scalar, optional
+ Sample spacing. Default is 1.
Returns
-------
@@ -151,12 +152,12 @@ def fftfreq(n,d=1.0):
"""
assert isinstance(n,types.IntType) or isinstance(n, integer)
- val = 1.0/(n*d)
+ val = 1.0 / (n * d)
results = empty(n, int)
N = (n-1)//2 + 1
- p1 = arange(0,N,dtype=int)
+ p1 = arange(0, N, dtype=int)
results[:N] = p1
- p2 = arange(-(n//2),0,dtype=int)
+ p2 = arange(-(n//2), 0, dtype=int)
results[N:] = p2
return results * val
#return hstack((arange(0,(n-1)/2 + 1), arange(-(n/2),0))) / (n*d)