From 16abbef11489c512b24018a3c8557b12b2d50f40 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Thu, 14 Dec 2023 21:04:59 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- numpy/numerical_ranges​/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/numpy/numerical_ranges​/README.md b/numpy/numerical_ranges​/README.md index 331986b..a4ecbc8 100644 --- a/numpy/numerical_ranges​/README.md +++ b/numpy/numerical_ranges​/README.md @@ -98,6 +98,24 @@ numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, ax > > If True, stop is the last sample. Otherwise, it is not included. Default is True. +An example: + +```python +import numpy as np + +print(np.linspace(0, 1, num=10, endpoint=False)) # -> [0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9] +print(np.arange(0, 10) / 10) # -> [0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9] +``` + +Be mindful concerning the endpoint setting (**Notice the ... 8 10]**): + +```python +import numpy as np + +print(np.linspace(0, 10, num=10, endpoint=False, dtype=int)) # -> [0 1 2 3 4 5 6 7 8 9] +print(np.linspace(0, 10, num=10, endpoint=True, dtype=int)) # -> [ 0 1 2 3 4 5 6 7 8 10] +``` + ## [numpy.logspace](https://numpy.org/doc/stable/reference/generated/numpy.logspace.html) ```python