summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <43369155+BvB93@users.noreply.github.com>2020-07-30 05:59:19 +0200
committerGitHub <noreply@github.com>2020-07-29 20:59:19 -0700
commitaca0ce63d92d85f507f5fc08ab23432dab9e9735 (patch)
tree4060f0dc9ba57cd4083069214749b8ed367441ba
parentb46e5d3ecb9dcc6e167579f5e5cc0978a8e59e93 (diff)
downloadnumpy-aca0ce63d92d85f507f5fc08ab23432dab9e9735.tar.gz
MAINT: Added the `order` parameter to `np.array()` (#16966)
* MAINT: Added the `order` argument to `np.array()` * MAINT: Made a number of `np.array()` arguments keyword-only * TST: Added a `np.array` test with >2 positional arguments
-rw-r--r--numpy/__init__.pyi2
-rw-r--r--numpy/tests/typing/fail/simple.py2
-rw-r--r--numpy/tests/typing/pass/simple.py8
3 files changed, 12 insertions, 0 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index ff2cc565e..fad5e1774 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -519,7 +519,9 @@ class str_(character):
def array(
object: object,
dtype: DtypeLike = ...,
+ *,
copy: bool = ...,
+ order: Optional[str] = ...,
subok: bool = ...,
ndmin: int = ...,
) -> ndarray: ...
diff --git a/numpy/tests/typing/fail/simple.py b/numpy/tests/typing/fail/simple.py
index b5e9d1b13..57c08fb7d 100644
--- a/numpy/tests/typing/fail/simple.py
+++ b/numpy/tests/typing/fail/simple.py
@@ -8,3 +8,5 @@ np.zeros() # E: Too few arguments
np.ones("test") # E: incompatible type
np.ones() # E: Too few arguments
+
+np.array(0, float, True) # E: Too many positional
diff --git a/numpy/tests/typing/pass/simple.py b/numpy/tests/typing/pass/simple.py
index e0157ab81..1fe6df54f 100644
--- a/numpy/tests/typing/pass/simple.py
+++ b/numpy/tests/typing/pass/simple.py
@@ -18,6 +18,14 @@ array == 1
array.dtype == float
# Array creation routines checks
+np.array(1, dtype=float)
+np.array(1, copy=False)
+np.array(1, order='F')
+np.array(1, order=None)
+np.array(1, subok=True)
+np.array(1, ndmin=3)
+np.array(1, str, copy=True, order='C', subok=False, ndmin=2)
+
ndarray_func(np.zeros([1, 2]))
ndarray_func(np.ones([1, 2]))
ndarray_func(np.empty([1, 2]))