Permalink
Browse files

DOC: fix more Sphinx issues. Also complete fftpack.tilbert docstring.

  • Loading branch information...
1 parent 87c9baa commit 5c4c8ea8fc0ad657c6c4e67a86e677586c182ef6 @rgommers rgommers committed Apr 22, 2012
@@ -1945,9 +1945,8 @@ def dendrogram(Z, p=30, truncate_mode=None, color_threshold=None,
get_leaves : bool, optional
Includes a list ``R['leaves']=H`` in the result
dictionary. For each :math:`i`, ``H[i] == j``, cluster node
- :math:`j` appears in the :math:`i` th position in the
- left-to-right traversal of the leaves, where :math:`j < 2n-1`
- and :math:`i < n`.
+ ``j`` appears in position ``i`` in the left-to-right traversal
+ of the leaves, where :math:`j < 2n-1` and :math:`i < n`.
orientation : str, optional
The direction to plot the dendrogram, which can be any
of the following strings:
@@ -2050,9 +2049,7 @@ def llf(id):
link_color_function is called with each non-singleton id
corresponding to each U-shaped link it will paint. The
function is expected to return the color to paint the link,
- encoded as a matplotlib color string code.
-
- For example:
+ encoded as a matplotlib color string code. For example:
>>> dendrogram(Z, link_color_func=lambda k: colors[k])
@@ -2065,25 +2062,21 @@ def llf(id):
A dictionary of data structures computed to render the
dendrogram. Its has the following keys:
- - 'icoords': a list of lists ``[I1, I2, ..., Ip]`` where
- ``Ik`` is a list of 4 independent variable coordinates
- corresponding to the line that represents the k'th link
- painted.
-
- - 'dcoords': a list of lists ``[I2, I2, ..., Ip]`` where
- ``Ik`` is a list of 4 independent variable coordinates
- corresponding to the line that represents the k'th link
- painted.
-
- - 'ivl': a list of labels corresponding to the leaf nodes.
-
- - 'leaves': for each i, ``H[i] == j``, cluster node
- :math:`j` appears in the :math:`i` th position in the
- left-to-right traversal of the leaves, where :math:`j < 2n-1`
- and :math:`i < n`. If :math:`j` is less than :math:`n`, the
- :math:`i` th leaf node corresponds to an original
- observation. Otherwise, it corresponds to a non-singleton
- cluster.
+ * 'icoords': a list of lists ``[I1, I2, ..., Ip]`` where
+ ``Ik`` is a list of 4 independent variable coordinates
+ corresponding to the line that represents the k'th link
+ painted.
+ * 'dcoords': a list of lists ``[I2, I2, ..., Ip]`` where
+ ``Ik`` is a list of 4 independent variable coordinates
+ corresponding to the line that represents the k'th link
+ painted.
+ * 'ivl': a list of labels corresponding to the leaf nodes.
+ * 'leaves': for each i, ``H[i] == j``, cluster node
+ ``j`` appears in position ``i`` in the left-to-right
+ traversal of the leaves, where :math:`j < 2n-1`
+ and :math:`i < n`. If ``j`` is less than ``n``, the
+ ``i`` th leaf node corresponds to an original observation.
+ Otherwise, it corresponds to a non-singleton cluster.
"""
@@ -176,12 +176,16 @@ def fft(x, n=None, axis=-1, overwrite_x=0):
Returns
-------
z : complex ndarray
- with the elements:
+ with the elements::
+
[y(0),y(1),..,y(n/2),y(1-n/2),...,y(-1)] if n is even
[y(0),y(1),..,y((n-1)/2),y(-(n-1)/2),...,y(-1)] if n is odd
- where
+
+ where::
+
y(j) = sum[k=0..n-1] x[k] * exp(-sqrt(-1)*j*k* 2*pi/n), j = 0..n-1
- Note that y(-j) = y(n-j).conjugate().
+
+ Note that ``y(-j) = y(n-j).conjugate()``.
See Also
--------
@@ -205,7 +209,7 @@ def fft(x, n=None, axis=-1, overwrite_x=0):
--------
>>> from scipy.fftpack import fft, ifft
>>> x = np.arange(5)
- >>> np.allclose(fft(ifft(x)), x, atol=1e-15) #within numerical accuracy.
+ >>> np.allclose(fft(ifft(x)), x, atol=1e-15) #within numerical accuracy.
True
"""
@@ -343,22 +347,33 @@ def irfft(x, n=None, axis=-1, overwrite_x=0):
""" irfft(x, n=None, axis=-1, overwrite_x=0) -> y
Return inverse discrete Fourier transform of real sequence x.
- The contents of x is interpreted as the output of rfft(..)
+ The contents of x is interpreted as the output of the ``rfft(..)``
function.
- The returned real array contains
- [y(0),y(1),...,y(n-1)]
- where for n is even
- y(j) = 1/n (sum[k=1..n/2-1] (x[2*k-1]+sqrt(-1)*x[2*k])
- * exp(sqrt(-1)*j*k* 2*pi/n)
- + c.c. + x[0] + (-1)**(j) x[n-1])
- and for n is odd
- y(j) = 1/n (sum[k=1..(n-1)/2] (x[2*k-1]+sqrt(-1)*x[2*k])
- * exp(sqrt(-1)*j*k* 2*pi/n)
- + c.c. + x[0])
+ The returned real array contains::
+
+ [y(0),y(1),...,y(n-1)]
+
+ where for n is even::
+
+ y(j) = 1/n (sum[k=1..n/2-1] (x[2*k-1]+sqrt(-1)*x[2*k])
+ * exp(sqrt(-1)*j*k* 2*pi/n)
+ + c.c. + x[0] + (-1)**(j) x[n-1])
+
+ and for n is odd::
+
+ y(j) = 1/n (sum[k=1..(n-1)/2] (x[2*k-1]+sqrt(-1)*x[2*k])
+ * exp(sqrt(-1)*j*k* 2*pi/n)
+ + c.c. + x[0])
+
c.c. denotes complex conjugate of preceeding expression.
- Optional input: see rfft.__doc__
+ For details on input parameters, see `rfft`.
+
+ See Also
+ --------
+ rfft, ifft
+
"""
tmp = _asfarray(x)
if not numpy.isrealobj(tmp):
@@ -72,48 +72,67 @@ def kernel(k,order=order,c=c):
_cache = {}
-def tilbert(x,h,period=None,
- _cache = _cache):
+def tilbert(x, h, period=None, _cache=_cache):
""" tilbert(x, h, period=2*pi) -> y
Return h-Tilbert transform of a periodic sequence x.
If x_j and y_j are Fourier coefficients of periodic functions x
- and y, respectively, then
+ and y, respectively, then::
- y_j = sqrt(-1)*coth(j*h*2*pi/period) * x_j
- y_0 = 0
+ y_j = sqrt(-1)*coth(j*h*2*pi/period) * x_j
+ y_0 = 0
- Input:
- h
+ Parameters
+ ----------
+ x : array_like
+ The input array to transform.
+ h : float
Defines the parameter of the Tilbert transform.
- period
- The assumed period of the sequence. Default period is 2*pi.
+ period : float, optional
+ The assumed period of the sequence. Default period is ``2*pi``.
+
+ Returns
+ -------
+ tilbert : ndarray
+ The result of the transform.
+
+ Notes
+ -----
+ If ``sum(x, axis=0) == 0`` and ``n = len(x)`` is odd then
+ ``tilbert(itilbert(x)) == x``.
+
+ If ``2 * pi * h / period`` is approximately 10 or larger, then
+ numerically ``tilbert == hilbert``
+ (theoretically oo-Tilbert == Hilbert).
+
+ For even ``len(x)``, the Nyquist mode of ``x`` is taken zero.
- Notes:
- If sum(x,axis=0)==0 and n=len(x) is odd then
- tilbert(itilbert(x)) == x
- If 2*pi*h/period is approximately 10 or larger then numerically
- tilbert == hilbert
- (theoretically oo-Tilbert == Hilbert).
- For even len(x), the Nyquist mode of x is taken zero.
"""
tmp = asarray(x)
if iscomplexobj(tmp):
- return tilbert(tmp.real,h,period)+\
- 1j*tilbert(tmp.imag,h,period)
+ return tilbert(tmp.real, h, period) + \
+ 1j * tilbert(tmp.imag, h, period)
+
if period is not None:
- h = h*2*pi/period
+ h = h * 2 * pi / period
+
n = len(x)
- omega = _cache.get((n,h))
+ omega = _cache.get((n, h))
if omega is None:
- if len(_cache)>20:
- while _cache: _cache.popitem()
- def kernel(k,h=h):
- if k: return 1.0/tanh(h*k)
+ if len(_cache) > 20:
+ while _cache:
+ _cache.popitem()
+
+ def kernel(k, h=h):
+ if k:
+ return 1.0/tanh(h*k)
+
return 0
- omega = convolve.init_convolution_kernel(n,kernel,d=1)
+
+ omega = convolve.init_convolution_kernel(n, kernel, d=1)
_cache[(n,h)] = omega
+
overwrite_x = _datacopied(tmp, x)
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)
del _cache
@@ -56,8 +56,8 @@ def dct(x, type=2, n=None, axis=-1, norm=None, overwrite_x=0):
implemented in scipy. 'The' DCT generally refers to DCT type 2, and 'the'
Inverse DCT generally refers to DCT type 3.
- type I
- ~~~~~~
+ **type I**
+
There are several definitions of the DCT-I; we use the following
(for ``norm=None``)::
@@ -68,8 +68,8 @@ def dct(x, type=2, n=None, axis=-1, norm=None, overwrite_x=0):
Only None is supported as normalization mode for DCT-I. Note also that the
DCT-I is only supported for input size > 1
- type II
- ~~~~~~~
+ **type II**
+
There are several definitions of the DCT-II; we use the following
(for ``norm=None``)::
@@ -86,8 +86,7 @@ def dct(x, type=2, n=None, axis=-1, norm=None, overwrite_x=0):
Which makes the corresponding matrix of coefficients orthonormal
(``OO' = Id``).
- type III
- ~~~~~~~~
+ **type III**
There are several definitions, we use the following
(for ``norm=None``)::
@@ -108,7 +107,6 @@ def dct(x, type=2, n=None, axis=-1, norm=None, overwrite_x=0):
References
----------
-
http://en.wikipedia.org/wiki/Discrete_cosine_transform
'A Fast Cosine Transform in One and Two Dimensions', by J. Makhoul, `IEEE
@@ -279,8 +277,8 @@ def dst(x, type=2, n=None, axis=-1, norm=None, overwrite_x=0):
even/odd boundary conditions and boundary off sets [WPS]_, only the first
3 types are implemented in scipy.
- type I
- ~~~~~~
+ **type I**
+
There are several definitions of the DST-I; we use the following
for ``norm=None``. DST-I assumes the input is odd around n=-1 and n=N.
@@ -292,8 +290,8 @@ def dst(x, type=2, n=None, axis=-1, norm=None, overwrite_x=0):
DCT-I is only supported for input size > 1
The (unnormalized) DCT-I is its own inverse, up to a factor `2(N+1)`.
- type II
- ~~~~~~~
+ **type II**
+
There are several definitions of the DST-I; we use the following
for ``norm=None``. DST-I assumes the input is odd around n=-1 and n=N.
@@ -306,8 +304,7 @@ def dst(x, type=2, n=None, axis=-1, norm=None, overwrite_x=0):
f = sqrt(1/(4*N)) if k == 0
f = sqrt(1/(2*N)) otherwise.
- type III
- ~~~~~~~~
+ **type III**
There are several definitions of the DST-III, we use the following
(for ``norm=None``). DST-III assumes the input is odd around n=-1
@@ -323,8 +320,8 @@ def dst(x, type=2, n=None, axis=-1, norm=None, overwrite_x=0):
References
----------
-
http://en.wikipedia.org/wiki/Discrete_sine_transform
+
"""
if type == 1 and norm is not None:
raise NotImplementedError(
@@ -146,8 +146,8 @@ def minimize(fun, x0, args=(), method='BFGS', jac=None, hess=None,
This section describes the available solvers that can be selected by the
'method' parameter. The default method is *BFGS*.
- Unconstrained minimization
- ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ **Unconstrained minimization**
+
Method *Nelder-Mead* uses the Simplex algorithm [1]_, [2]_. This
algorithm has been successful in many applications but other algorithms
using the first and/or second derivatives information might be preferred
@@ -178,8 +178,8 @@ def minimize(fun, x0, args=(), method='BFGS', jac=None, hess=None,
metaheuristic algorithm for global optimization. It uses no derivative
information from the function being optimized.
- Constrained minimization
- ~~~~~~~~~~~~~~~~~~~~~~~~
+ **Constrained minimization**
+
Method *L-BFGS-B* uses the L-BFGS-B algorithm [6]_, [7]_ for bound
constrained minimization.
Oops, something went wrong.

0 comments on commit 5c4c8ea

Please sign in to comment.