summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorendolith <endolith@gmail.com>2012-09-16 21:01:28 -0300
committerCharles Harris <charlesr.harris@gmail.com>2012-09-17 10:05:52 -0600
commitccbf5cf2fc35ec0a3e2c184fb846bb808aee3610 (patch)
treea764477183164c51572db4b78bdd87d31ce4d419 /numpy/lib/function_base.py
parentd8988abc295ef2d6cf1e3a5ffb0d766ebd4cd3a8 (diff)
downloadnumpy-ccbf5cf2fc35ec0a3e2c184fb846bb808aee3610.tar.gz
MAINT: Use linspace instead of arange in some examples.
The original code used arange with offsets and scaling to generate sample points. Using linspace simplifies the code and clarifies the intent.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 2b1d780d2..e32492958 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -660,7 +660,7 @@ def piecewise(x, condlist, funclist, *args, **kw):
--------
Define the sigma function, which is -1 for ``x < 0`` and +1 for ``x >= 0``.
- >>> x = np.arange(6) - 2.5
+ >>> x = np.linspace(-2.5, 2.5, 6)
>>> np.piecewise(x, [x < 0, x >= 0], [-1, 1])
array([-1., -1., -1., 1., 1., 1.])
@@ -2827,7 +2827,7 @@ def sinc(x):
Examples
--------
- >>> x = np.arange(-20., 21.)/5.
+ >>> x = np.linspace(-4, 4, 41)
>>> np.sinc(x)
array([ -3.89804309e-17, -4.92362781e-02, -8.40918587e-02,
-8.90384387e-02, -5.84680802e-02, 3.89804309e-17,
@@ -2856,7 +2856,7 @@ def sinc(x):
It works in 2-D as well:
- >>> x = np.arange(-200., 201.)/50.
+ >>> x = np.linspace(-4, 4, 401)
>>> xx = np.outer(x, x)
>>> plt.imshow(np.sinc(xx))
<matplotlib.image.AxesImage object at 0x...>