From ccbf5cf2fc35ec0a3e2c184fb846bb808aee3610 Mon Sep 17 00:00:00 2001 From: endolith Date: Sun, 16 Sep 2012 21:01:28 -0300 Subject: 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. --- numpy/lib/function_base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'numpy/lib/function_base.py') 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)) -- cgit v1.2.1