From 418e3bf0789dcd7d064de55a266b186d4ab42774 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Sun, 14 Apr 2019 23:02:20 +0200 Subject: DOC: fix 4 remaining doc build warnings. 2 for polyfit rankwarning, 2 for divide by zero in log10. --- numpy/lib/function_base.py | 62 +++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index fb40ef927..dad2e3bcd 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -377,7 +377,7 @@ def average(a, axis=None, weights=None, returned=False): Traceback (most recent call last): ... TypeError: Axis must be specified when shapes of a and weights differ. - + >>> a = np.ones(5, dtype=np.float128) >>> w = np.ones(5, dtype=np.complex64) >>> avg = np.average(a, weights=w) @@ -1431,7 +1431,7 @@ def angle(z, deg=False): angle : ndarray or scalar The counterclockwise angle from the positive real axis on the complex plane, with dtype as numpy.float64. - + ..versionchanged:: 1.16.0 This function works on subclasses of ndarray like `ma.array`. @@ -1929,6 +1929,30 @@ class vectorize(object): vectorized : callable Vectorized function. + See Also + -------- + frompyfunc : Takes an arbitrary Python function and returns a ufunc + + Notes + ----- + The `vectorize` function is provided primarily for convenience, not for + performance. The implementation is essentially a for loop. + + If `otypes` is not specified, then a call to the function with the + first argument will be used to determine the number of outputs. The + results of this call will be cached if `cache` is `True` to prevent + calling the function twice. However, to implement the cache, the + original function must be wrapped which will slow down subsequent + calls, so only do this if your function is expensive. + + The new keyword argument interface and `excluded` argument support + further degrades performance. + + References + ---------- + .. [1] NumPy Reference, section `Generalized Universal Function API + `_. + Examples -------- >>> def myfunc(a, b): @@ -1988,8 +2012,8 @@ class vectorize(object): >>> import scipy.stats >>> pearsonr = np.vectorize(scipy.stats.pearsonr, - ... signature='(n),(n)->(),()') - >>> pearsonr([[0, 1, 2, 3]], [[1, 2, 3, 4], [4, 3, 2, 1]]) + ... signature='(n),(n)->(),()') + >>> pearsonr([[0, 1, 2, 3]], [[1, 2, 3, 4], [4, 3, 2, 1]]) (array([ 1., -1.]), array([ 0., 0.])) Or for a vectorized convolution: @@ -2001,31 +2025,7 @@ class vectorize(object): [0., 0., 1., 2., 1., 0.], [0., 0., 0., 1., 2., 1.]]) - See Also - -------- - frompyfunc : Takes an arbitrary Python function and returns a ufunc - - Notes - ----- - The `vectorize` function is provided primarily for convenience, not for - performance. The implementation is essentially a for loop. - - If `otypes` is not specified, then a call to the function with the - first argument will be used to determine the number of outputs. The - results of this call will be cached if `cache` is `True` to prevent - calling the function twice. However, to implement the cache, the - original function must be wrapped which will slow down subsequent - calls, so only do this if your function is expensive. - - The new keyword argument interface and `excluded` argument support - further degrades performance. - - References - ---------- - .. [1] NumPy Reference, section `Generalized Universal Function API - `_. """ - def __init__(self, pyfunc, otypes=None, doc=None, excluded=None, cache=False, signature=None): self.pyfunc = pyfunc @@ -2602,7 +2602,7 @@ def blackman(M): Plot the window and the frequency response: >>> from numpy.fft import fft, fftshift - >>> window = np.blackman(51) + >>> window = np.blackman(51) + 1e-10 # eps shift to avoid division by zero >>> plt.plot(window) [] >>> plt.title("Blackman window") @@ -2709,7 +2709,7 @@ def bartlett(M): Plot the window and its frequency response (requires SciPy and matplotlib): >>> from numpy.fft import fft, fftshift - >>> window = np.bartlett(51) + >>> window = np.bartlett(51) + 1e-10 # eps shift to avoid division by zero >>> plt.plot(window) [] >>> plt.title("Bartlett window") @@ -2810,7 +2810,7 @@ def hanning(M): >>> import matplotlib.pyplot as plt >>> from numpy.fft import fft, fftshift - >>> window = np.hanning(51) + >>> window = np.hanning(51) + 1e-10 # eps shift to avoid division by zero >>> plt.plot(window) [] >>> plt.title("Hann window") -- cgit v1.2.1 From 26a8b418a9e19437d76b00be8a0a4f32aee68c4b Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Mon, 15 Apr 2019 16:52:02 +0200 Subject: DOC: fix doc build warnings in a cleaner way. Addresses review comment by @eric-wieser. --- numpy/lib/function_base.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index dad2e3bcd..e9908d1ef 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -2602,7 +2602,7 @@ def blackman(M): Plot the window and the frequency response: >>> from numpy.fft import fft, fftshift - >>> window = np.blackman(51) + 1e-10 # eps shift to avoid division by zero + >>> window = np.blackman(51) >>> plt.plot(window) [] >>> plt.title("Blackman window") @@ -2618,7 +2618,9 @@ def blackman(M): >>> A = fft(window, 2048) / 25.5 >>> mag = np.abs(fftshift(A)) >>> freq = np.linspace(-0.5, 0.5, len(A)) - >>> response = 20 * np.log10(mag) + >>> with np.errstate(divide='ignore', invalid='ignore'): + ... response = 20 * np.log10(mag) + ... >>> response = np.clip(response, -100, 100) >>> plt.plot(freq, response) [] @@ -2709,7 +2711,7 @@ def bartlett(M): Plot the window and its frequency response (requires SciPy and matplotlib): >>> from numpy.fft import fft, fftshift - >>> window = np.bartlett(51) + 1e-10 # eps shift to avoid division by zero + >>> window = np.bartlett(51) >>> plt.plot(window) [] >>> plt.title("Bartlett window") @@ -2725,7 +2727,9 @@ def bartlett(M): >>> A = fft(window, 2048) / 25.5 >>> mag = np.abs(fftshift(A)) >>> freq = np.linspace(-0.5, 0.5, len(A)) - >>> response = 20 * np.log10(mag) + >>> with np.errstate(divide='ignore', invalid='ignore'): + ... response = 20 * np.log10(mag) + ... >>> response = np.clip(response, -100, 100) >>> plt.plot(freq, response) [] @@ -2810,7 +2814,7 @@ def hanning(M): >>> import matplotlib.pyplot as plt >>> from numpy.fft import fft, fftshift - >>> window = np.hanning(51) + 1e-10 # eps shift to avoid division by zero + >>> window = np.hanning(51) >>> plt.plot(window) [] >>> plt.title("Hann window") @@ -2826,7 +2830,9 @@ def hanning(M): >>> A = fft(window, 2048) / 25.5 >>> mag = np.abs(fftshift(A)) >>> freq = np.linspace(-0.5, 0.5, len(A)) - >>> response = 20 * np.log10(mag) + >>> with np.errstate(divide='ignore', invalid='ignore'): + ... response = 20 * np.log10(mag) + ... >>> response = np.clip(response, -100, 100) >>> plt.plot(freq, response) [] -- cgit v1.2.1