summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2022-02-14 21:57:18 +0200
committerGitHub <noreply@github.com>2022-02-14 21:57:18 +0200
commit5b9b9395036702a23275592293c6501f423269ba (patch)
treea8158799b96df46477c0b03fbaa5837c4b364cbb
parent5eab6434dd3646f1df78d38454f316e84723dc4f (diff)
parent3f18d8fab26fb473e495f2e82600ce170d1c577c (diff)
downloadnumpy-5b9b9395036702a23275592293c6501f423269ba.tar.gz
Merge pull request #21015 from melissawm/doc-arange-signature
DOC: Added note about possible arange signatures
-rw-r--r--numpy/core/_add_newdocs.py17
-rw-r--r--numpy/core/overrides.py2
2 files changed, 14 insertions, 5 deletions
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index e432f6a11..6ac9951fb 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -1598,15 +1598,24 @@ add_newdoc('numpy.core.multiarray', 'arange',
Return evenly spaced values within a given interval.
- Values are generated within the half-open interval ``[start, stop)``
- (in other words, the interval including `start` but excluding `stop`).
+ ``arange`` can be called with a varying number of positional arguments:
+
+ * ``arange(stop)``: Values are generated within the half-open interval
+ ``[0, stop)`` (in other words, the interval including `start` but
+ excluding `stop`).
+ * ``arange(start, stop)``: Values are generated within the half-open
+ interval ``[start, stop)``.
+ * ``arange(start, stop, step)`` Values are generated within the half-open
+ interval ``[start, stop)``, with spacing between values given by
+ ``step``.
+
For integer arguments the function is roughly equivalent to the Python
built-in :py:class:`range`, but returns an ndarray rather than a ``range``
instance.
When using a non-integer step, such as 0.1, it is often better to use
`numpy.linspace`.
-
+
See the Warning sections below for more information.
Parameters
@@ -1623,7 +1632,7 @@ add_newdoc('numpy.core.multiarray', 'arange',
between two adjacent values, ``out[i+1] - out[i]``. The default
step size is 1. If `step` is specified as a position argument,
`start` must also be given.
- dtype : dtype
+ dtype : dtype, optional
The type of the output array. If `dtype` is not given, infer the data
type from the other input arguments.
${ARRAY_FUNCTION_LIKE}
diff --git a/numpy/core/overrides.py b/numpy/core/overrides.py
index 840cf38c9..cb550152e 100644
--- a/numpy/core/overrides.py
+++ b/numpy/core/overrides.py
@@ -12,7 +12,7 @@ ARRAY_FUNCTION_ENABLED = bool(
int(os.environ.get('NUMPY_EXPERIMENTAL_ARRAY_FUNCTION', 1)))
array_function_like_doc = (
- """like : array_like
+ """like : array_like, optional
Reference object to allow the creation of arrays which are not
NumPy arrays. If an array-like passed in as ``like`` supports
the ``__array_function__`` protocol, the result will be defined