Skip to content

Commit 00dda8d

Browse files
committed
Add basic docstrings to the array API wrapper functions
The docstrings just point back to the functions they wrap for now. More thought may need to be put into this for the future. Most functions can actually perhaps inherit the docstring of the function they wrap directly, but there are some functions that have differences (e.g., different names, different keyword arguments, fewer keyword arguments, etc.). There's also the question of how to handle cross-references/see alsos that point to functions not in the API spec and behavior shown in docstring examples that isn't required in the spec.
1 parent a78d20a commit 00dda8d

8 files changed

+521
-1
lines changed

numpy/_array_api/_creation_functions.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,121 @@
11
import numpy as np
22

33
def arange(start, /, *, stop=None, step=1, dtype=None, device=None):
4+
"""
5+
Array API compatible wrapper for :py:func:`np.arange <numpy.arange>`.
6+
7+
See its docstring for more information.
8+
"""
49
if device is not None:
510
# Note: Device support is not yet implemented on ndarray
611
raise NotImplementedError("Device support is not yet implemented")
712
return np.arange(start, stop=stop, step=step, dtype=dtype)
813

914
def empty(shape, /, *, dtype=None, device=None):
15+
"""
16+
Array API compatible wrapper for :py:func:`np.empty <numpy.empty>`.
17+
18+
See its docstring for more information.
19+
"""
1020
if device is not None:
1121
# Note: Device support is not yet implemented on ndarray
1222
raise NotImplementedError("Device support is not yet implemented")
1323
return np.empty(shape, dtype=dtype)
1424

1525
def empty_like(x, /, *, dtype=None, device=None):
26+
"""
27+
Array API compatible wrapper for :py:func:`np.empty_like <numpy.empty_like>`.
28+
29+
See its docstring for more information.
30+
"""
1631
if device is not None:
1732
# Note: Device support is not yet implemented on ndarray
1833
raise NotImplementedError("Device support is not yet implemented")
1934
return np.empty_like(x, dtype=dtype)
2035

2136
def eye(N, /, *, M=None, k=0, dtype=None, device=None):
37+
"""
38+
Array API compatible wrapper for :py:func:`np.eye <numpy.eye>`.
39+
40+
See its docstring for more information.
41+
"""
2242
if device is not None:
2343
# Note: Device support is not yet implemented on ndarray
2444
raise NotImplementedError("Device support is not yet implemented")
2545
return np.eye(N, M=M, k=k, dtype=dtype)
2646

2747
def full(shape, fill_value, /, *, dtype=None, device=None):
48+
"""
49+
Array API compatible wrapper for :py:func:`np.full <numpy.full>`.
50+
51+
See its docstring for more information.
52+
"""
2853
if device is not None:
2954
# Note: Device support is not yet implemented on ndarray
3055
raise NotImplementedError("Device support is not yet implemented")
3156
return np.full(shape, fill_value, dtype=dtype)
3257

3358
def full_like(x, fill_value, /, *, dtype=None, device=None):
59+
"""
60+
Array API compatible wrapper for :py:func:`np.full_like <numpy.full_like>`.
61+
62+
See its docstring for more information.
63+
"""
3464
if device is not None:
3565
# Note: Device support is not yet implemented on ndarray
3666
raise NotImplementedError("Device support is not yet implemented")
3767
return np.full_like(x, fill_value, dtype=dtype)
3868

3969
def linspace(start, stop, num, /, *, dtype=None, device=None, endpoint=True):
70+
"""
71+
Array API compatible wrapper for :py:func:`np.linspace <numpy.linspace>`.
72+
73+
See its docstring for more information.
74+
"""
4075
if device is not None:
4176
# Note: Device support is not yet implemented on ndarray
4277
raise NotImplementedError("Device support is not yet implemented")
4378
return np.linspace(start, stop, num, dtype=dtype, endpoint=endpoint)
4479

4580
def ones(shape, /, *, dtype=None, device=None):
81+
"""
82+
Array API compatible wrapper for :py:func:`np.ones <numpy.ones>`.
83+
84+
See its docstring for more information.
85+
"""
4686
if device is not None:
4787
# Note: Device support is not yet implemented on ndarray
4888
raise NotImplementedError("Device support is not yet implemented")
4989
return np.ones(shape, dtype=dtype)
5090

5191
def ones_like(x, /, *, dtype=None, device=None):
92+
"""
93+
Array API compatible wrapper for :py:func:`np.ones_like <numpy.ones_like>`.
94+
95+
See its docstring for more information.
96+
"""
5297
if device is not None:
5398
# Note: Device support is not yet implemented on ndarray
5499
raise NotImplementedError("Device support is not yet implemented")
55100
return np.ones_like(x, dtype=dtype)
56101

57102
def zeros(shape, /, *, dtype=None, device=None):
103+
"""
104+
Array API compatible wrapper for :py:func:`np.zeros <numpy.zeros>`.
105+
106+
See its docstring for more information.
107+
"""
58108
if device is not None:
59109
# Note: Device support is not yet implemented on ndarray
60110
raise NotImplementedError("Device support is not yet implemented")
61111
return np.zeros(shape, dtype=dtype)
62112

63113
def zeros_like(x, /, *, dtype=None, device=None):
114+
"""
115+
Array API compatible wrapper for :py:func:`np.zeros_like <numpy.zeros_like>`.
116+
117+
See its docstring for more information.
118+
"""
64119
if device is not None:
65120
# Note: Device support is not yet implemented on ndarray
66121
raise NotImplementedError("Device support is not yet implemented")

0 commit comments

Comments
 (0)