summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2007-02-18 22:43:40 +0000
committerStefan van der Walt <stefan@sun.ac.za>2007-02-18 22:43:40 +0000
commit9bcf9ef90b0893a157e5d69478b9a9566b966249 (patch)
tree409d290d8d465d44b801cf5d38ee4677e7976415 /numpy/lib
parentb860a39925a5e0a49d54fa363ccdf6113dfef12d (diff)
downloadnumpy-9bcf9ef90b0893a157e5d69478b9a9566b966249.tar.gz
Fix doctests.
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/function_base.py42
-rw-r--r--numpy/lib/index_tricks.py25
-rw-r--r--numpy/lib/polynomial.py2
-rw-r--r--numpy/lib/shape_base.py26
-rw-r--r--numpy/lib/utils.py3
5 files changed, 54 insertions, 44 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 14f02f797..5d3e75036 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -665,7 +665,7 @@ def unique(x):
Example:
>>> unique([5,2,4,0,4,4,2,2,1])
- array([0,1,2,4,5])
+ array([0, 1, 2, 4, 5])
"""
try:
@@ -806,13 +806,13 @@ class vectorize(object):
Example:
- def myfunc(a, b):
- if a > b:
- return a-b
- else
- return a+b
+ >>> def myfunc(a, b):
+ ... if a > b:
+ ... return a-b
+ ... else:
+ ... return a+b
- vfunc = vectorize(myfunc)
+ >>> vfunc = vectorize(myfunc)
>>> vfunc([1, 2, 3, 4], 2)
array([3, 4, 1, 2])
@@ -1197,16 +1197,16 @@ def delete(arr, obj, axis=None):
Example:
>>> arr = [[3,4,5],
- [1,2,3],
- [6,7,8]]
+ ... [1,2,3],
+ ... [6,7,8]]
>>> delete(arr, 1, 1)
- array([[3,5],
- [1,3],
- [6,8])
+ array([[3, 5],
+ [1, 3],
+ [6, 8]])
>>> delete(arr, 1, 0)
- array([[3,4,5],
- [6,7,8]])
+ array([[3, 4, 5],
+ [6, 7, 8]])
"""
wrap = None
if type(arr) is not ndarray:
@@ -1300,15 +1300,15 @@ def insert(arr, obj, values, axis=None):
Example:
>>> a = array([[1,2,3],
- [4,5,6],
- [7,8,9]])
+ ... [4,5,6],
+ ... [7,8,9]])
>>> insert(a, [1,2], [[4],[5]], axis=0)
- array([[1,2,3],
- [4,4,4],
- [4,5,6],
- [5,5,5],
- [7,8,9])
+ array([[1, 2, 3],
+ [4, 4, 4],
+ [4, 5, 6],
+ [5, 5, 5],
+ [7, 8, 9]])
"""
wrap = None
if type(arr) is not ndarray:
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index 8f8e1b235..5568634e5 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -108,6 +108,7 @@ class nd_grid(object):
[2, 2, 2, 2, 2],
[3, 3, 3, 3, 3],
[4, 4, 4, 4, 4]],
+ <BLANKLINE>
[[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
@@ -118,7 +119,11 @@ class nd_grid(object):
>>> ogrid = nd_grid(sparse=True)
>>> ogrid[0:5,0:5]
- [array([[0],[1],[2],[3],[4]]), array([[0, 1, 2, 3, 4]])]
+ [array([[0],
+ [1],
+ [2],
+ [3],
+ [4]]), array([[0, 1, 2, 3, 4]])]
"""
def __init__(self, sparse=False):
@@ -359,15 +364,15 @@ class ndindex(object):
will then return an N-dimensional counter.
Example:
- >>> for index in ndindex(4,3,2):
- print index
- (0,0,0)
- (0,0,1)
- (0,1,0)
- ...
- (3,1,1)
- (3,2,0)
- (3,2,1)
+ >>> for index in ndindex(3,2,1):
+ ... print index
+ (0, 0, 0)
+ (0, 1, 0)
+ (1, 0, 0)
+ (1, 1, 0)
+ (2, 0, 0)
+ (2, 1, 0)
+
"""
def __init__(self, *args):
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
index ff429e3f8..4e1db5525 100644
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -56,7 +56,7 @@ def poly(seq_of_zeros):
>>> b = roots([1,3,1,5,6])
>>> poly(b)
- array([1., 3., 1., 5., 6.])
+ array([ 1., 3., 1., 5., 6.])
"""
seq_of_zeros = atleast_1d(seq_of_zeros)
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index 1e9b55bb6..d061ee774 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -288,15 +288,17 @@ def dstack(tup):
>>> a = array((1,2,3))
>>> b = array((2,3,4))
>>> numpy.dstack((a,b))
- array([ [[1, 2],
- [2, 3],
- [3, 4]]])
+ array([[[1, 2],
+ [2, 3],
+ [3, 4]]])
>>> a = array([[1],[2],[3]])
>>> b = array([[2],[3],[4]])
>>> numpy.dstack((a,b))
- array([[ [1, 2]],
- [ [2, 3]],
- [ [3, 4]]])
+ array([[[1, 2]],
+ <BLANKLINE>
+ [[2, 3]],
+ <BLANKLINE>
+ [[3, 4]]])
"""
return _nx.concatenate(map(atleast_3d,tup),2)
@@ -436,6 +438,7 @@ def hsplit(ary,indices_or_sections):
>>> numpy.hsplit(a,2)
[array([1, 2]), array([3, 4])]
>>> a = array([[1,2,3,4],[1,2,3,4]])
+ >>> hsplit(a,2)
[array([[1, 2],
[1, 2]]), array([[3, 4],
[3, 4]])]
@@ -482,8 +485,8 @@ def vsplit(ary,indices_or_sections):
import numpy
>>> a = array([[1,2,3,4],
... [1,2,3,4]])
- >>> numpy.vsplit(a)
- [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]
+ >>> numpy.vsplit(a,2)
+ [array([[1, 2, 3, 4]]), array([[1, 2, 3, 4]])]
"""
if len(_nx.shape(ary)) < 2:
@@ -518,8 +521,9 @@ def dsplit(ary,indices_or_sections):
dstack, split, array_split, hsplit, vsplit.
Examples:
>>> a = array([[[1,2,3,4],[1,2,3,4]]])
- [array([ [[1, 2],
- [1, 2]]]), array([ [[3, 4],
+ >>> dsplit(a,2)
+ [array([[[1, 2],
+ [1, 2]]]), array([[[3, 4],
[3, 4]]])]
"""
@@ -603,7 +607,7 @@ def tile(A, reps):
[0, 1, 2, 0, 1, 2]])
>>> tile(a,(2,1,2))
array([[[0, 1, 2, 0, 1, 2]],
-
+ <BLANKLINE>
[[0, 1, 2, 0, 1, 2]]])
See Also:
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index ed156bb79..743985250 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -269,7 +269,8 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'):
Example:
>>> from numpy import *
- >>> info(polyval)
+ >>> info(polyval) # doctest: +SKIP
+
polyval(p, x)
Evaluate the polymnomial p at x.