summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/lib/function_base.py62
-rw-r--r--numpy/lib/polynomial.py1
-rw-r--r--numpy/lib/scimath.py16
-rw-r--r--numpy/lib/shape_base.py5
-rw-r--r--numpy/lib/utils.py3
5 files changed, 39 insertions, 48 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index cb2cbf29b..fe6e67903 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -319,8 +319,8 @@ def histogramdd(sample, bins=10, range=None, normed=False, weights=None):
Examples
--------
- >>> x = random.randn(100,3)
- >>> hist3d, edges = histogramdd(x, bins = (5, 6, 7))
+ >>> x = np.random.randn(100,3)
+ >>> hist3d, edges = np.lib.histogramdd(x, bins = (5, 6, 7))
"""
@@ -833,9 +833,9 @@ def angle(z, deg=0):
Examples
--------
- >>> numpy.angle(1+1j) # in radians
+ >>> np.angle(1+1j) # in radians
0.78539816339744828
- >>> numpy.angle(1+1j,deg=True) # in degrees
+ >>> np.angle(1+1j,deg=True) # in degrees
45.0
"""
@@ -893,9 +893,8 @@ def trim_zeros(filt, trim='fb'):
Examples
--------
- >>> import numpy
>>> a = array((0, 0, 0, 1, 2, 3, 2, 1, 0))
- >>> numpy.trim_zeros(a)
+ >>> np.trim_zeros(a)
array([1, 2, 3, 2, 1])
"""
@@ -922,7 +921,7 @@ def unique(x):
Examples
--------
- >>> numpy.unique([5,2,4,0,4,4,2,2,1])
+ >>> np.unique([5,2,4,0,4,4,2,2,1])
array([0, 1, 2, 4, 5])
"""
@@ -1270,35 +1269,33 @@ def bartlett(M):
Examples
--------
- >>> from numpy import bartlett
- >>> bartlett(12)
+ >>> np.bartlett(12)
array([ 0. , 0.18181818, 0.36363636, 0.54545455, 0.72727273,
0.90909091, 0.90909091, 0.72727273, 0.54545455, 0.36363636,
0.18181818, 0. ])
- Plot the window and its frequency response:
-
- >>> from numpy import clip, log10, array, bartlett
- >>> from scipy.fftpack import fft
- >>> from matplotlib import pyplot as plt
-
- >>> window = bartlett(51)
- >>> plt.plot(window)
- >>> plt.title("Bartlett window")
- >>> plt.ylabel("Amplitude")
- >>> plt.xlabel("Sample")
- >>> plt.show()
-
- >>> A = fft(window, 2048) / 25.5
- >>> mag = abs(fftshift(A))
- >>> freq = linspace(-0.5,0.5,len(A))
- >>> response = 20*log10(mag)
- >>> response = clip(response,-100,100)
- >>> plt.plot(freq, response)
- >>> plt.title("Frequency response of Bartlett window")
- >>> plt.ylabel("Magnitude [dB]")
- >>> plt.xlabel("Normalized frequency [cycles per sample]")
- >>> plt.axis('tight'); plt.show()
+ Plot the window and its frequency response (requires SciPy and matplotlib):
+
+ from scipy.fftpack import fft
+ from matplotlib import pyplot as plt
+
+ window = np.bartlett(51)
+ plt.plot(window) #doctest: SKIP
+ plt.title("Bartlett window")
+ plt.ylabel("Amplitude")
+ plt.xlabel("Sample")
+ plt.show()
+
+ A = fft(window, 2048) / 25.5
+ mag = abs(np.fft.fftshift(A))
+ freq = linspace(-0.5,0.5,len(A))
+ response = 20*np.log10(mag)
+ response = np.clip(response,-100,100)
+ plt.plot(freq, response)
+ plt.title("Frequency response of Bartlett window")
+ plt.ylabel("Magnitude [dB]")
+ plt.xlabel("Normalized frequency [cycles per sample]")
+ plt.axis('tight'); plt.show()
"""
if M < 1:
@@ -1489,7 +1486,6 @@ def median(a, axis=0, out=None, overwrite_input=False):
Examples
--------
- >>> import numpy as np
>>> from numpy import median
>>> a = np.array([[10, 7, 4], [3, 2, 1]])
>>> a
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
index ab2febf35..141e85e25 100644
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -223,7 +223,6 @@ def polyfit(x, y, deg, rcond=None, full=False):
-----
RankWarning : if rank is reduced and not full output
The warnings can be turned off by:
- >>> import numpy as np
>>> import warnings
>>> warnings.simplefilter('ignore',np.RankWarning)
diff --git a/numpy/lib/scimath.py b/numpy/lib/scimath.py
index f35c87578..d3965668d 100644
--- a/numpy/lib/scimath.py
+++ b/numpy/lib/scimath.py
@@ -46,8 +46,6 @@ def _tocomplex(arr):
Examples
--------
- >>> import numpy as np
-
First, consider an input of type short:
>>> a = np.array([1,2,3],np.short)
@@ -246,7 +244,7 @@ def log10(x):
--------
(We set the printing precision so the example can be auto-tested)
- >>> import numpy as np; np.set_printoptions(precision=4)
+ >>> np.set_printoptions(precision=4)
>>> log10([10**1,10**2])
array([ 1., 2.])
@@ -276,7 +274,7 @@ def logn(n, x):
--------
(We set the printing precision so the example can be auto-tested)
- >>> import numpy as np; np.set_printoptions(precision=4)
+ >>> np.set_printoptions(precision=4)
>>> logn(2,[4,8])
array([ 2., 3.])
@@ -306,7 +304,7 @@ def log2(x):
--------
(We set the printing precision so the example can be auto-tested)
- >>> import numpy as np; np.set_printoptions(precision=4)
+ >>> np.set_printoptions(precision=4)
>>> log2([4,8])
array([ 2., 3.])
@@ -336,7 +334,7 @@ def power(x, p):
Examples
--------
(We set the printing precision so the example can be auto-tested)
- >>> import numpy as np; np.set_printoptions(precision=4)
+ >>> np.set_printoptions(precision=4)
>>> power([2,4],2)
array([ 4, 16])
@@ -368,7 +366,7 @@ def arccos(x):
Examples
--------
- >>> import numpy as np; np.set_printoptions(precision=4)
+ >>> np.set_printoptions(precision=4)
>>> arccos(1)
0.0
@@ -397,7 +395,7 @@ def arcsin(x):
Examples
--------
(We set the printing precision so the example can be auto-tested)
- >>> import numpy as np; np.set_printoptions(precision=4)
+ >>> np.set_printoptions(precision=4)
>>> arcsin(0)
0.0
@@ -426,7 +424,7 @@ def arctanh(x):
Examples
--------
(We set the printing precision so the example can be auto-tested)
- >>> import numpy as np; np.set_printoptions(precision=4)
+ >>> np.set_printoptions(precision=4)
>>> arctanh(0)
0.0
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index 9ac77666f..77f158eb3 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -192,15 +192,14 @@ def vstack(tup):
tup -- sequence of arrays. All arrays must have the same
shape.
Examples:
- >>> import numpy
>>> a = array((1,2,3))
>>> b = array((2,3,4))
- >>> numpy.vstack((a,b))
+ >>> np.vstack((a,b))
array([[1, 2, 3],
[2, 3, 4]])
>>> a = array([[1],[2],[3]])
>>> b = array([[2],[3],[4]])
- >>> numpy.vstack((a,b))
+ >>> np.vstack((a,b))
array([[1],
[2],
[3],
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index 3f7d22092..8a119722b 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -316,8 +316,7 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'):
"""Get help information for a function, class, or module.
Example:
- >>> from numpy import *
- >>> info(polyval) # doctest: +SKIP
+ >>> np.info(np.polyval) # doctest: +SKIP
polyval(p, x)