# [Numpy-svn] r5337 - trunk/numpy/lib

numpy-svn@scip... numpy-svn@scip...
Wed Jul 2 22:51:50 CDT 2008

```Author: alan.mcintyre
Date: 2008-07-02 22:51:46 -0500 (Wed, 02 Jul 2008)
New Revision: 5337

Modified:
trunk/numpy/lib/function_base.py
trunk/numpy/lib/polynomial.py
trunk/numpy/lib/scimath.py
trunk/numpy/lib/shape_base.py
trunk/numpy/lib/utils.py
Log:
Use the implicit "import numpy as np" made available to all doctests instead of an explicit
import.
Remove ">>>" from bartlett plotting example since it currently requires matplotlib.

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2008-07-03 03:35:50 UTC (rev 5336)
+++ trunk/numpy/lib/function_base.py	2008-07-03 03:51:46 UTC (rev 5337)
@@ -319,8 +319,8 @@

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 @@

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 @@

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 @@

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 @@

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:
+    Plot the window and its frequency response (requires SciPy and matplotlib):

-    >>> from numpy import clip, log10, array, bartlett
-    >>> from scipy.fftpack import fft
-    >>> from matplotlib import pyplot as plt
+    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()
+    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(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()
+    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 @@

Examples
--------
-    >>> import numpy as np
>>> from numpy import median
>>> a = np.array([[10, 7, 4], [3, 2, 1]])
>>> a

Modified: trunk/numpy/lib/polynomial.py
===================================================================
--- trunk/numpy/lib/polynomial.py	2008-07-03 03:35:50 UTC (rev 5336)
+++ trunk/numpy/lib/polynomial.py	2008-07-03 03:51:46 UTC (rev 5337)
@@ -223,7 +223,6 @@
-----
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)

Modified: trunk/numpy/lib/scimath.py
===================================================================
--- trunk/numpy/lib/scimath.py	2008-07-03 03:35:50 UTC (rev 5336)
+++ trunk/numpy/lib/scimath.py	2008-07-03 03:51:46 UTC (rev 5337)
@@ -46,8 +46,6 @@
Examples
--------

-    >>> import numpy as np
-
First, consider an input of type short:

>>> a = np.array([1,2,3],np.short)
@@ -246,7 +244,7 @@
--------

(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 @@
--------

(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 @@
--------

(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 @@
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 @@

Examples
--------
-    >>> import numpy as np; np.set_printoptions(precision=4)
+    >>> np.set_printoptions(precision=4)

>>> arccos(1)
0.0
@@ -397,7 +395,7 @@
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 @@
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

Modified: trunk/numpy/lib/shape_base.py
===================================================================
--- trunk/numpy/lib/shape_base.py	2008-07-03 03:35:50 UTC (rev 5336)
+++ trunk/numpy/lib/shape_base.py	2008-07-03 03:51:46 UTC (rev 5337)
@@ -192,15 +192,14 @@
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],

Modified: trunk/numpy/lib/utils.py
===================================================================
--- trunk/numpy/lib/utils.py	2008-07-03 03:35:50 UTC (rev 5336)
+++ trunk/numpy/lib/utils.py	2008-07-03 03:51:46 UTC (rev 5337)
@@ -316,8 +316,7 @@
"""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)

```