summaryrefslogtreecommitdiff
path: root/numpy/_array_api/_creation_functions.py
diff options
context:
space:
mode:
authorAaron Meurer <asmeurer@gmail.com>2021-02-23 16:17:07 -0700
committerAaron Meurer <asmeurer@gmail.com>2021-02-23 16:17:07 -0700
commitf2ac67e236c1dbc60f66c4a4b041403a197e52f2 (patch)
treec4c50c88cb923667d94666a1558108f9decca963 /numpy/_array_api/_creation_functions.py
parentaffc5f0c2581a8d17825bcb7d9610e4f58560b5d (diff)
downloadnumpy-f2ac67e236c1dbc60f66c4a4b041403a197e52f2.tar.gz
Update array_api namespace with latest changes from the spec
Diffstat (limited to 'numpy/_array_api/_creation_functions.py')
-rw-r--r--numpy/_array_api/_creation_functions.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/numpy/_array_api/_creation_functions.py b/numpy/_array_api/_creation_functions.py
index 68326f291..d015734ff 100644
--- a/numpy/_array_api/_creation_functions.py
+++ b/numpy/_array_api/_creation_functions.py
@@ -1,9 +1,21 @@
from __future__ import annotations
-from ._types import Optional, Tuple, Union, array, device, dtype
+from ._types import (Optional, SupportsDLPack, SupportsBufferProtocol, Tuple,
+ Union, array, device, dtype)
import numpy as np
+def asarray(obj: Union[float, NestedSequence[bool|int|float], SupportsDLPack, SupportsBufferProtocol], /, *, dtype: Optional[dtype] = None, device: Optional[device] = None, copy: Optional[bool] = None) -> array:
+ """
+ Array API compatible wrapper for :py:func:`np.asarray <numpy.asarray>`.
+
+ See its docstring for more information.
+ """
+ if device is not None:
+ # Note: Device support is not yet implemented on ndarray
+ raise NotImplementedError("Device support is not yet implemented")
+ return np.asarray(obj, dtype=dtype, copy=copy)
+
def arange(start: Union[int, float], /, *, stop: Optional[Union[int, float]] = None, step: Union[int, float] = 1, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
"""
Array API compatible wrapper for :py:func:`np.arange <numpy.arange>`.
@@ -48,6 +60,10 @@ def eye(N: int, /, *, M: Optional[int] = None, k: Optional[int] = 0, dtype: Opti
raise NotImplementedError("Device support is not yet implemented")
return np.eye(N, M=M, k=k, dtype=dtype)
+def from_dlpack(x: object, /) -> array:
+ # Note: dlpack support is not yet implemented on ndarray
+ raise NotImplementedError("DLPack support is not yet implemented")
+
def full(shape: Union[int, Tuple[int, ...]], fill_value: Union[int, float], /, *, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:
"""
Array API compatible wrapper for :py:func:`np.full <numpy.full>`.