Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 94d35b5

Browse files
committed
Merge pull request #4372 from charris/fix-gh-2423
DOC: Fix documentation of normed keyword in histogram2d and histogramdd.
2 parents a4e7645 + 3392529 commit 94d35b5

File tree

2 files changed

+113
-109
lines changed

2 files changed

+113
-109
lines changed

numpy/lib/function_base.py

Lines changed: 95 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -256,22 +256,22 @@ def histogramdd(sample, bins=10, range=None, normed=False, weights=None):
256256
257257
range : sequence, optional
258258
A sequence of lower and upper bin edges to be used if the edges are
259-
not given explicitely in `bins`. Defaults to the minimum and maximum
259+
not given explicitly in `bins`. Defaults to the minimum and maximum
260260
values along each dimension.
261261
normed : bool, optional
262-
If False, returns the number of samples in each bin. If True, returns
263-
the bin density, ie, the bin count divided by the bin hypervolume.
262+
If False, returns the number of samples in each bin. If True,
263+
returns the bin density ``bin_count / sample_count / bin_volume``.
264264
weights : array_like (N,), optional
265265
An array of values `w_i` weighing each sample `(x_i, y_i, z_i, ...)`.
266-
Weights are normalized to 1 if normed is True. If normed is False, the
267-
values of the returned histogram are equal to the sum of the weights
268-
belonging to the samples falling into each bin.
266+
Weights are normalized to 1 if normed is True. If normed is False,
267+
the values of the returned histogram are equal to the sum of the
268+
weights belonging to the samples falling into each bin.
269269
270270
Returns
271271
-------
272272
H : ndarray
273-
The multidimensional histogram of sample x. See normed and weights for
274-
the different possible semantics.
273+
The multidimensional histogram of sample x. See normed and weights
274+
for the different possible semantics.
275275
edges : list
276276
A list of D arrays describing the bin edges for each dimension.
277277
@@ -1101,7 +1101,7 @@ def interp(x, xp, fp, left=None, right=None):
11011101
-----
11021102
Does not check that the x-coordinate sequence `xp` is increasing.
11031103
If `xp` is not increasing, the results are nonsense.
1104-
A simple check for increasingness is::
1104+
A simple check for increasing is::
11051105
11061106
np.all(np.diff(xp) > 0)
11071107
@@ -1578,15 +1578,16 @@ class vectorize(object):
15781578
The `vectorize` function is provided primarily for convenience, not for
15791579
performance. The implementation is essentially a for loop.
15801580
1581-
If `otypes` is not specified, then a call to the function with the first
1582-
argument will be used to determine the number of outputs. The results of
1583-
this call will be cached if `cache` is `True` to prevent calling the
1584-
function twice. However, to implement the cache, the original function
1585-
must be wrapped which will slow down subsequent calls, so only do this if
1586-
your function is expensive.
1581+
If `otypes` is not specified, then a call to the function with the
1582+
first argument will be used to determine the number of outputs. The
1583+
results of this call will be cached if `cache` is `True` to prevent
1584+
calling the function twice. However, to implement the cache, the
1585+
original function must be wrapped which will slow down subsequent
1586+
calls, so only do this if your function is expensive.
1587+
1588+
The new keyword argument interface and `excluded` argument support
1589+
further degrades performance.
15871590
1588-
The new keyword argument interface and `excluded` argument support further
1589-
degrades performance.
15901591
"""
15911592
def __init__(self, pyfunc, otypes='', doc=None, excluded=None,
15921593
cache=False):
@@ -1911,7 +1912,7 @@ def blackman(M):
19111912
"""
19121913
Return the Blackman window.
19131914
1914-
The Blackman window is a taper formed by using the the first three
1915+
The Blackman window is a taper formed by using the first three
19151916
terms of a summation of cosines. It was designed to have close to the
19161917
minimal leakage possible. It is close to optimal, only slightly worse
19171918
than a Kaiser window.
@@ -2141,9 +2142,10 @@ def hanning(M):
21412142
.. math:: w(n) = 0.5 - 0.5cos\\left(\\frac{2\\pi{n}}{M-1}\\right)
21422143
\\qquad 0 \\leq n \\leq M-1
21432144
2144-
The Hanning was named for Julius van Hann, an Austrian meterologist. It is
2145-
also known as the Cosine Bell. Some authors prefer that it be called a
2146-
Hann window, to help avoid confusion with the very similar Hamming window.
2145+
The Hanning was named for Julius van Hann, an Austrian meteorologist.
2146+
It is also known as the Cosine Bell. Some authors prefer that it be
2147+
called a Hann window, to help avoid confusion with the very similar
2148+
Hamming window.
21472149
21482150
Most references to the Hanning window come from the signal processing
21492151
literature, where it is used as one of many windowing functions for
@@ -2240,9 +2242,9 @@ def hamming(M):
22402242
.. math:: w(n) = 0.54 - 0.46cos\\left(\\frac{2\\pi{n}}{M-1}\\right)
22412243
\\qquad 0 \\leq n \\leq M-1
22422244
2243-
The Hamming was named for R. W. Hamming, an associate of J. W. Tukey and
2244-
is described in Blackman and Tukey. It was recommended for smoothing the
2245-
truncated autocovariance function in the time domain.
2245+
The Hamming was named for R. W. Hamming, an associate of J. W. Tukey
2246+
and is described in Blackman and Tukey. It was recommended for
2247+
smoothing the truncated autocovariance function in the time domain.
22462248
Most references to the Hamming window come from the signal processing
22472249
literature, where it is used as one of many windowing functions for
22482250
smoothing values. It is also known as an apodization (which means
@@ -2422,11 +2424,11 @@ def i0(x):
24222424
Notes
24232425
-----
24242426
We use the algorithm published by Clenshaw [1]_ and referenced by
2425-
Abramowitz and Stegun [2]_, for which the function domain is partitioned
2426-
into the two intervals [0,8] and (8,inf), and Chebyshev polynomial
2427-
expansions are employed in each interval. Relative error on the domain
2428-
[0,30] using IEEE arithmetic is documented [3]_ as having a peak of 5.8e-16
2429-
with an rms of 1.4e-16 (n = 30000).
2427+
Abramowitz and Stegun [2]_, for which the function domain is
2428+
partitioned into the two intervals [0,8] and (8,inf), and Chebyshev
2429+
polynomial expansions are employed in each interval. Relative error on
2430+
the domain [0,30] using IEEE arithmetic is documented [3]_ as having a
2431+
peak of 5.8e-16 with an rms of 1.4e-16 (n = 30000).
24302432
24312433
References
24322434
----------
@@ -2496,12 +2498,11 @@ def kaiser(M, beta):
24962498
24972499
where :math:`I_0` is the modified zeroth-order Bessel function.
24982500
2499-
The Kaiser was named for Jim Kaiser, who discovered a simple approximation
2500-
to the DPSS window based on Bessel functions.
2501-
The Kaiser window is a very good approximation to the Digital Prolate
2502-
Spheroidal Sequence, or Slepian window, which is the transform which
2503-
maximizes the energy in the main lobe of the window relative to total
2504-
energy.
2501+
The Kaiser was named for Jim Kaiser, who discovered a simple
2502+
approximation to the DPSS window based on Bessel functions. The Kaiser
2503+
window is a very good approximation to the Digital Prolate Spheroidal
2504+
Sequence, or Slepian window, which is the transform which maximizes the
2505+
energy in the main lobe of the window relative to total energy.
25052506
25062507
The Kaiser can approximate many other windows by varying the beta
25072508
parameter.
@@ -2611,8 +2612,8 @@ def sinc(x):
26112612
The name sinc is short for "sine cardinal" or "sinus cardinalis".
26122613
26132614
The sinc function is used in various signal processing applications,
2614-
including in anti-aliasing, in the construction of a
2615-
Lanczos resampling filter, and in interpolation.
2615+
including in anti-aliasing, in the construction of a Lanczos resampling
2616+
filter, and in interpolation.
26162617
26172618
For bandlimited interpolation of discrete-time signals, the ideal
26182619
interpolation kernel is proportional to the sinc function.
@@ -2708,23 +2709,23 @@ def median(a, axis=None, out=None, overwrite_input=False):
27082709
Axis along which the medians are computed. The default (axis=None)
27092710
is to compute the median along a flattened version of the array.
27102711
out : ndarray, optional
2711-
Alternative output array in which to place the result. It must
2712-
have the same shape and buffer length as the expected output,
2713-
but the type (of the output) will be cast if necessary.
2712+
Alternative output array in which to place the result. It must have
2713+
the same shape and buffer length as the expected output, but the
2714+
type (of the output) will be cast if necessary.
27142715
overwrite_input : bool, optional
27152716
If True, then allow use of memory of input array (a) for
27162717
calculations. The input array will be modified by the call to
2717-
median. This will save memory when you do not need to preserve
2718-
the contents of the input array. Treat the input as undefined,
2719-
but it will probably be fully or partially sorted. Default is
2720-
False. Note that, if `overwrite_input` is True and the input
2721-
is not already an ndarray, an error will be raised.
2718+
median. This will save memory when you do not need to preserve the
2719+
contents of the input array. Treat the input as undefined, but it
2720+
will probably be fully or partially sorted. Default is False. Note
2721+
that, if `overwrite_input` is True and the input is not already an
2722+
ndarray, an error will be raised.
27222723
27232724
Returns
27242725
-------
27252726
median : ndarray
2726-
A new array holding the result (unless `out` is specified, in
2727-
which case that array is returned instead). If the input contains
2727+
A new array holding the result (unless `out` is specified, in which
2728+
case that array is returned instead). If the input contains
27282729
integers, or floats of smaller precision than 64, then the output
27292730
data-type is float64. Otherwise, the output data-type is the same
27302731
as that of the input.
@@ -2861,26 +2862,26 @@ def percentile(a, q, axis=None, out=None,
28612862
Returns
28622863
-------
28632864
percentile : scalar or ndarray
2864-
If a single percentile `q` is given and axis=None a scalar is returned.
2865-
If multiple percentiles `q` are given an array holding the result is
2866-
returned. The results are listed in the first axis.
2867-
(If `out` is specified, in which case that array is returned instead).
2868-
If the input contains integers, or floats of smaller precision than 64,
2869-
then the output data-type is float64. Otherwise, the output data-type
2870-
is the same as that of the input.
2865+
If a single percentile `q` is given and axis=None a scalar is
2866+
returned. If multiple percentiles `q` are given an array holding
2867+
the result is returned. The results are listed in the first axis.
2868+
(If `out` is specified, in which case that array is returned
2869+
instead). If the input contains integers, or floats of smaller
2870+
precision than 64, then the output data-type is float64. Otherwise,
2871+
the output data-type is the same as that of the input.
28712872
28722873
See Also
28732874
--------
28742875
mean, median
28752876
28762877
Notes
28772878
-----
2878-
Given a vector V of length N, the qth percentile of V is the qth ranked
2879-
value in a sorted copy of V. The values and distances of the two nearest
2880-
neighbors as well as the `interpolation` parameter will determine the
2881-
percentile if the normalized ranking does not match q exactly. This
2882-
function is the same as the median if ``q=50``, the same as the minimum
2883-
if ``q=0``and the same as the maximum if ``q=100``.
2879+
Given a vector V of length N, the q-th percentile of V is the q-th ranked
2880+
value in a sorted copy of V. The values and distances of the two
2881+
nearest neighbors as well as the `interpolation` parameter will
2882+
determine the percentile if the normalized ranking does not match q
2883+
exactly. This function is the same as the median if ``q=50``, the same
2884+
as the minimum if ``q=0``and the same as the maximum if ``q=100``.
28842885
28852886
Examples
28862887
--------
@@ -3031,10 +3032,11 @@ def trapz(y, x=None, dx=1.0, axis=-1):
30313032
30323033
Notes
30333034
-----
3034-
Image [2]_ illustrates trapezoidal rule -- y-axis locations of points will
3035-
be taken from `y` array, by default x-axis distances between points will be
3036-
1.0, alternatively they can be provided with `x` array or with `dx` scalar.
3037-
Return value will be equal to combined area under the red lines.
3035+
Image [2]_ illustrates trapezoidal rule -- y-axis locations of points
3036+
will be taken from `y` array, by default x-axis distances between
3037+
points will be 1.0, alternatively they can be provided with `x` array
3038+
or with `dx` scalar. Return value will be equal to combined area under
3039+
the red lines.
30383040
30393041
30403042
References
@@ -3147,12 +3149,12 @@ def meshgrid(*xi, **kwargs):
31473149
If True a sparse grid is returned in order to conserve memory.
31483150
Default is False.
31493151
copy : bool, optional
3150-
If False, a view into the original arrays are returned in
3151-
order to conserve memory. Default is True. Please note that
3152-
``sparse=False, copy=False`` will likely return non-contiguous arrays.
3153-
Furthermore, more than one element of a broadcast array may refer to
3154-
a single memory location. If you need to write to the arrays, make
3155-
copies first.
3152+
If False, a view into the original arrays are returned in order to
3153+
conserve memory. Default is True. Please note that
3154+
``sparse=False, copy=False`` will likely return non-contiguous
3155+
arrays. Furthermore, more than one element of a broadcast array
3156+
may refer to a single memory location. If you need to write to the
3157+
arrays, make copies first.
31563158
31573159
Returns
31583160
-------
@@ -3166,13 +3168,13 @@ def meshgrid(*xi, **kwargs):
31663168
Notes
31673169
-----
31683170
This function supports both indexing conventions through the indexing
3169-
keyword argument. Giving the string 'ij' returns a meshgrid with matrix
3170-
indexing, while 'xy' returns a meshgrid with Cartesian indexing. In the
3171-
2-D case with inputs of length M and N, the outputs are of shape (N, M) for
3172-
'xy' indexing and (M, N) for 'ij' indexing. In the 3-D case with inputs of
3173-
length M, N and P, outputs are of shape (N, M, P) for 'xy' indexing and
3174-
(M, N, P) for 'ij' indexing. The difference is illustrated by the
3175-
following code snippet::
3171+
keyword argument. Giving the string 'ij' returns a meshgrid with
3172+
matrix indexing, while 'xy' returns a meshgrid with Cartesian indexing.
3173+
In the 2-D case with inputs of length M and N, the outputs are of shape
3174+
(N, M) for 'xy' indexing and (M, N) for 'ij' indexing. In the 3-D case
3175+
with inputs of length M, N and P, outputs are of shape (N, M, P) for
3176+
'xy' indexing and (M, N, P) for 'ij' indexing. The difference is
3177+
illustrated by the following code snippet::
31763178
31773179
xv, yv = meshgrid(x, y, sparse=False, indexing='ij')
31783180
for i in range(nx):
@@ -3184,7 +3186,8 @@ def meshgrid(*xi, **kwargs):
31843186
for j in range(ny):
31853187
# treat xv[j,i], yv[j,i]
31863188
3187-
In the 1-D and 0-D case, the indexing and sparse keywords have no effect.
3189+
In the 1-D and 0-D case, the indexing and sparse keywords have no
3190+
effect.
31883191
31893192
See Also
31903193
--------
@@ -3260,7 +3263,8 @@ def meshgrid(*xi, **kwargs):
32603263
def delete(arr, obj, axis=None):
32613264
"""
32623265
Return a new array with sub-arrays along an axis deleted. For a one
3263-
dimensional array, this returns those entries not returned by `arr[obj]`.
3266+
dimensional array, this returns those entries not returned by
3267+
`arr[obj]`.
32643268
32653269
Parameters
32663270
----------
@@ -3287,9 +3291,11 @@ def delete(arr, obj, axis=None):
32873291
Notes
32883292
-----
32893293
Often it is preferable to use a boolean mask. For example:
3294+
32903295
>>> mask = np.ones(len(arr), dtype=bool)
32913296
>>> mask[[0,2,4]] = False
32923297
>>> result = arr[mask,...]
3298+
32933299
Is equivalent to `np.delete(arr, [0,2,4], axis=0)`, but allows further
32943300
use of `mask`.
32953301
@@ -3467,7 +3473,8 @@ def insert(arr, obj, values, axis=None):
34673473
.. versionadded:: 1.8.0
34683474
34693475
Support for multiple insertions when `obj` is a single scalar or a
3470-
sequence with one element (similar to calling insert multiple times).
3476+
sequence with one element (similar to calling insert multiple
3477+
times).
34713478
values : array_like
34723479
Values to insert into `arr`. If the type of `values` is different
34733480
from that of `arr`, `values` is converted to the type of `arr`.
@@ -3666,19 +3673,19 @@ def append(arr, values, axis=None):
36663673
Values are appended to a copy of this array.
36673674
values : array_like
36683675
These values are appended to a copy of `arr`. It must be of the
3669-
correct shape (the same shape as `arr`, excluding `axis`). If `axis`
3670-
is not specified, `values` can be any shape and will be flattened
3671-
before use.
3676+
correct shape (the same shape as `arr`, excluding `axis`). If
3677+
`axis` is not specified, `values` can be any shape and will be
3678+
flattened before use.
36723679
axis : int, optional
3673-
The axis along which `values` are appended. If `axis` is not given,
3674-
both `arr` and `values` are flattened before use.
3680+
The axis along which `values` are appended. If `axis` is not
3681+
given, both `arr` and `values` are flattened before use.
36753682
36763683
Returns
36773684
-------
36783685
append : ndarray
3679-
A copy of `arr` with `values` appended to `axis`. Note that `append`
3680-
does not occur in-place: a new array is allocated and filled. If
3681-
`axis` is None, `out` is a flattened array.
3686+
A copy of `arr` with `values` appended to `axis`. Note that
3687+
`append` does not occur in-place: a new array is allocated and
3688+
filled. If `axis` is None, `out` is a flattened array.
36823689
36833690
See Also
36843691
--------

0 commit comments

Comments
 (0)