diff options
author | Alan McIntyre <alan.mcintyre@local> | 2008-07-02 01:15:06 +0000 |
---|---|---|
committer | Alan McIntyre <alan.mcintyre@local> | 2008-07-02 01:15:06 +0000 |
commit | aa26afb8fbb6901bed42e895e410728b0dd1f6bc (patch) | |
tree | ce60c447f698888c62300b3fa0aaba83b3b7b9a7 | |
parent | bc01c96daf61de61046c5ac7d17a80ab35ccd0ef (diff) | |
download | numpy-aa26afb8fbb6901bed42e895e410728b0dd1f6bc.tar.gz |
Update doctests to use the implicit "import numpy as np" made available
to all doctests.
-rw-r--r-- | numpy/core/arrayprint.py | 5 | ||||
-rw-r--r-- | numpy/core/defmatrix.py | 4 | ||||
-rw-r--r-- | numpy/core/memmap.py | 1 | ||||
-rw-r--r-- | numpy/core/numeric.py | 22 | ||||
-rw-r--r-- | numpy/core/records.py | 14 |
5 files changed, 18 insertions, 28 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 99f9c8607..377457e23 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -218,9 +218,8 @@ def array2string(a, max_line_width = None, precision = None, Examples -------- - >>> import numpy as N - >>> x = N.array([1e-16,1,2,3]) - >>> print array2string(x,precision=2,separator=',',suppress_small=True) + >>> x = np.array([1e-16,1,2,3]) + >>> print np.core.array2string(x,precision=2,separator=',',suppress_small=True) [ 0., 1., 2., 3.] """ diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py index b577df4a6..2008ba62e 100644 --- a/numpy/core/defmatrix.py +++ b/numpy/core/defmatrix.py @@ -84,8 +84,7 @@ def matrix_power(M,n): Examples -------- - >>> from numpy import array - >>> matrix_power(array([[0,1],[-1,0]]),10) + >>> np.linalg.matrix_power(np.array([[0,1],[-1,0]]),10) array([[-1, 0], [ 0, -1]]) """ @@ -149,7 +148,6 @@ class matrix(N.ndarray): Examples -------- - >>> import numpy as np >>> a = np.matrix('1 2; 3 4') >>> print a [[1 2] diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index c7705d263..14aa409c4 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -67,7 +67,6 @@ class memmap(ndarray): Examples -------- - >>> import numpy as np >>> data = np.arange(12, dtype='float32') >>> data.resize((3,4)) diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 47e11bb1f..3e4b6cb1f 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -214,8 +214,7 @@ def argwhere(a): is a sequence of indices into a. This sequence must be converted to a tuple in order to be used to index into a. - >>> from numpy import ones, argwhere - >>> argwhere(ones((2, 2))) + >>> np.argwhere(np.ones((2, 2))) array([[0, 0], [0, 1], [1, 0], @@ -228,10 +227,9 @@ def flatnonzero(a): Equivalent to a.ravel().nonzero()[0] - >>> from numpy import arange, flatnonzero - >>> arange(-2, 3) + >>> np.arange(-2, 3) array([-2, -1, 0, 1, 2]) - >>> flatnonzero(arange(-2, 3)) + >>> np.flatnonzero(np.arange(-2, 3)) array([0, 1, 3, 4]) """ return a.ravel().nonzero()[0] @@ -385,10 +383,9 @@ def roll(a, shift, axis=None): """Roll the elements in the array by 'shift' positions along the given axis. - >>> from numpy import roll - >>> arange(10) + >>> np.arange(10) array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - >>> roll(arange(10), 2) + >>> np.roll(np.arange(10), 2) array([8, 9, 0, 1, 2, 3, 4, 5, 6, 7]) """ a = asanyarray(a) @@ -409,13 +406,12 @@ def roll(a, shift, axis=None): def rollaxis(a, axis, start=0): """Return transposed array so that axis is rolled before start. - >>> from numpy import ones, rollaxis - >>> a = ones((3,4,5,6)) - >>> rollaxis(a, 3, 1).shape + >>> a = np.ones((3,4,5,6)) + >>> np.rollaxis(a, 3, 1).shape (3, 6, 4, 5) - >>> rollaxis(a, 2, 0).shape + >>> np.rollaxis(a, 2, 0).shape (5, 3, 4, 6) - >>> rollaxis(a, 1, 4).shape + >>> np.rollaxis(a, 1, 4).shape (3, 5, 6, 4) """ n = a.ndim diff --git a/numpy/core/records.py b/numpy/core/records.py index 845e1300c..26ebba450 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -347,11 +347,10 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None): """ create a record array from a (flat) list of arrays - >>> import numpy as N - >>> x1=N.array([1,2,3,4]) - >>> x2=N.array(['a','dd','xyz','12']) - >>> x3=N.array([1.1,2,3,4]) - >>> r = fromarrays([x1,x2,x3],names='a,b,c') + >>> x1=np.array([1,2,3,4]) + >>> x2=np.array(['a','dd','xyz','12']) + >>> x3=np.array([1.1,2,3,4]) + >>> r = np.core.records.fromarrays([x1,x2,x3],names='a,b,c') >>> print r[1] (2, 'dd', 2.0) >>> x1[1]=34 @@ -515,8 +514,7 @@ def fromfile(fd, dtype=None, shape=None, offset=0, formats=None, to be a file object. >>> from tempfile import TemporaryFile - >>> import numpy as N - >>> a = N.empty(10,dtype='f8,i4,a5') + >>> a = np.empty(10,dtype='f8,i4,a5') >>> a[5] = (0.5,10,'abcde') >>> >>> fd=TemporaryFile() @@ -524,7 +522,7 @@ def fromfile(fd, dtype=None, shape=None, offset=0, formats=None, >>> a.tofile(fd) >>> >>> fd.seek(0) - >>> r=fromfile(fd, formats='f8,i4,a5', shape=10, byteorder='<') + >>> r=np.fromfile(fd, formats='f8,i4,a5', shape=10, byteorder='<') >>> print r[5] (0.5, 10, 'abcde') >>> r.shape |